- Delete routes: counter.py, sum.py - Delete jobs.py and worker.py - Delete tests: test_counter.py, test_jobs.py - Update audit.py: keep only price-history endpoints - Update models.py: remove VIEW_COUNTER, INCREMENT_COUNTER, USE_SUM permissions - Update models.py: remove Counter, SumRecord, CounterRecord, RandomNumberOutcome models - Update schemas.py: remove sum/counter related schemas - Update main.py: remove deleted router imports - Update test_permissions.py: remove tests for deprecated features - Update test_price_history.py: remove worker-related tests - Update conftest.py: remove mock_enqueue_job fixture - Update auth.py: fix example in docstring
51 lines
1.5 KiB
Python
51 lines
1.5 KiB
Python
"""FastAPI application entry point."""
|
|
|
|
from contextlib import asynccontextmanager
|
|
|
|
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
|
|
from database import Base, engine
|
|
from routes import audit as audit_routes
|
|
from routes import auth as auth_routes
|
|
from routes import availability as availability_routes
|
|
from routes import booking as booking_routes
|
|
from routes import invites as invites_routes
|
|
from routes import meta as meta_routes
|
|
from routes import profile as profile_routes
|
|
from validate_constants import validate_shared_constants
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
"""Create database tables on startup and validate constants."""
|
|
# Validate shared constants match backend definitions
|
|
validate_shared_constants()
|
|
|
|
async with engine.begin() as conn:
|
|
await conn.run_sync(Base.metadata.create_all)
|
|
yield
|
|
|
|
|
|
app = FastAPI(lifespan=lifespan)
|
|
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=["http://localhost:3000"],
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
allow_credentials=True,
|
|
)
|
|
|
|
# Include routers - modules with single router
|
|
app.include_router(auth_routes.router)
|
|
app.include_router(audit_routes.router)
|
|
app.include_router(profile_routes.router)
|
|
app.include_router(availability_routes.router)
|
|
app.include_router(meta_routes.router)
|
|
|
|
# Include routers - modules with multiple routers
|
|
for r in invites_routes.routers:
|
|
app.include_router(r)
|
|
for r in booking_routes.routers:
|
|
app.include_router(r)
|