Got comments working

This commit is contained in:
2026-03-01 13:18:12 -05:00
parent 5483e42bb4
commit 7c090c647e
4 changed files with 48 additions and 13 deletions

View File

@@ -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);
}
});