From 0a8a3d271db1ad7b054247b7e2bd6c29bfb9b22c Mon Sep 17 00:00:00 2001 From: Luckaskl Date: Thu, 28 May 2026 13:20:47 -0500 Subject: [PATCH] =?UTF-8?q?corre=C3=A7=C3=B5es=20na=20valida=C3=A7=C3=A3o?= =?UTF-8?q?=20de=20jwt=20e=20na=20requisi=C3=A7=C3=A3o=20POST?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/v1/endpoints/games.py | 8 ++++---- app/main.py | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/app/api/v1/endpoints/games.py b/app/api/v1/endpoints/games.py index 4573eae..5c4fdb6 100644 --- a/app/api/v1/endpoints/games.py +++ b/app/api/v1/endpoints/games.py @@ -23,8 +23,8 @@ def generate_slug(title: str) -> str: text = re.sub(r'-+', '-', text).strip('-') return text -@router.get("/", response_model=StandardResponse) -def read_games(skip: int = 0, limit: int = 100, genre: Optional[str] = None, platform: Optional[str] = None, db: Session = Depends(get_db)): +@router.get("", response_model=StandardResponse) +def read_games(skip: int = 0, limit: int = 100, genre: Optional[str] = None, platform: Optional[str] = None, db: Session = Depends(get_db), current_user: UserAuth = Depends(get_current_user)): query = db.query(Game) if genre: @@ -38,7 +38,7 @@ def read_games(skip: int = 0, limit: int = 100, genre: Optional[str] = None, pla return {"success": True, "message": "Lista de jogos", "data": data} -@router.post("/", response_model=StandardResponse, status_code=status.HTTP_201_CREATED) +@router.post("", response_model=StandardResponse, status_code=status.HTTP_201_CREATED) def create_game(game: GameCreate, db: Session = Depends(get_db), current_user: UserAuth = Depends(get_current_user)): slug = generate_slug(game.title) @@ -59,7 +59,7 @@ def create_game(game: GameCreate, db: Session = Depends(get_db), current_user: U return {"success": True, "message": "Jogo criado com sucesso", "data": data} @router.get("/{id_ou_slug}", response_model=StandardResponse) -def read_game(id_ou_slug: str, db: Session = Depends(get_db)): +def read_game(id_ou_slug: str, db: Session = Depends(get_db), current_user: UserAuth = Depends(get_current_user)): if id_ou_slug.isdigit(): db_game = db.query(Game).filter(Game.id == int(id_ou_slug)).first() else: diff --git a/app/main.py b/app/main.py index 8dc643e..5f878cd 100644 --- a/app/main.py +++ b/app/main.py @@ -1,4 +1,5 @@ -from fastapi import FastAPI +from fastapi import FastAPI, Depends +from app.core.security import get_current_user, UserAuth from app.core.config import settings from app.api.v1.api import api_router from app.db.database import Base, engine @@ -14,5 +15,5 @@ app = FastAPI( app.include_router(api_router, prefix=settings.API_V1_STR) @app.get("/") -def root(): +def root(current_user: UserAuth = Depends(get_current_user)): return {"message": "Bem-vindo ao Microsserviço de Catálogo do GameVerse"}