添加用户鉴权

This commit is contained in:
ChengCan
2026-03-26 11:06:10 +08:00
parent f7b264e6c8
commit 3e3f4390a6
12 changed files with 379 additions and 29 deletions

View File

@@ -5,12 +5,16 @@ from fastapi import FastAPI
try:
# For module mode: `uvicorn app.main:app`
from app.db import check_db_connection, close_db_engine
from app.middleware.auth import install_auth_middleware
from app.routers.auth import router as auth_router
from app.routers.health import router as health_router
from app.routers.messages import router as messages_router
from app.settings import settings
except ModuleNotFoundError:
# For script mode: `python app/main.py` or VS Code "Run Python File"
from db import check_db_connection, close_db_engine
from middleware.auth import install_auth_middleware
from routers.auth import router as auth_router
from routers.health import router as health_router
from routers.messages import router as messages_router
from settings import settings
@@ -31,6 +35,8 @@ def create_app() -> FastAPI:
def on_shutdown() -> None:
close_db_engine()
install_auth_middleware(app)
app.include_router(auth_router)
app.include_router(health_router)
app.include_router(messages_router)
return app