Back to Bricks
Comments System
SocialNested commenting system for any resource (Product, Post, etc). Supports parent/child relationships.
socialdiscussionreplythreadAuth Required
Backend:
prisma/schema.prismajavascript
1model Comment {2 id String @id @default(uuid())3 content String4 userId String5 targetId String6 targetModel String7 parentId String?8 createdAt DateTime @default(now())9}Paste Guide
Copy files to:
prisma/schema.prisma (append models)repositories/comment.repo.jscontrollers/commentController.jsroutes/commentRoutes.jsAdd to server.js:
app.use('/api/comment', require('./routes/commentRoutes'));Stack
PrismaExpress
Test Examples
curl http://localhost:5000/api/comments/Post/POST_IDcurl -X POST http://localhost:5000/api/comments \
-H "Authorization: Bearer TOKEN" \
-d '{"content": "Nice!", "targetId": "ID", "targetModel": "Post"}'