Init project structure

This commit is contained in:
k1nq
2025-11-22 13:56:45 +05:00
parent ad0025be28
commit 74330b292f
25 changed files with 1343 additions and 1 deletions
+22
View File
@@ -0,0 +1,22 @@
"""Authentication API endpoints."""
from __future__ import annotations
from fastapi import APIRouter, Depends, HTTPException, status
from app.api.deps import get_auth_service
from app.models.token import LoginRequest, TokenResponse
from app.services.auth_service import AuthService, InvalidCredentialsError
router = APIRouter(prefix="/auth", tags=["auth"])
@router.post("/token", response_model=TokenResponse)
async def login_for_access_token(
credentials: LoginRequest,
service: AuthService = Depends(get_auth_service),
) -> TokenResponse:
try:
user = await service.authenticate(credentials.email, credentials.password)
except InvalidCredentialsError as exc: # pragma: no cover - thin API
raise HTTPException(status_code=status.HTTP_401_UNAUTHORIZED, detail=str(exc)) from exc
return service.create_access_token(user)