Globals restructured to their own module. Origin and RP definition.

This commit is contained in:
Leo Vasanko
2025-08-06 13:23:35 -06:00
parent 5a129220aa
commit dcca3e3fbd
11 changed files with 120 additions and 67 deletions

View File

@@ -1,6 +1,5 @@
import contextlib
import logging
from contextlib import asynccontextmanager
from pathlib import Path
from fastapi import Cookie, FastAPI, Request, Response
@@ -8,7 +7,6 @@ from fastapi.responses import FileResponse, JSONResponse
from fastapi.staticfiles import StaticFiles
from ..authsession import get_session
from ..db import db
from . import ws
from .api import register_api_routes
from .reset import register_reset_routes
@@ -16,25 +14,7 @@ from .reset import register_reset_routes
STATIC_DIR = Path(__file__).parent.parent / "frontend-build"
@asynccontextmanager
async def lifespan(app: FastAPI):
# Test if we have a database already initialized, otherwise use SQL
try:
db.instance
except RuntimeError:
from ..db import sql
await sql.init()
# Bootstrap system if needed
from ..bootstrap import bootstrap_if_needed
await bootstrap_if_needed()
yield
app = FastAPI(lifespan=lifespan)
app = FastAPI()
# Global exception handlers