Return 204 on empty success responses (not 200)

This commit is contained in:
Peter Vacho 2024-12-27 17:49:16 +01:00
parent 5ff4da15d8
commit d106423fca
Signed by: school
GPG key ID: 8CFC3837052871B4
3 changed files with 4 additions and 4 deletions

View file

@ -123,4 +123,4 @@ async def logout(cur_token: RefreshTokenDep) -> Response:
cur_db_token.revoked = True
_ = await cur_db_token.replace()
return Response(status_code=status.HTTP_200_OK)
return Response(status_code=status.HTTP_204_NO_CONTENT)

View file

@ -157,7 +157,7 @@ async def delete_category(category_id: PydanticObjectId, user: CurrentUserDep) -
# We can now safely delete the category
_ = await category.delete()
return Response(status_code=status.HTTP_200_OK)
return Response(status_code=status.HTTP_204_NO_CONTENT)
@categories_router.post("")

View file

@ -4,7 +4,7 @@ from typing import Annotated, final
from beanie import PydanticObjectId
from fastapi import APIRouter, Body, HTTPException, Response, status
from pydantic import BaseModel, EmailStr, StringConstraints
from starlette.status import HTTP_200_OK
from starlette.status import HTTP_204_NO_CONTENT
from src.api.auth.dependencies import LoggedInDep
from src.api.auth.passwords import check_hashed_password, create_password_hash
@ -134,7 +134,7 @@ async def delete_user(user_id: PydanticObjectId, user: CurrentUserDep) -> Respon
_ = await user.delete()
return Response(status_code=HTTP_200_OK)
return Response(status_code=HTTP_204_NO_CONTENT)
@protected_router.patch("/{user_id}")