-
Notifications
You must be signed in to change notification settings - Fork 44
Open
Labels
Description
Implement Comment System API Routes
Description
Create API routes for Comment model to enable payout commenting.
Implement full CRUD operations with authentication, payout relationships, and proper error handling.
Requirements
API Routes Structure
-
src/app/api/(comment)/comment/create/route.ts→ POST for comment creation -
src/app/api/(comment)/comment/find-by-payout/[payout_id]/route.ts→ GET comments for a payout -
src/app/api/(comment)/comment/update/[id]/route.ts→ PATCH comment editing -
src/app/api/(comment)/comment/delete/[id]/route.ts→ DELETE comment removal
Database Operations
- Use
@/lib/prisma+ error handling patterns - Optimize with indexes:
payout_id,user_id,created_at - Include
Userrelation for comment author - Return comments ordered chronologically (
created_at)
Authorization & Security
- Users can only update/delete their own comments
- Validate payout existence before comment creation
- Follow existing API authentication patterns
- Proper user context validation
Components
src/app/api/(comment)/comment/directory structure (new)- Follow consistent error handling & response patterns
Validations
- Comments link to existing
PayoutandUserrecords - User can only edit/delete own comments
- Comments display in chronological order
- Database queries optimized with proper indexing
Reactions are currently unavailable