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>
52 lines
1.3 KiB
Python
52 lines
1.3 KiB
Python
"""游民社区独立进程入口 — 仅挂 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,
|
||
}
|