redirect - document 201, 409, 422 and 500 semantic response models on RSVP route - document Authelia Remote-User security requirement and 401 response on admin routes - add interactive examples and spanish descriptions across all Pydantic schemas - add /docs redirect to /birthday/api/docs for developer ergonomics - hide SPA static catch-all routes from OpenAPI schema - resolve static assets directly from disk before SPA catch-all fallback
46 lines
1.3 KiB
Python
46 lines
1.3 KiB
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends, status
|
|
from fastapi.responses import JSONResponse
|
|
from sqlalchemy.orm import Session
|
|
|
|
from ..database import get_db
|
|
from ..schemas import InvitationConfigResponse, RSVPErrorResponse
|
|
from ..services.config import get_config, seed_default_config
|
|
|
|
router = APIRouter(tags=["Config"])
|
|
|
|
DbDep = Annotated[Session, Depends(get_db)]
|
|
|
|
|
|
@router.get(
|
|
"/config",
|
|
response_model=InvitationConfigResponse,
|
|
summary="Obtener configuración de la invitación",
|
|
description=(
|
|
"Retorna la configuración singleton actual del evento para ser renderizada en la "
|
|
"experiencia web pública del invitado (textos, homenajeado, coordenadas de tiempo y lugar)."
|
|
),
|
|
responses={
|
|
200: {
|
|
"model": InvitationConfigResponse,
|
|
"description": "Configuración del evento obtenida correctamente.",
|
|
},
|
|
500: {
|
|
"model": RSVPErrorResponse,
|
|
"description": "Fallo al inicializar o consultar el registro singleton.",
|
|
},
|
|
},
|
|
)
|
|
def read_config(db: DbDep):
|
|
config = get_config(db)
|
|
if not config:
|
|
config = seed_default_config(db)
|
|
|
|
if not config:
|
|
return JSONResponse(
|
|
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
|
|
content={"result": "ERROR"},
|
|
)
|
|
return config
|