Refactor: Clean main.py

This commit is contained in:
Артём Кокос
2026-02-21 13:34:47 +07:00
parent b30ce9ce2a
commit 765bfd3201
7 changed files with 328 additions and 403 deletions

21
app/api/deps.py Normal file
View File

@@ -0,0 +1,21 @@
import os
from fastapi import Depends, HTTPException, Security
from fastapi.security import APIKeyHeader
from starlette.status import HTTP_403_FORBIDDEN
from dotenv import load_dotenv
load_dotenv()
API_KEY = os.getenv("IGNIS_API_KEY")
API_KEY_NAME = "X-API-Key"
api_key_header = APIKeyHeader(name=API_KEY_NAME, auto_error=False)
async def verify_token(header_value: str = Depends(api_key_header)):
if not API_KEY:
return None
if header_value == API_KEY:
return header_value
raise HTTPException(
status_code=HTTP_403_FORBIDDEN, detail="Could not validate credentials"
)