58 lines
1.6 KiB
Python
58 lines
1.6 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from contextlib import asynccontextmanager
|
|
|
|
from app.database import connect_db, close_db
|
|
from app.config import get_settings
|
|
from app.routers import auth, resume, requirements, schedule, questions, pronunciation
|
|
|
|
settings = get_settings()
|
|
|
|
|
|
@asynccontextmanager
|
|
async def lifespan(app: FastAPI):
|
|
await connect_db()
|
|
yield
|
|
await close_db()
|
|
|
|
|
|
app = FastAPI(
|
|
title="HireAI API",
|
|
description="AI-powered hiring platform backend",
|
|
version="1.0.0",
|
|
lifespan=lifespan,
|
|
docs_url="/docs",
|
|
redoc_url="/redoc",
|
|
)
|
|
|
|
# ── CORS ────────────────────────────────────────────────────────
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=[settings.frontend_url, "http://localhost:5173"],
|
|
allow_credentials=True,
|
|
allow_methods=["*"],
|
|
allow_headers=["*"],
|
|
)
|
|
|
|
# ── Routers ─────────────────────────────────────────────────────
|
|
app.include_router(auth.router)
|
|
app.include_router(resume.router)
|
|
app.include_router(requirements.router)
|
|
app.include_router(schedule.router)
|
|
app.include_router(questions.router)
|
|
app.include_router(pronunciation.router)
|
|
|
|
|
|
@app.get("/")
|
|
async def root():
|
|
return {
|
|
"app": "HireAI API",
|
|
"version": "1.0.0",
|
|
"status": "running",
|
|
"docs": "/docs",
|
|
}
|
|
|
|
|
|
@app.get("/health")
|
|
async def health():
|
|
return {"status": "ok"}
|