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 = (
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} ;
Original file line number Diff line number Diff 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} ;
Original file line number Diff line number Diff line change 11import app from "./app.ts" ;
22import connectDB from "./config/db.ts" ;
3+ // import { seedQuestions } from "./scripts/seed.ts";
34
45const PORT = process . env . SERVICE_PORT || 3000 ;
56
67if ( 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" ) ;
Original file line number Diff line number Diff line change 11import UserModel , { IUser } from "./user-model" ;
2- import "dotenv/config " ;
2+ import dotenv from "dotenv" ;
33import { connect } from "mongoose" ;
44
5+ dotenv . config ( ) ;
6+
57export 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 }
Original file line number Diff line number Diff line change 11import 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
813export const questionClient = axios . create ( {
914 baseURL : questionsUrl ,
Original file line number Diff line number Diff 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
4344export const collabSocket = io ( COLLAB_SOCKET_URL , {
4445 reconnectionAttempts : 5 ,
Original file line number Diff line number Diff 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
2122export const communicationSocket = io ( COMMUNICATION_SOCKET_URL , {
2223 reconnectionAttempts : 3 ,
Original file line number Diff line number Diff line change 11import { io } from "socket.io-client" ;
22import { 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
67export const matchSocket = io ( MATCH_SOCKET_URL , {
78 reconnectionAttempts : 3 ,
Original file line number Diff line number Diff line change 33 "husky" : " ^9.1.6"
44 },
55 "scripts" : {
6- "prepare" : " husky"
6+ "prepare" : " command -v husky && husky || true "
77 }
88}
You can’t perform that action at this time.
0 commit comments