-
Notifications
You must be signed in to change notification settings - Fork 0
API for categories: saving and deleting #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implemented unit tests for this feature
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR implements comprehensive category management API functionality with endpoints for creating, fetching, and deleting categories. The implementation includes proper color code validation and normalization, comprehensive error handling, and user isolation.
Key changes:
- Added category fetching and deletion endpoints with user isolation
- Implemented color code normalization to ensure consistent # prefix formatting
- Enhanced validation to accept both RRGGBB and #RRGGBB color code formats
Reviewed Changes
Copilot reviewed 8 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| Sources/GrowBitAppServer/Controllers/HabitsController.swift | Added getAllCategoriesForUser and deleteCategory endpoints with color normalization |
| Sources/GrowBitAppServer/Models/Category.swift | Fixed validation error message typo and updated color pattern regex |
| Sources/GrowBitAppServer/Extensions/CategoryResponseDTO+Extensions.swift | Corrected filename in header comment |
| Tests/GrowBitAppServerTests/GrowBitAppServerSavingCategoryTests.swift | Enhanced test with color normalization validation and better invalid color test |
| Tests/GrowBitAppServerTests/GrowBitAppServerFetchingCategoriesTests.swift | Added comprehensive test suite for category fetching functionality |
| Tests/GrowBitAppServerTests/GrowBitAppServerDeleteCategoryTests.swift | Added comprehensive test suite for category deletion functionality |
| Tests/GrowBitAppServerTests/GrowBitAppServerLoginTests.swift | Removed unused import |
| README.md | Updated documentation to reflect implemented category CRUD operations |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Tests/GrowBitAppServerTests/GrowBitAppServerDeleteCategoryTests.swift
Outdated
Show resolved
Hide resolved
Tests/GrowBitAppServerTests/GrowBitAppServerDeleteCategoryTests.swift
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Copilot reviewed 8 out of 10 changed files in this pull request and generated 1 comment.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| guard let userId = req.parameters.get("userId", as: UUID.self), | ||
| let categoryId = req.parameters.get("categoryId", as: UUID.self) | ||
| else { | ||
| throw Abort(.badRequest, reason: "Missing or invalid userId parameter") // HTTP 400 |
Copilot
AI
Oct 10, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error message mentions only 'userId parameter' but the function validates both userId and categoryId parameters. Consider updating to 'Missing or invalid userId or categoryId parameter' for clarity.
| throw Abort(.badRequest, reason: "Missing or invalid userId parameter") // HTTP 400 | |
| throw Abort(.badRequest, reason: "Missing or invalid userId or categoryId parameter") // HTTP 400 |
API for categories: saving and deleting