Got comments working
This commit is contained in:
@@ -6,7 +6,7 @@ import { requireLogin, requireMemberState, requireRole } from '../middleware/aut
|
||||
import { logger } from '../services/logging/logger';
|
||||
import { audit } from '../services/logging/auditLog';
|
||||
import { MemberState } from '@app/shared/types/member';
|
||||
import { createDiscussion, getAllDiscussions, getDiscussionById, postComment } from '../services/db/discussionService';
|
||||
import { createDiscussion, getAllDiscussions, getDiscussionById, getPostComments, postComment } from '../services/db/discussionService';
|
||||
import { ModRequest } from '@app/shared/schemas/modRequest';
|
||||
import { DiscussionComment } from '@app/shared/types/discussion';
|
||||
|
||||
@@ -20,10 +20,22 @@ router.post('/comment', async (req: Request, res: Response) => {
|
||||
console.log(comment);
|
||||
|
||||
await postComment(comment, req.user.id);
|
||||
|
||||
|
||||
res.sendStatus(201);
|
||||
} catch (error) {
|
||||
logger.error('app', "Failed to post comments", error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
router.get('/:postId/comments', async (req: Request, res: Response) => {
|
||||
try {
|
||||
const postId = parseInt(req.params.postId);
|
||||
const comments = await getPostComments(postId);
|
||||
res.json(comments);
|
||||
} catch (error) {
|
||||
logger.error('app', "Failed to fetch comments", error);
|
||||
res.sendStatus(500);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user