File tree Expand file tree Collapse file tree 2 files changed +58
-0
lines changed
src/quant_research_starter/api Expand file tree Collapse file tree 2 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ """API package for QuantResearchStarter backend."""
2+
3+ __all__ = [
4+ "main" ,
5+ "db" ,
6+ "models" ,
7+ "schemas" ,
8+ "auth" ,
9+ "routers" ,
10+ "tasks" ,
11+ ]
Original file line number Diff line number Diff line change 1+ """FastAPI application entrypoint for backend API."""
2+ from fastapi import FastAPI , APIRouter
3+ from fastapi .middleware .cors import CORSMiddleware
4+ import os
5+ import asyncio
6+
7+ from .routers import auth as auth_router , backtest as backtest_router
8+ from .utils .ws_manager import redis_listener_loop
9+
10+ app = FastAPI (title = "QuantResearch API" )
11+
12+ app .add_middleware (
13+ CORSMiddleware ,
14+ allow_origins = [os .getenv ("CORS_ORIGINS" , "*" )],
15+ allow_credentials = True ,
16+ allow_methods = ["*" ],
17+ allow_headers = ["*" ],
18+ )
19+
20+
21+ @app .on_event ("startup" )
22+ async def startup_event ():
23+ # Start background redis subscription for websocket broadcasting
24+ loop = asyncio .get_event_loop ()
25+ loop .create_task (redis_listener_loop ())
26+
27+
28+ @app .on_event ("shutdown" )
29+ async def shutdown_event ():
30+ # Nothing special for now
31+ pass
32+
33+
34+ app .include_router (auth_router .router )
35+ app .include_router (backtest_router .router )
36+ app .include_router (assets_router .router )
37+
38+ # Health / readiness
39+ router = APIRouter (prefix = "/api" )
40+
41+
42+ @router .get ("/health" )
43+ async def health ():
44+ return {"status" : "ok" }
45+
46+
47+ app .include_router (router )
You can’t perform that action at this time.
0 commit comments