96da68e18e
- Express 4 → 5.2.1 - Remove method-override (unused with Angular HttpClient) and errorhandler (superseded by exceptions.handler.js) - Remove asyncHandler wrapper from all controllers — Express 5 propagates async rejections natively - Remove body-parser (redundant, Express 5 includes it internally) - Patch/minor updates: cors, dotenv, ejs, express-jwt, express-session, jsonwebtoken, morgan, mysql2, sequelize, underscore - Dev updates: eslint 9.0→9.39, nodemon 2→3, globals, sequelize-cli - Fix getUser endpoint to include SkydiverProfile data in response - docs: add ADR 0013, update README
35 lines
1.0 KiB
JavaScript
35 lines
1.0 KiB
JavaScript
const { CommentService } = require('../services');
|
|
const ErrorResponse = require("../utils/errorResponse");
|
|
|
|
module.exports.createComment = async (req, res, next) => {
|
|
try {
|
|
const { slug, title, description, body } = req.body;
|
|
const comment = await CommentService.createComment({
|
|
slug,
|
|
title,
|
|
description,
|
|
body,
|
|
authorId: req.payload.id
|
|
});
|
|
|
|
res.status(201).json({
|
|
message: 'Comment created successfully.',
|
|
data: comment,
|
|
});
|
|
} catch (err) {
|
|
return next(new ErrorResponse('Something went wrong while creating comment.', 500, err.message));
|
|
}
|
|
};
|
|
|
|
module.exports.getAllComments = async (req, res, next) => {
|
|
try {
|
|
const comments = await CommentService.getAllComments();
|
|
|
|
res.status(200).json({
|
|
data: comments,
|
|
});
|
|
} catch (err) {
|
|
return next(new ErrorResponse('Something went wrong while fetching comments.', 500, err.message));
|
|
}
|
|
};
|