-
Notifications
You must be signed in to change notification settings - Fork 0
Main #1
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
Open
NonsoBarn
wants to merge
18
commits into
setup
Choose a base branch
from
main
base: setup
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…shing + Error Logging fix
Features implemented: - Category entity with self-referential relationships - Hierarchical categories (2-level depth maximum) - Auto-generated slugs for SEO-friendly URLs (fast-food, burgers, etc.) - Full CRUD operations with proper authorization - Soft delete functionality (preserves data, sets isActive=false) - Data validation with class-validator DTOs - Business rules enforcement: * Maximum 2-level nesting (root > parent > child) * Duplicate name prevention (409 Conflict) * Circular reference prevention * Parent existence validation * Slug uniqueness with automatic numbering Endpoints implemented: - POST /api/v1/categories (admin only) - GET /api/v1/categories (public) - GET /api/v1/categories/root (public) - GET /api/v1/categories/slug/:slug (public) - GET /api/v1/categories/:id (public) - PATCH /api/v1/categories/:id (admin only) - DELETE /api/v1/categories/:id (admin only - soft delete) - DELETE /api/v1/categories/:id/hard (admin only - permanent) Technical implementation: - Self-referential TypeORM relationships (@manytoone, @onetomany) - Slug generation with slugify library and uniqueness checking - TypeORM IsNull() operator for NULL value queries - Constructor-based dependency injection - Guard chain (JwtAuthGuard + RolesGuard) for RBAC - Proper HTTP status codes (201, 204, 400, 401, 403, 404, 409) - Query parameter support for admin views (includeInactive) Testing completed: ✅ CRUD operations verified ✅ Hierarchical data structure tested ✅ Validation error handling confirmed (duplicate, invalid UUID) ✅ Authorization (RBAC) working correctly ✅ Soft delete functionality verified (204 response, isActive=false) ✅ Slug auto-generation tested (fast-food, burgers, pizza) ✅ Parent-child relationships loading correctly Database structure: - 6 categories created (3 root, 3 children) - Fast Food > Burgers, Pizza, Fried Chicken - Beverages (root) - Desserts (root, soft deleted)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.