feat(api): add admin household management endpoints
This commit is contained in:
parent
4bfa4ea02d
commit
1d5630ed8c
3 changed files with 566 additions and 4 deletions
|
|
@ -1,9 +1,9 @@
|
|||
from collections.abc import AsyncIterator
|
||||
from contextlib import asynccontextmanager
|
||||
from typing import AsyncIterator
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv() # load .env before db.py reads DATABASE_URL
|
||||
_ = load_dotenv() # load .env before db.py reads DATABASE_URL
|
||||
|
||||
from fastapi import Depends, FastAPI # noqa: E402
|
||||
from fastapi.middleware.cors import CORSMiddleware # noqa: E402
|
||||
|
|
@ -11,6 +11,7 @@ from sqlmodel import Session # noqa: E402
|
|||
|
||||
from db import create_db_and_tables, engine # noqa: E402
|
||||
from innercontext.api import ( # noqa: E402
|
||||
admin,
|
||||
ai_logs,
|
||||
auth,
|
||||
health,
|
||||
|
|
@ -25,11 +26,11 @@ from innercontext.services.pricing_jobs import enqueue_pricing_recalc # noqa: E
|
|||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI) -> AsyncIterator[None]:
|
||||
async def lifespan(_app: FastAPI) -> AsyncIterator[None]:
|
||||
create_db_and_tables()
|
||||
try:
|
||||
with Session(engine) as session:
|
||||
enqueue_pricing_recalc(session)
|
||||
_ = enqueue_pricing_recalc(session)
|
||||
session.commit()
|
||||
except Exception as exc: # pragma: no cover
|
||||
print(f"[startup] failed to enqueue pricing recalculation job: {exc}")
|
||||
|
|
@ -52,6 +53,7 @@ app.add_middleware(
|
|||
protected = [Depends(get_current_user)]
|
||||
|
||||
app.include_router(auth.router, prefix="/auth", tags=["auth"])
|
||||
app.include_router(admin.router, prefix="/admin", tags=["admin"])
|
||||
app.include_router(
|
||||
products.router,
|
||||
prefix="/products",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue