mirror of
https://github.com/joaovitoriasilva/endurain.git
synced 2026-01-09 15:57:59 -05:00
Refactored the server settings module for better structure and clarity, including splitting base and public schemas, updating SQLAlchemy model to use Mapped/mapped_column, and improving type hints and docstrings. Enhanced API endpoints with detailed documentation, added file validation for login photo upload, and improved error handling. The __init__.py now provides explicit exports for all key components.
35 lines
990 B
Python
35 lines
990 B
Python
from typing import Annotated
|
|
|
|
from fastapi import APIRouter, Depends
|
|
from sqlalchemy.orm import Session
|
|
|
|
import server_settings.schema as server_settings_schema
|
|
import server_settings.utils as server_settings_utils
|
|
|
|
import core.database as core_database
|
|
|
|
# Define the API router
|
|
router = APIRouter()
|
|
|
|
|
|
@router.get("", response_model=server_settings_schema.ServerSettingsReadPublic)
|
|
async def read_public_server_settings(
|
|
db: Annotated[
|
|
Session,
|
|
Depends(core_database.get_db),
|
|
],
|
|
):
|
|
"""
|
|
Get public server settings (unauthenticated).
|
|
|
|
Returns only the public subset of server configuration
|
|
(sensitive signup approval/verification settings excluded).
|
|
Pydantic model filtering automatically excludes sensitive fields.
|
|
|
|
Returns:
|
|
Public subset of server configuration.
|
|
"""
|
|
server_settings = server_settings_utils.get_server_settings(db)
|
|
# Pydantic model_validate handles field filtering automatically
|
|
return server_settings
|