Skip to content

Commit 3fb91e0

Browse files
authored
Merge pull request #114 from jolynloh/deployment
Deployment
2 parents 66d6b0e + 3f9359c commit 3fb91e0

File tree

9 files changed

+28
-12
lines changed

9 files changed

+28
-12
lines changed

backend/qn-history-service/src/middlewares/basicAccessControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export const verifyToken = (
1212
.then(() => next())
1313
.catch((err) => {
1414
console.log(err.response);
15-
return res.status(err.response.status).json(err.response.data);
15+
return res.status(err.response?.status).json(err.response?.data);
1616
});
1717
};

backend/question-service/src/middlewares/basicAccessControl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ export const verifyAdminToken = (
1212
.then(() => next())
1313
.catch((err) => {
1414
console.log(err.response);
15-
return res.status(err.response.status).json(err.response.data);
15+
return res.status(err.response?.status).json(err.response?.data);
1616
});
1717
};

backend/question-service/src/server.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
import app from "./app.ts";
22
import connectDB from "./config/db.ts";
3+
// import { seedQuestions } from "./scripts/seed.ts";
34

45
const PORT = process.env.SERVICE_PORT || 3000;
56

67
if (process.env.NODE_ENV !== "test") {
78
connectDB()
89
.then(() => {
910
console.log("MongoDB Connected!");
11+
// seedQuestions();
1012

11-
app.listen(PORT, () => {
13+
const server = app.listen(PORT, () => {
1214
console.log(
1315
`Question service server listening on http://localhost:${PORT}`,
1416
);
1517
});
18+
19+
server.keepAliveTimeout = 70 * 1000; // set timeout value to > load balancer idle timeout (60s)
1620
})
1721
.catch((err) => {
1822
console.error("Failed to connect to DB");

backend/user-service/src/model/repository.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
import UserModel, { IUser } from "./user-model";
2-
import "dotenv/config";
2+
import dotenv from "dotenv";
33
import { connect } from "mongoose";
44

5+
dotenv.config();
6+
57
export async function connectToDB() {
68
const mongoDBUri: string | undefined =
79
process.env.NODE_ENV === "production"
810
? process.env.MONGO_CLOUD_URI
911
: process.env.MONGO_LOCAL_URI;
1012

13+
console.log(mongoDBUri);
14+
1115
if (!mongoDBUri) {
1216
throw new Error("MongoDB URI is not provided");
1317
}

frontend/src/utils/api.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import axios from "axios";
22

3-
const usersUrl = "http://localhost:3001/api";
4-
const questionsUrl = "http://localhost:3000/api/questions";
5-
const codeExecutionUrl = "http://localhost:3004/api/run";
6-
const qnHistoriesUrl = "http://localhost:3006/api/qnhistories";
3+
const usersUrl =
4+
import.meta.env.VITE_USER_SERVICE_URL ?? "http://localhost:3001/api";
5+
const questionsUrl =
6+
import.meta.env.VITE_QN_SERVICE_URL ?? "http://localhost:3000/api/questions";
7+
const codeExecutionUrl =
8+
import.meta.env.VITE_CODE_EXEC_SERVICE_URL ?? "http://localhost:3004/api/run";
9+
const qnHistoriesUrl =
10+
import.meta.env.VITE_QN_HIST_SERVICE_URL ??
11+
"http://localhost:3006/api/qnhistories";
712

813
export const questionClient = axios.create({
914
baseURL: questionsUrl,

frontend/src/utils/collabSocket.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ export type CollabSessionData = {
3838
awareness: Awareness;
3939
};
4040

41-
const COLLAB_SOCKET_URL = "http://localhost:3003";
41+
const COLLAB_SOCKET_URL =
42+
import.meta.env.VITE_COLLAB_SERVICE_URL ?? "http://localhost:3003";
4243

4344
export const collabSocket = io(COLLAB_SOCKET_URL, {
4445
reconnectionAttempts: 5,

frontend/src/utils/communicationSocket.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export enum CommunicationEvents {
1616
DISCONNECTED = "disconnected",
1717
}
1818

19-
const COMMUNICATION_SOCKET_URL = "http://localhost:3005";
19+
const COMMUNICATION_SOCKET_URL =
20+
import.meta.env.VITE_COMM_SERVICE_URL ?? "http://localhost:3005";
2021

2122
export const communicationSocket = io(COMMUNICATION_SOCKET_URL, {
2223
reconnectionAttempts: 3,

frontend/src/utils/matchSocket.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { io } from "socket.io-client";
22
import { getToken } from "./token";
33

4-
const MATCH_SOCKET_URL = "http://localhost:3002";
4+
const MATCH_SOCKET_URL =
5+
import.meta.env.VITE_MATCH_SERVICE_URL ?? "http://localhost:3002";
56

67
export const matchSocket = io(MATCH_SOCKET_URL, {
78
reconnectionAttempts: 3,

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
"husky": "^9.1.6"
44
},
55
"scripts": {
6-
"prepare": "husky"
6+
"prepare": "command -v husky && husky || true"
77
}
88
}

0 commit comments

Comments
 (0)