Add restore-mode task launch flow

This commit is contained in:
2026-03-24 15:27:35 +08:00
parent 6413edf8c9
commit 8d6c3c5647
12 changed files with 572 additions and 52 deletions

View File

@@ -6,15 +6,15 @@ from __future__ import annotations
from typing import Any
from fastapi import Depends, FastAPI, Query
from fastapi.middleware.cors import CORSMiddleware
from backend.apps.cors import add_cors_middleware
from backend.data.market_store import MarketStore
from backend.domains import news as news_domain
def get_market_store() -> MarketStore:
"""Create a market store dependency."""
return MarketStore()
"""Get the MarketStore singleton dependency."""
return MarketStore.get_instance()
def create_app() -> FastAPI:
@@ -25,13 +25,7 @@ def create_app() -> FastAPI:
version="0.1.0",
)
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
add_cors_middleware(app)
@app.get("/health")
async def health_check() -> dict[str, str]:
@@ -51,6 +45,7 @@ def create_app() -> FastAPI:
start_date=start_date,
end_date=end_date,
limit=limit,
refresh_if_stale=False,
)
@app.get("/api/news-for-date")
@@ -65,6 +60,7 @@ def create_app() -> FastAPI:
ticker=ticker,
date=date,
limit=limit,
refresh_if_stale=False,
)
@app.get("/api/news-timeline")
@@ -79,6 +75,7 @@ def create_app() -> FastAPI:
ticker=ticker,
start_date=start_date,
end_date=end_date,
refresh_if_stale=False,
)
@app.get("/api/categories")
@@ -95,6 +92,7 @@ def create_app() -> FastAPI:
start_date=start_date,
end_date=end_date,
limit=limit,
refresh_if_stale=False,
)
@app.get("/api/similar-days")
@@ -109,6 +107,7 @@ def create_app() -> FastAPI:
ticker=ticker,
date=date,
n_similar=n_similar,
refresh_if_stale=False,
)
@app.get("/api/stories/{ticker}")
@@ -121,6 +120,7 @@ def create_app() -> FastAPI:
store,
ticker=ticker,
as_of_date=as_of_date,
refresh_if_stale=False,
)
@app.get("/api/range-explain")
@@ -139,6 +139,7 @@ def create_app() -> FastAPI:
end_date=end_date,
article_ids=article_ids,
limit=limit,
refresh_if_stale=False,
)
return app