mirror of
https://github.com/TronoSfera/Law.git
synced 2026-05-19 02:23:45 +03:00
36 lines
1.2 KiB
Python
36 lines
1.2 KiB
Python
from fastapi import FastAPI
|
|
from fastapi.middleware.cors import CORSMiddleware
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from app.api.admin.chat import router as admin_chat_router
|
|
from app.api.public.chat import router as public_chat_router
|
|
from app.core.config import settings, validate_production_security_or_raise
|
|
from app.core.http_hardening import install_http_hardening
|
|
|
|
app = FastAPI(title=f"{settings.APP_NAME}-chat", version="0.1.0")
|
|
app.add_middleware(
|
|
CORSMiddleware,
|
|
allow_origins=settings.cors_origins_list,
|
|
allow_credentials=settings.CORS_ALLOW_CREDENTIALS,
|
|
allow_methods=settings.cors_allow_methods_list,
|
|
allow_headers=settings.cors_allow_headers_list,
|
|
)
|
|
install_http_hardening(app)
|
|
|
|
app.include_router(public_chat_router, prefix="/api/public/chat")
|
|
app.include_router(admin_chat_router, prefix="/api/admin/chat")
|
|
|
|
|
|
@app.on_event("startup")
|
|
def _validate_security_config_on_startup() -> None:
|
|
validate_production_security_or_raise("chat-service")
|
|
|
|
|
|
@app.get("/", include_in_schema=False)
|
|
def landing():
|
|
return JSONResponse({"service": f"{settings.APP_NAME}-chat", "status": "ok"})
|
|
|
|
|
|
@app.get("/health")
|
|
def health():
|
|
return {"status": "ok"}
|