Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[project]
name = "fastapi-boilerplate"
version = "0.1.0"
description = "A fully Async FastAPI boilerplate using SQLAlchemy and Pydantic 2"
authors = [{ name = "Igor Magalhaes", email = "igor.magalhaes.r@gmail.com" }]
description = "Batteries-included FastAPI starter with production-ready defaults, optional modules, and clear docs."
authors = [{ name = "Benav Labs", email = "contact@benav.io" }]
license = { text = "MIT" }
readme = "README.md"
requires-python = ">=3.11, <4"
Expand All @@ -28,7 +28,7 @@ dependencies = [
"arq>=0.25.0",
"bcrypt>=4.1.1",
"psycopg2-binary>=2.9.9",
"fastcrud>=0.19.1",
"fastcrud>=0.19.2",
"crudadmin>=0.4.2",
"gunicorn>=23.0.0",
"ruff>=0.11.13",
Expand Down
8 changes: 2 additions & 6 deletions src/app/api/v1/posts.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,12 @@ async def write_post(
post_internal_dict["created_by_user_id"] = db_user["id"]

post_internal = PostCreateInternal(**post_internal_dict)
created_post = await crud_posts.create(db=db, object=post_internal)
created_post = await crud_posts.create(db=db, object=post_internal, schema_to_select=PostRead)

if created_post is None:
raise NotFoundException("Failed to create post")

post_read = await crud_posts.get(db=db, id=created_post["id"], schema_to_select=PostRead)
if post_read is None:
raise NotFoundException("Created post not found")

return post_read
return created_post


@router.get("/{username}/posts", response_model=PaginatedListResponse[PostRead])
Expand Down
10 changes: 4 additions & 6 deletions src/app/api/v1/rate_limits.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ async def write_rate_limit(
raise DuplicateValueException("Rate Limit Name not available")

rate_limit_internal = RateLimitCreateInternal(**rate_limit_internal_dict)
created_rate_limit = await crud_rate_limits.create(db=db, object=rate_limit_internal)
created_rate_limit = await crud_rate_limits.create(
db=db, object=rate_limit_internal, schema_to_select=RateLimitRead
)

if created_rate_limit is None:
raise NotFoundException("Failed to create rate limit")

rate_limit_read = await crud_rate_limits.get(db=db, id=created_rate_limit["id"], schema_to_select=RateLimitRead)
if rate_limit_read is None:
raise NotFoundException("Created rate limit not found")

return rate_limit_read
return created_rate_limit


@router.get("/tier/{tier_name}/rate_limits", response_model=PaginatedListResponse[RateLimitRead])
Expand Down
8 changes: 2 additions & 6 deletions src/app/api/v1/tiers.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,12 @@ async def write_tier(
raise DuplicateValueException("Tier Name not available")

tier_internal = TierCreateInternal(**tier_internal_dict)
created_tier = await crud_tiers.create(db=db, object=tier_internal)
created_tier = await crud_tiers.create(db=db, object=tier_internal, schema_to_select=TierRead)

if created_tier is None:
raise NotFoundException("Failed to create tier")

tier_read = await crud_tiers.get(db=db, id=created_tier["id"], schema_to_select=TierRead)
if tier_read is None:
raise NotFoundException("Created tier not found")

return tier_read
return created_tier


@router.get("/tiers", response_model=PaginatedListResponse[TierRead])
Expand Down
8 changes: 2 additions & 6 deletions src/app/api/v1/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ async def write_user(
del user_internal_dict["password"]

user_internal = UserCreateInternal(**user_internal_dict)
created_user = await crud_users.create(db=db, object=user_internal)
created_user = await crud_users.create(db=db, object=user_internal, schema_to_select=UserRead)

if created_user is None:
raise NotFoundException("Failed to create user")

user_read = await crud_users.get(db=db, id=created_user["id"], schema_to_select=UserRead)
if user_read is None:
raise NotFoundException("Created user not found")

return user_read
return created_user


@router.get("/users", response_model=PaginatedListResponse[UserRead])
Expand Down
3 changes: 1 addition & 2 deletions tests/test_user.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ async def test_create_user_success(self, mock_db, sample_user_data, sample_user_
with patch("src.app.api.v1.users.crud_users") as mock_crud:
# Mock that email and username don't exist
mock_crud.exists = AsyncMock(side_effect=[False, False]) # email, then username
mock_crud.create = AsyncMock(return_value={"id": 1})
mock_crud.get = AsyncMock(return_value=sample_user_read.model_dump())
mock_crud.create = AsyncMock(return_value=sample_user_read.model_dump())

with patch("src.app.api.v1.users.get_password_hash") as mock_hash:
mock_hash.return_value = "hashed_password"
Expand Down
8 changes: 4 additions & 4 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading