Refactor code structure for improved readability and maintainability

This commit is contained in:
k1nq
2026-09-16 13:41:55 +05:00
commit 7d0762ef17
27 changed files with 2718 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
import secrets
from typing import Annotated
from fastapi import Depends, HTTPException, status
from fastapi.security import APIKeyHeader
from app.config import Settings, get_settings
api_key_header = APIKeyHeader(name="X-API-Key", auto_error=False)
async def require_api_key(
supplied_key: Annotated[str | None, Depends(api_key_header)],
current_settings: Annotated[Settings, Depends(get_settings)],
) -> None:
if supplied_key is None or not secrets.compare_digest(supplied_key, current_settings.api_key):
raise HTTPException(
status_code=status.HTTP_401_UNAUTHORIZED,
detail="Invalid or missing API key",
)