2a9ebe24: Implement auth endpoints (register/login/JWT) with SQLAlchemy
This commit is contained in:
17
app/main.py
17
app/main.py
@@ -1,15 +1,29 @@
|
||||
"""FastAPI application entry point."""
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from app.core.config import settings
|
||||
from app.db.database import engine, Base
|
||||
from app.routers.auth import router as auth_router
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
"""Application lifespan manager for startup/shutdown events."""
|
||||
# Startup: Create database tables
|
||||
Base.metadata.create_all(bind=engine)
|
||||
yield
|
||||
# Shutdown: cleanup if needed
|
||||
|
||||
|
||||
# Create FastAPI app
|
||||
app = FastAPI(
|
||||
title=settings.APP_NAME,
|
||||
version=settings.APP_VERSION,
|
||||
debug=settings.DEBUG,
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
# CORS middleware
|
||||
@@ -21,6 +35,9 @@ app.add_middleware(
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
# Include routers
|
||||
app.include_router(auth_router)
|
||||
|
||||
|
||||
@app.get("/")
|
||||
async def root():
|
||||
|
||||
Reference in New Issue
Block a user