- Drop Product.personal_rating from model, API schemas, and all frontend views (list table, detail view, quick-edit form, new-product form) - Extract get_or_404 into backend/innercontext/api/utils.py; remove five duplicate copies from individual API modules - Fix all ty type errors: generic get_or_404 with TypeVar, cast() in coerce_effect_profile validator, col() for ilike on SQLModel column, dict[str, Any] annotation in test helper, ty: ignore for CORSMiddleware Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.1 KiB
Python
38 lines
1.1 KiB
Python
from contextlib import asynccontextmanager
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv() # load .env before db.py reads DATABASE_URL
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from db import create_db_and_tables
|
|
from innercontext.api import health, inventory, products, routines, skincare
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
create_db_and_tables()
|
|
yield
|
|
|
|
|
|
app = FastAPI(title="innercontext API", lifespan=lifespan, redirect_slashes=False)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware, # ty: ignore[invalid-argument-type]
|
|
allow_origins=["*"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
app.include_router(products.router, prefix="/products", tags=["products"])
|
|
app.include_router(inventory.router, prefix="/inventory", tags=["inventory"])
|
|
app.include_router(health.router, prefix="/health", tags=["health"])
|
|
app.include_router(routines.router, prefix="/routines", tags=["routines"])
|
|
app.include_router(skincare.router, prefix="/skincare", tags=["skincare"])
|
|
|
|
|
|
@app.get("/health-check")
|
|
def health_check():
|
|
return {"status": "ok"}
|