Sanuka0523 commited on
Commit
338ec2d
·
1 Parent(s): 9d23399

Fix MongoDB SSL + add root endpoint redirect

Browse files
Files changed (3) hide show
  1. app/database.py +6 -1
  2. app/main.py +6 -0
  3. requirements.txt +1 -0
app/database.py CHANGED
@@ -1,3 +1,4 @@
 
1
  from motor.motor_asyncio import AsyncIOMotorClient
2
 
3
  client: AsyncIOMotorClient = None
@@ -6,7 +7,11 @@ db = None
6
 
7
  async def connect_db(uri: str, db_name: str):
8
  global client, db
9
- client = AsyncIOMotorClient(uri, serverSelectionTimeoutMS=5000)
 
 
 
 
10
  db = client[db_name]
11
 
12
  # Create indexes (non-blocking — if DB is unreachable, server still starts)
 
1
+ import certifi
2
  from motor.motor_asyncio import AsyncIOMotorClient
3
 
4
  client: AsyncIOMotorClient = None
 
7
 
8
  async def connect_db(uri: str, db_name: str):
9
  global client, db
10
+ client = AsyncIOMotorClient(
11
+ uri,
12
+ serverSelectionTimeoutMS=5000,
13
+ tlsCAFile=certifi.where(),
14
+ )
15
  db = client[db_name]
16
 
17
  # Create indexes (non-blocking — if DB is unreachable, server still starts)
app/main.py CHANGED
@@ -2,6 +2,7 @@ from contextlib import asynccontextmanager
2
 
3
  from fastapi import FastAPI
4
  from fastapi.middleware.cors import CORSMiddleware
 
5
 
6
  from app.config import settings
7
  from app.database import connect_db, close_db
@@ -39,6 +40,11 @@ app.add_middleware(
39
  allow_headers=["*"],
40
  )
41
 
 
 
 
 
 
42
  app.include_router(health.router, prefix="/api/v1", tags=["health"])
43
  app.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
44
  app.include_router(vitals.router, prefix="/api/v1/vitals", tags=["vitals"])
 
2
 
3
  from fastapi import FastAPI
4
  from fastapi.middleware.cors import CORSMiddleware
5
+ from fastapi.responses import RedirectResponse
6
 
7
  from app.config import settings
8
  from app.database import connect_db, close_db
 
40
  allow_headers=["*"],
41
  )
42
 
43
+ @app.get("/", include_in_schema=False)
44
+ async def root():
45
+ return RedirectResponse(url="/docs")
46
+
47
+
48
  app.include_router(health.router, prefix="/api/v1", tags=["health"])
49
  app.include_router(auth.router, prefix="/api/v1/auth", tags=["auth"])
50
  app.include_router(vitals.router, prefix="/api/v1/vitals", tags=["vitals"])
requirements.txt CHANGED
@@ -13,3 +13,4 @@ httpx==0.28.1
13
  xgboost>=2.0.0
14
  neurokit2>=0.2.7
15
  joblib>=1.3.0
 
 
13
  xgboost>=2.0.0
14
  neurokit2>=0.2.7
15
  joblib>=1.3.0
16
+ certifi>=2024.0.0