Feat/proper cursor rules #175
Conversation
…istration -m This commit implements the logic to automatically assign the Buyer role to users who select it in the registration form. Additionally, it is now mandatory for users with this role to select a country. -m Main Changes: Added the country field to the User model. Implemented the necessary validation in the registration endpoint to ensure the country field is not empty if the role is Buyer. The Buyer role is automatically assigned to the user during the registration process. Added unit and integration tests to verify the correct operation of these changes. This change is crucial to ensure all buyers have associated geographic data, which is critical for future platform operations.
- Removed user ID from the AuthController and related DTOs to streamline response data. - Updated example values in DTOs for consistency and clarity.
Create Seller Role on Registration (with Store Profile)
…_primary_id_and_convert_id_to_uuid feat: use walletAddress as the primary public ID
…ration-flow Feature/buyer registration flow
feat: added cache interceptors
|
Caution Review failedThe pull request is closed. WalkthroughAdds Redis-backed caching (module, service, interceptor, controller), introduces a full Stores module (entity, DTOs, service, controller, migration), migrates users to UUID and walletAddress-first APIs, extends user model (country/location/buyerData/sellerData), updates auth/user flows and DTOs, adjusts related modules (buyer-requests, reviews), and enhances tooling/docs. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant C as Client
participant API as Controller/Route
participant CI as CacheInterceptor
participant SVC as Service
participant CS as CacheService
participant DB as Database
Note over API,CI: Request to a @Cacheable route
C->>API: HTTP GET /products?...
API->>CI: handle(request)
CI->>CS: generateKey(entity, action, params)
CI->>CS: get(key)
alt Cache HIT
CS-->>CI: data
CI-->>API: cached data
API-->>C: 200 OK (cached)
else Cache MISS
CI->>SVC: proceed()
SVC->>DB: query
DB-->>SVC: rows
SVC-->>CI: result
CI->>CS: set(key, result, ttl)
CI-->>API: result
API-->>C: 200 OK
end
sequenceDiagram
autonumber
participant C as Client
participant AuthC as Auth Controller
participant AuthS as Auth Service
participant Users as User Service/Repo
participant Stores as Store Service
participant JWT as JWT Service
Note over C,AuthC: Register with walletAddress (public ID)
C->>AuthC: POST /auth/register { walletAddress, role, country?, ... }
AuthC->>AuthS: registerWithWallet(dto)
AuthS->>Users: createUser(..., walletAddress, role, country, ...)
Users-->>AuthS: user (UUID id, walletAddress)
alt role == seller
AuthS->>Stores: createDefaultStore(user.id, sellerData)
Stores-->>AuthS: store or noop
end
AuthS->>JWT: sign({ walletAddress, role, id })
JWT-->>AuthS: token
AuthS-->>AuthC: { user (no id), token }
AuthC-->>C: 201 Created
Estimated code review effort🎯 5 (Critical) | ⏱️ ~120+ minutes Possibly related PRs
Suggested reviewers
Poem
✨ Finishing touches
🧪 Generate unit tests
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (68)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
🚀 StarShop Pull Request
Mark with an
xall the checkboxes that apply (like[x])�� Type of Change
📝 Changes description
Enhanced Contribution Rules and Code Quality Standards
This PR introduces comprehensive contribution rules and quality gates to ensure consistent, production-ready code across the StarShop Backend project, especially when using AI coding assistants like Cursor.
Key Improvements:
Centralized Environment Configuration
src/config/env.tswith Zod validationprocess.env.*access throughout codebaseEnhanced NPM Scripts
test:cifor continuous integration testingformat:checkfor code formatting verificationpre-commitscript for comprehensive quality checkszoddependency for environment validationImproved Testing Configuration
Pre-commit Hooks
process.envusage violationsconsole.logstatements in production codeCursor AI-Specific Rules
.cursorrulesfile with detailed guidelinesDocumentation
Files Modified:
package.json- Added new scripts and dependencies.husky/pre-commit- Added comprehensive pre-commit checks.cursorrules- Added AI-specific development rulesFiles Created:
src/config/env.ts- Centralized environment configurationjest.config.enhanced.js- Enhanced Jest configurationjest.global-setup.js- Global test setupjest.global-teardown.js- Global test teardownsetup-enhanced-rules.sh- Automated setup scriptCONTRIBUTION_RULES_ENHANCED.md- Detailed contribution guidelinesRULES_SUMMARY.md- Summary of all implemented rules�� Evidence (A photo is required as evidence)
Before (Issues Found):
process.env.*access in multiple filesAfter (Improvements Implemented):
⏰ Time spent breakdown
Analysis & Planning: 15 minutes
Implementation: 25 minutes
Documentation: 10 minutes
Testing & Validation: 5 minutes
Total Time: ~55 minutes
🌌 Comments
This enhancement significantly improves the development experience and code quality for the StarShop Backend project. The new rules ensure that:
The implementation follows industry best practices and is designed to scale with the project. All changes are backward-compatible and include comprehensive documentation for easy adoption.
Next Steps:
npm installto install new dependencies.envfile with actual valuesThank you for contributing to StarShop, we are glad that you have chosen us as your project of choice and we hope that you continue to contribute to this great project, so that together we can make our mark at the top!
Summary by CodeRabbit