File tree Expand file tree Collapse file tree 9 files changed +28
-12
lines changed
qn-history-service/src/middlewares Expand file tree Collapse file tree 9 files changed +28
-12
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,6 @@ export const verifyToken = (
12
12
. then ( ( ) => next ( ) )
13
13
. catch ( ( err ) => {
14
14
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 ) ;
16
16
} ) ;
17
17
} ;
Original file line number Diff line number Diff line change @@ -12,6 +12,6 @@ export const verifyAdminToken = (
12
12
. then ( ( ) => next ( ) )
13
13
. catch ( ( err ) => {
14
14
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 ) ;
16
16
} ) ;
17
17
} ;
Original file line number Diff line number Diff line change 1
1
import app from "./app.ts" ;
2
2
import connectDB from "./config/db.ts" ;
3
+ // import { seedQuestions } from "./scripts/seed.ts";
3
4
4
5
const PORT = process . env . SERVICE_PORT || 3000 ;
5
6
6
7
if ( process . env . NODE_ENV !== "test" ) {
7
8
connectDB ( )
8
9
. then ( ( ) => {
9
10
console . log ( "MongoDB Connected!" ) ;
11
+ // seedQuestions();
10
12
11
- app . listen ( PORT , ( ) => {
13
+ const server = app . listen ( PORT , ( ) => {
12
14
console . log (
13
15
`Question service server listening on http://localhost:${ PORT } ` ,
14
16
) ;
15
17
} ) ;
18
+
19
+ server . keepAliveTimeout = 70 * 1000 ; // set timeout value to > load balancer idle timeout (60s)
16
20
} )
17
21
. catch ( ( err ) => {
18
22
console . error ( "Failed to connect to DB" ) ;
Original file line number Diff line number Diff line change 1
1
import UserModel , { IUser } from "./user-model" ;
2
- import "dotenv/config " ;
2
+ import dotenv from "dotenv" ;
3
3
import { connect } from "mongoose" ;
4
4
5
+ dotenv . config ( ) ;
6
+
5
7
export async function connectToDB ( ) {
6
8
const mongoDBUri : string | undefined =
7
9
process . env . NODE_ENV === "production"
8
10
? process . env . MONGO_CLOUD_URI
9
11
: process . env . MONGO_LOCAL_URI ;
10
12
13
+ console . log ( mongoDBUri ) ;
14
+
11
15
if ( ! mongoDBUri ) {
12
16
throw new Error ( "MongoDB URI is not provided" ) ;
13
17
}
Original file line number Diff line number Diff line change 1
1
import axios from "axios" ;
2
2
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" ;
7
12
8
13
export const questionClient = axios . create ( {
9
14
baseURL : questionsUrl ,
Original file line number Diff line number Diff line change @@ -38,7 +38,8 @@ export type CollabSessionData = {
38
38
awareness : Awareness ;
39
39
} ;
40
40
41
- const COLLAB_SOCKET_URL = "http://localhost:3003" ;
41
+ const COLLAB_SOCKET_URL =
42
+ import . meta. env . VITE_COLLAB_SERVICE_URL ?? "http://localhost:3003" ;
42
43
43
44
export const collabSocket = io ( COLLAB_SOCKET_URL , {
44
45
reconnectionAttempts : 5 ,
Original file line number Diff line number Diff line change @@ -16,7 +16,8 @@ export enum CommunicationEvents {
16
16
DISCONNECTED = "disconnected" ,
17
17
}
18
18
19
- const COMMUNICATION_SOCKET_URL = "http://localhost:3005" ;
19
+ const COMMUNICATION_SOCKET_URL =
20
+ import . meta. env . VITE_COMM_SERVICE_URL ?? "http://localhost:3005" ;
20
21
21
22
export const communicationSocket = io ( COMMUNICATION_SOCKET_URL , {
22
23
reconnectionAttempts : 3 ,
Original file line number Diff line number Diff line change 1
1
import { io } from "socket.io-client" ;
2
2
import { getToken } from "./token" ;
3
3
4
- const MATCH_SOCKET_URL = "http://localhost:3002" ;
4
+ const MATCH_SOCKET_URL =
5
+ import . meta. env . VITE_MATCH_SERVICE_URL ?? "http://localhost:3002" ;
5
6
6
7
export const matchSocket = io ( MATCH_SOCKET_URL , {
7
8
reconnectionAttempts : 3 ,
Original file line number Diff line number Diff line change 3
3
"husky" : " ^9.1.6"
4
4
},
5
5
"scripts" : {
6
- "prepare" : " husky"
6
+ "prepare" : " command -v husky && husky || true "
7
7
}
8
8
}
You can’t perform that action at this time.
0 commit comments