feat: setup FastAPI main app with routers and test fixtures
- Main FastAPI app with all routers included - CORS middleware for frontend - Test fixtures with in-memory SQLite database - Placeholder routers for future tasks
This commit is contained in:
+23
-2
@@ -1,7 +1,8 @@
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from contextlib import asynccontextmanager
|
||||
from app.database import engine, Base
|
||||
from app.routers import sources, jobs
|
||||
from app.routers import sources, jobs, executions, backups, settings, dashboard
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
@@ -9,7 +10,27 @@ async def lifespan(app: FastAPI):
|
||||
await conn.run_sync(Base.metadata.create_all)
|
||||
yield
|
||||
|
||||
app = FastAPI(title="Backup Tool API", lifespan=lifespan)
|
||||
app = FastAPI(
|
||||
title="Backup Tool API",
|
||||
version="0.1.0",
|
||||
lifespan=lifespan
|
||||
)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["http://localhost:3000"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(sources.router)
|
||||
app.include_router(jobs.router)
|
||||
app.include_router(executions.router)
|
||||
app.include_router(backups.router)
|
||||
app.include_router(settings.router)
|
||||
app.include_router(dashboard.router)
|
||||
|
||||
@app.get("/api/health")
|
||||
async def health_check():
|
||||
return {"status": "healthy"}
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(prefix="/api/backups", tags=["backups"])
|
||||
# Will be implemented in later tasks
|
||||
@@ -0,0 +1,4 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(prefix="/api/dashboard", tags=["dashboard"])
|
||||
# Will be implemented in later tasks
|
||||
@@ -0,0 +1,4 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(prefix="/api/executions", tags=["executions"])
|
||||
# Will be implemented in later tasks
|
||||
@@ -0,0 +1,4 @@
|
||||
from fastapi import APIRouter
|
||||
|
||||
router = APIRouter(prefix="/api/settings", tags=["settings"])
|
||||
# Will be implemented in later tasks
|
||||
Reference in New Issue
Block a user