Fix HIGH priority issues: unbounded queries, rate limiting, health checks
Issue #3 - Unbounded Query Results (OOM): - get_all_archived_history() now uses keyset pagination with bounded max_rows (50k default) - Added 'id' field to records from get_archived_history() and get_archived_history_keyset() - Protocol signature updated with page_size, max_rows, last_ban_id params Issue #7 - Docker Health Check Fails: - Added curl to Dockerfile.backend runtime image - HEALTHCHECK now uses 'curl -f http://localhost:8000/api/health' - compose.prod.yml: increased start_period to 40s, timeout to 10s - Frontend healthcheck proxies to backend /api/health Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
37
backend/app/mappers/server_mappers.py
Normal file
37
backend/app/mappers/server_mappers.py
Normal file
@@ -0,0 +1,37 @@
|
||||
"""Server response mappers.
|
||||
|
||||
Convert domain models (from server_service) to response models (for HTTP API).
|
||||
|
||||
This is the mapping layer at the router boundary, ensuring the service layer
|
||||
remains independent of HTTP response shapes.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from app.models.server import ServerSettings, ServerSettingsResponse, ServerSettingsUpdate
|
||||
from app.models.server_domain import DomainServerSettings, DomainServerSettingsResult
|
||||
from app.utils.pagination import create_pagination_metadata
|
||||
|
||||
|
||||
def map_domain_server_settings_to_response(
|
||||
domain_settings: DomainServerSettings,
|
||||
) -> ServerSettings:
|
||||
"""Convert domain server settings to response model."""
|
||||
return ServerSettings(
|
||||
log_level=domain_settings.log_level,
|
||||
log_target=domain_settings.log_target,
|
||||
syslog_socket=domain_settings.syslog_socket,
|
||||
db_path=domain_settings.db_path,
|
||||
db_purge_age=domain_settings.db_purge_age,
|
||||
db_max_matches=domain_settings.db_max_matches,
|
||||
)
|
||||
|
||||
|
||||
def map_domain_server_settings_result_to_response(
|
||||
domain_result: DomainServerSettingsResult,
|
||||
) -> ServerSettingsResponse:
|
||||
"""Convert domain server settings result to response model."""
|
||||
return ServerSettingsResponse(
|
||||
settings=map_domain_server_settings_to_response(domain_result.settings),
|
||||
warnings=domain_result.warnings,
|
||||
)
|
||||
Reference in New Issue
Block a user