35 lines
805 B
Python
35 lines
805 B
Python
|
|
from contextlib import asynccontextmanager
|
||
|
|
|
||
|
|
from fastapi import FastAPI
|
||
|
|
from fastapi.middleware.cors import CORSMiddleware
|
||
|
|
|
||
|
|
from app.api import health, session, match, ws, stats
|
||
|
|
from app.core.config import settings
|
||
|
|
from app.core.database import create_tables
|
||
|
|
|
||
|
|
|
||
|
|
@asynccontextmanager
|
||
|
|
async def lifespan(app: FastAPI):
|
||
|
|
await create_tables()
|
||
|
|
yield
|
||
|
|
|
||
|
|
|
||
|
|
app = FastAPI(
|
||
|
|
title="Social Proximity API",
|
||
|
|
version="0.1.0",
|
||
|
|
lifespan=lifespan,
|
||
|
|
)
|
||
|
|
|
||
|
|
app.add_middleware(
|
||
|
|
CORSMiddleware,
|
||
|
|
allow_origins=settings.allowed_origins,
|
||
|
|
allow_methods=["*"],
|
||
|
|
allow_headers=["*"],
|
||
|
|
)
|
||
|
|
|
||
|
|
app.include_router(health.router)
|
||
|
|
app.include_router(session.router, prefix="/session")
|
||
|
|
app.include_router(match.router, prefix="/match")
|
||
|
|
app.include_router(ws.router)
|
||
|
|
app.include_router(stats.router, prefix="/stats")
|