Codificador-23/codesage-backend
0
1import os2from fastapi import FastAPI3from fastapi.middleware.cors import CORSMiddleware4from app.api.routes import ingest, chat, repos5from app.db.postgres import PostgresDB6from dotenv import load_dotenv7 8load_dotenv()9 10app = FastAPI(title="CodeSage API")11 12app.add_middleware(13 CORSMiddleware,14 allow_origins=[os.getenv("FRONTEND_URL", "http://localhost:5173")],15 allow_credentials=True,16 allow_methods=["*"],17 allow_headers=["*"],18)19 20db = PostgresDB()21 22@app.on_event("startup")23async def startup_event():24 await db.init_db()25 26@app.get("/health")27@app.get("/api/health")28async def health():29 return {"status": "healthy"}30 31 32app.include_router(ingest.router, prefix="/api/ingest", tags=["ingest"])33app.include_router(chat.router, prefix="/api/chat", tags=["chat"])34app.include_router(repos.router, prefix="/api", tags=["repos"])35 36 37if __name__ == "__main__":38 import uvicorn39 uvicorn.run(app, host="0.0.0.0", port=8000)40 