27 lines
790 B
Python
27 lines
790 B
Python
from fastapi import FastAPI
|
|
from contextlib import asynccontextmanager
|
|
from typing import AsyncGenerator
|
|
|
|
from app.core.config import settings
|
|
from app.db.session import engine
|
|
from app.db.base import SQLModel
|
|
from app.api.routers import auth, users
|
|
|
|
|
|
def create_app() -> FastAPI:
|
|
app = FastAPI(title="FastAPI Account System")
|
|
app.include_router(auth.router, prefix="/auth", tags=["auth"])
|
|
app.include_router(users.router, prefix="/users", tags=["users"])
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app) -> AsyncGenerator[None, None]:
|
|
# For quick local runs create tables automatically. In production use Alembic migrations.
|
|
SQLModel.metadata.create_all(engine)
|
|
yield
|
|
|
|
app.router.lifespan_context = lifespan
|
|
return app
|
|
|
|
|
|
app = create_app()
|