Skip to content

Commit 0ef57ee

Browse files
committed
resolve merge conflict
2 parents 6bdb6a2 + 6ea317a commit 0ef57ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+4131
-180
lines changed

backend/question-service/package-lock.json

Lines changed: 0 additions & 146 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/question-service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"type": "module",
66
"scripts": {
77
"start": "tsx server.ts",
8+
"dev": "tsx watch server.ts",
89
"test": "echo \"Error: no test specified\" && exit 1",
910
"lint": "eslint ."
1011
},
@@ -34,7 +35,6 @@
3435
"@types/swagger-ui-express": "^4.1.6",
3536
"eslint": "^9.10.0",
3637
"globals": "^15.9.0",
37-
"nodemon": "^3.1.4",
3838
"prettier": "^3.3.3",
3939
"ts-node": "^10.9.2",
4040
"tsx": "^4.19.1",

backend/question-service/src/controllers/questionController.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
QN_DESC_CHAR_LIMIT,
88
QN_CREATED_MESSAGE,
99
QN_NOT_FOUND_MESSAGE,
10+
QN_DELETED_MESSAGE,
1011
SERVER_ERROR_MESSAGE,
1112
QN_RETRIEVED_MESSAGE,
1213
PAGE_LIMIT_REQUIRED_MESSAGE,
@@ -127,6 +128,25 @@ export const updateQuestion = async (
127128
}
128129
};
129130

131+
export const deleteQuestion = async (
132+
req: Request,
133+
res: Response,
134+
): Promise<void> => {
135+
try {
136+
const { id } = req.params;
137+
const currentQuestion = await Question.findById(id);
138+
if (!currentQuestion) {
139+
res.status(400).json({ message: QN_NOT_FOUND_MESSAGE });
140+
return;
141+
}
142+
143+
await Question.findByIdAndDelete(id);
144+
res.status(200).json({ message: QN_DELETED_MESSAGE });
145+
} catch (error) {
146+
res.status(500).json({ message: SERVER_ERROR_MESSAGE, error });
147+
}
148+
};
149+
130150
interface QnListSearchFilterParams {
131151
page: string;
132152
qnLimit: string;
@@ -206,6 +226,7 @@ export const readQuestionIndiv = async (
206226
res.status(404).json({ message: QN_NOT_FOUND_MESSAGE });
207227
return;
208228
}
229+
209230
res.status(200).json({
210231
message: QN_RETRIEVED_MESSAGE,
211232
question: questionDetails,

backend/question-service/src/routes/questionRoutes.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import express from "express";
22
import {
33
createQuestion,
4+
deleteQuestion,
45
createImageLink,
56
updateQuestion,
67
readQuestionsList,
@@ -19,4 +20,6 @@ router.get("/questions", readQuestionsList);
1920

2021
router.get("/questions/:id", readQuestionIndiv);
2122

23+
router.delete("/questions/:id", deleteQuestion);
24+
2225
export default router;

backend/question-service/src/utils/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ export const QN_CREATED_MESSAGE = "Question created successfully.";
1010

1111
export const QN_NOT_FOUND_MESSAGE = "Question not found.";
1212

13+
export const QN_DELETED_MESSAGE = "Question deleted successfully.";
14+
1315
export const SERVER_ERROR_MESSAGE = "Server error.";
1416

1517
export const QN_RETRIEVED_MESSAGE = "Question retrieved successfully.";

0 commit comments

Comments
 (0)