implement initial backend structure with authentication, user management, and database integration
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
from backend.app.routers import auth as auth_router
|
||||
from backend.app.routers import users as users_router
|
||||
from backend.app.routers import admin as admin_router
|
||||
from backend.app.db import close_db, init_db
|
||||
import os
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
init_db()
|
||||
yield
|
||||
close_db()
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="AI Allucanget Biz API",
|
||||
description="Multi-modal AI generation API powered by openrouter.ai",
|
||||
version="0.1.0",
|
||||
lifespan=lifespan,
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=[os.getenv("CORS_ORIGINS", "http://localhost:5000")],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(auth_router.router)
|
||||
app.include_router(users_router.router)
|
||||
app.include_router(admin_router.router)
|
||||
|
||||
|
||||
@app.get("/health", tags=["health"])
|
||||
async def health() -> dict:
|
||||
return {"status": "ok"}
|
||||
Reference in New Issue
Block a user