MCPcopy Create free account
hub / github.com/coderwhy/coderhub / CommentController

Class CommentController

src/controller/comment.controller.js:3–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1const service = require('../service/comment.service.js');
2
3class CommentController {
4 async create(ctx, next) {
5 const { momentId, content } = ctx.request.body;
6 const { id } = ctx.user;
7 const result = await service.create(momentId, content, id);
8 ctx.body = result;
9 }
10
11 async reply(ctx, next) {
12 const { momentId, content } = ctx.request.body;
13 const { commentId } = ctx.params;
14 const { id } = ctx.user;
15 const result = await service.reply(momentId, content, id, commentId);
16 ctx.body = result;
17 }
18
19 async update(ctx, next) {
20 const { commentId } = ctx.params;
21 const { content } = ctx.request.body;
22 const result = await service.update(commentId, content);
23 ctx.body = result;
24 }
25
26 async remove(ctx, next) {
27 const { commentId } = ctx.params;
28 const result = await service.remove(commentId);
29 ctx.body = result;
30 }
31
32 async list(ctx, next) {
33 const { momentId } = ctx.query;
34 const result = await service.getCommentsByMomentId(momentId);
35 ctx.body = result;
36 }
37}
38
39module.exports = new CommentController();

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected