Skip to content

Commit 519295c

Browse files
committed
Containerise frontend and update docker-compose
1 parent 7a60038 commit 519295c

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Request, Response } from "express";
22
import Question, { IQuestion } from "../models/Question.ts";
3-
import { checkIsExistingQuestion, sortAlphabetically } from "../utils/utils.ts";
3+
import { checkIsExistingQuestion } from "../utils/utils.ts";
44
import {
55
DUPLICATE_QUESTION_MESSAGE,
66
QN_DESC_EXCEED_CHAR_LIMIT_MESSAGE,
@@ -13,8 +13,6 @@ import {
1313
PAGE_LIMIT_REQUIRED_MESSAGE,
1414
PAGE_LIMIT_INCORRECT_FORMAT_MESSAGE,
1515
CATEGORIES_RETRIEVED_MESSAGE,
16-
MONGO_OBJ_ID_FORMAT,
17-
MONGO_OBJ_ID_MALFORMED_MESSAGE,
1816
} from "../utils/constants.ts";
1917

2018
import { upload } from "../../config/multer";
@@ -80,7 +78,6 @@ export const createImageLink = async (
8078

8179
const uploadPromises = files.map((file) => uploadFileToFirebase(file));
8280
const imageUrls = await Promise.all(uploadPromises);
83-
console.log(imageUrls);
8481
res
8582
.status(200)
8683
.json({ message: "Images uploaded successfully", imageUrls });
@@ -98,13 +95,7 @@ export const updateQuestion = async (
9895
const { id } = req.params;
9996
const { title, description } = req.body;
10097

101-
if (!id.match(MONGO_OBJ_ID_FORMAT)) {
102-
res.status(400).json({ message: MONGO_OBJ_ID_MALFORMED_MESSAGE });
103-
return;
104-
}
105-
10698
const currentQuestion = await Question.findById(id);
107-
10899
if (!currentQuestion) {
109100
res.status(404).json({ message: QN_NOT_FOUND_MESSAGE });
110101
return;
@@ -212,12 +203,7 @@ export const readQuestionsList = async (
212203
res.status(200).json({
213204
message: QN_RETRIEVED_MESSAGE,
214205
questionCount: filteredQuestionCount,
215-
questions: filteredQuestions
216-
.map(formatQuestionResponse)
217-
.map((question) => ({
218-
...question,
219-
categories: sortAlphabetically(question.categories),
220-
})),
206+
questions: filteredQuestions.map(formatQuestionResponse),
221207
});
222208
} catch (error) {
223209
res.status(500).json({ message: SERVER_ERROR_MESSAGE, error });
@@ -255,7 +241,7 @@ export const readCategories = async (
255241

256242
res.status(200).json({
257243
message: CATEGORIES_RETRIEVED_MESSAGE,
258-
categories: sortAlphabetically(uniqueCats),
244+
categories: uniqueCats,
259245
});
260246
} catch (error) {
261247
res.status(500).json({ message: SERVER_ERROR_MESSAGE, error });

docker-compose.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@ services:
1919
networks:
2020
- peerprep-network
2121
restart: on-failure
22+
frontend:
23+
image: peerprep/frontend
24+
build: ./frontend
25+
ports:
26+
- 5173:5173
27+
depends_on:
28+
- user-service
29+
- question-service
30+
networks:
31+
- peerprep-network
32+
restart: on-failure
2233

2334
networks:
2435
peerprep-network:

frontend/.dockerignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules

frontend/Dockerfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
FROM node:20-alpine
2+
3+
WORKDIR /frontend
4+
5+
COPY package*.json ./
6+
7+
RUN npm ci
8+
9+
COPY . .
10+
11+
EXPOSE 5173
12+
13+
CMD ["npm", "run", "dev"]

0 commit comments

Comments
 (0)