Add Cursor AI rules for improved code generation#4
Conversation
- Add 3 concise rule files: global, frontend, and backend - Rules enforce Ant Design patterns, theme tokens, and project conventions - Include contextual patterns for React components and Express controllers
Address PR review comments: - Change 'Bad' label to 'Verbose' in Controller Pattern example - Add explanation of why asyncHandler is preferred (DRY, consistency, maintainability) - Expand Validation section with 7 comprehensive patterns: * ObjectId validation * Enum/allowed values validation * File type and size validation * Email validation * String sanitization * Conditional validation - Add reference to validators/blogValidator.js for real examples
burnjohn
left a comment
There was a problem hiding this comment.
Thanks for the excellent questions! I've addressed both comments with comprehensive improvements:
Comment 1 (Controller Pattern): You're right - the try-catch isn't "bad", just verbose. I've relabeled it and added a detailed explanation of why asyncHandler is preferred (DRY principle, consistency, maintainability).
Comment 2 (Validation): Added 7 comprehensive validation patterns:
- ObjectId validation with mongoose
- Enum/allowed values checking
- File type and size validation
- Email format validation
- String sanitization and trimming
- Conditional business logic validation
Also added a reference to the actual validators/blogValidator.js file for real-world examples from the codebase.
All changes maintain the project's style guide (no semicolons, single quotes).
Updates Pushed! 🎉I've addressed both of your review comments with comprehensive improvements: Comment 1: "Is it really a bad example?"Resolution: You're absolutely right! The try-catch pattern isn't "bad" - it's valid code that works correctly. Changes made:
Comment 2: "Can you suggest any other validation"Resolution: Expanded the Validation section significantly! Added 7 validation patterns:
Bonus: Added reference to All changes follow project conventions (no semicolons, single quotes). Ready for another review! ✨ |
Adds structured Cursor rules to improve AI-assisted development:
KISS approach with 3 focused files + README. All examples use actual codebase patterns.