Skip to content

Commit 137a395

Browse files
committed
Migrate API routes to versioned router structure
1 parent 07fb77b commit 137a395

File tree

4 files changed

+37
-17
lines changed

4 files changed

+37
-17
lines changed
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,10 @@
11
"""API routes package."""
22

3+
from fastapi import APIRouter
4+
5+
from app.api.routes import admin, documents
6+
7+
router = APIRouter(prefix="/api/v1")
8+
9+
router.include_router(documents.router)
10+
router.include_router(admin.router)

RAGManager/app/api/routes/admin.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from fastapi import APIRouter
2+
3+
router = APIRouter(prefix="/admin", tags=["admin"])
4+
5+
@router.get("/health")
6+
def admin_health():
7+
return {"status": "ok"}
8+
9+
@router.get("/ping")
10+
def admin_ping():
11+
return {"pong": True}

RAGManager/app/api/routes/base.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from fastapi import APIRouter
2+
3+
router = APIRouter(tags=["base"])
4+
5+
@router.get("/")
6+
async def root():
7+
return {"message": "RAGManager up"}
8+
9+
@router.get("/health")
10+
def health_check():
11+
return {"message": "200 running..."}

RAGManager/main.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import logging
22
from fastapi import FastAPI
3-
from sqlalchemy.exc import OperationalError
43

5-
from app.api.routes import documents
4+
from app.api.routes import router as api_router
5+
from app.api.routes.base import router as base_router
66
from app.core.database_connection import init_db
77

88
# Configure logging
@@ -13,9 +13,11 @@
1313

1414
app = FastAPI(title="RAG Manager API", version="0.1.0")
1515

16-
# Include routers
17-
app.include_router(documents.router)
16+
# Global (non-versioned) routes
17+
app.include_router(base_router)
1818

19+
# Versioned API routes
20+
app.include_router(api_router)
1921

2022
@app.on_event("startup")
2123
async def startup_event():
@@ -25,16 +27,4 @@ async def startup_event():
2527
logging.info("Database initialized successfully")
2628
except Exception as e:
2729
logging.error(f"Failed to initialize database: {e}")
28-
raise
29-
30-
31-
@app.get("/")
32-
async def root():
33-
return {"message": "Hello World"}
34-
35-
36-
@app.get("/health")
37-
def health_check():
38-
return {"message": "200 corriendo..."}
39-
40-
30+
raise

0 commit comments

Comments
 (0)