feat: Semaine 8
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import os
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from starlette.middleware.sessions import SessionMiddleware
|
||||
|
||||
from infra.database import init_db, provision_data
|
||||
from presentation.routes.auth import router as auth_router
|
||||
from presentation.routes.secrets import router as secrets_router
|
||||
|
||||
# Use an environment variable in production; fall back to a dev default.
|
||||
_SESSION_SECRET = os.environ.get(
|
||||
"SESSION_SECRET", "secuvault-dev-secret-please-change-in-production"
|
||||
)
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
init_db()
|
||||
provision_data()
|
||||
yield
|
||||
|
||||
app = FastAPI(title="SecuVault", lifespan=lifespan)
|
||||
app.add_middleware(SessionMiddleware, secret_key=_SESSION_SECRET)
|
||||
|
||||
app.include_router(auth_router)
|
||||
app.include_router(secrets_router)
|
||||
Reference in New Issue
Block a user