nomadro/apps/api/social_main.py
Eric abdcafb1eb Ship Work access gate, pads/boards upgrades, and locale hydration fix on .com.
Gate /social/work behind join/login/profile; harden Work UX and LanguageSwitcher SSR; deploy portal, admin, and work API.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-08 00:14:39 +08:00

52 lines
1.3 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""游民社区独立进程入口 — 仅挂 social_svc,不拖垮 ebook/community/pay。"""
from __future__ import annotations
import sys
from pathlib import Path
ROOT = Path(__file__).resolve().parent
SERVICES = ROOT / "services"
sys.path.insert(0, str(ROOT))
sys.path.insert(0, str(SERVICES))
try:
from dotenv import load_dotenv
load_dotenv(ROOT / ".env")
load_dotenv(ROOT / ".env.local", override=True)
except Exception:
pass
from fastapi import FastAPI # noqa: E402
from social_svc.config import SOCIAL_ENABLED # noqa: E402
from social_svc.routers import router as social_router # noqa: E402
from social_svc.store import init_db # noqa: E402
app = FastAPI(title="nomadro-social", docs_url=None, redoc_url=None)
@app.on_event("startup")
def _startup() -> None:
if SOCIAL_ENABLED:
init_db()
if SOCIAL_ENABLED:
app.include_router(social_router, prefix="/api/social/v1")
@app.get("/health")
def health():
from social_svc.config import CENTRIFUGO_ENABLED
from social_svc.contract import IM_FEATURES, IM_PROTOCOL
return {
"ok": True,
"service": "nomadro-social",
"social": bool(SOCIAL_ENABLED),
"centrifugo": bool(CENTRIFUGO_ENABLED),
"imProtocol": IM_PROTOCOL,
"imFeatures": list(IM_FEATURES),
"uiAgnostic": True,
}