diff --git a/peerprep/backend/collab-service/src/server.js b/peerprep/backend/collab-service/src/server.js index b6c9e53c2e..08842368fd 100644 --- a/peerprep/backend/collab-service/src/server.js +++ b/peerprep/backend/collab-service/src/server.js @@ -17,7 +17,10 @@ dotenv.config(); const app = express(); let server; -if (process.env.SSL_KEY_PATH && process.env.SSL_CERT_PATH && process.env.SSL_CA_PATH) { +if (process.env.SSL_KEY_PATH && process.env.SSL_CERT_PATH && process.env.SSL_CA_PATH && + fs.existsSync(process.env.SSL_KEY_PATH) && + fs.existsSync(process.env.SSL_CERT_PATH) && + fs.existsSync(process.env.SSL_CA_PATH)) { // Load SSL/TLS certificates from environment variables const options = { key: fs.readFileSync(process.env.SSL_KEY_PATH), @@ -45,6 +48,11 @@ connectDB(); app.use('/api', gptRoutes); +// Sanity testing endpoint +app.get('/hello', (req, res) => { + res.status(200).json({ message: 'Hello, world!' }); +}); + // Endpoint to save a document to MongoDB app.post('/api/saveDocument', async(req, res) => { try { @@ -118,7 +126,6 @@ io.on("connection", (socket) => { }); }); - const PORT = process.env.PORT || 1234; server.listen(PORT, () => { console.log(`Server is running at http://localhost:${PORT}`); diff --git a/peerprep/backend/docker-compose.yaml b/peerprep/backend/docker-compose.yaml index 080bc4c870..4a28b9ba1d 100644 --- a/peerprep/backend/docker-compose.yaml +++ b/peerprep/backend/docker-compose.yaml @@ -24,12 +24,10 @@ services: context: ./matching-service dockerfile: Dockerfile ports: - - "3000:3000" + - "3333:3333" env_file: - ./matching-service/.env restart: always - volumes: - - /etc/letsencrypt:/etc/letsencrypt collab-service: build: @@ -41,6 +39,8 @@ services: env_file: - ./collab-service/.env restart: always + volumes: + - "/etc/letsencrypt:/etc/letsencrypt" networks: my-network: diff --git a/peerprep/backend/matching-service/.env b/peerprep/backend/matching-service/.env index f0b7a2596f..0495a88ec3 100644 --- a/peerprep/backend/matching-service/.env +++ b/peerprep/backend/matching-service/.env @@ -1,3 +1,3 @@ REDIS_CLOUD_URI=redis://default:TRXhRgutyzRMWWE8Mpl0RAYTECWRuxFH@redis-14179.c295.ap-southeast-1-1.ec2.redns.redis-cloud.com:14179/0 NODE_ENV=development -PORT=3000 +PORT=3333 diff --git a/peerprep/backend/matching-service/src/controllers/requestController.ts b/peerprep/backend/matching-service/src/controllers/requestController.ts index 5da340b530..bbb4908d4d 100644 --- a/peerprep/backend/matching-service/src/controllers/requestController.ts +++ b/peerprep/backend/matching-service/src/controllers/requestController.ts @@ -20,7 +20,7 @@ export const createRequest = async (req: Request, res: Response): Promise // find within 30 seconds let matchedUser = null; - const timeout = 30000; + const timeout = 33330; const startTime = Date.now(); while (!matchedUser && Date.now() - startTime < timeout) { diff --git a/peerprep/backend/matching-service/src/controllers/sseController.ts b/peerprep/backend/matching-service/src/controllers/sseController.ts index 435fb826ad..3580ebf49e 100644 --- a/peerprep/backend/matching-service/src/controllers/sseController.ts +++ b/peerprep/backend/matching-service/src/controllers/sseController.ts @@ -10,7 +10,7 @@ export const matchStatusStream = (req: Request, res: Response) => { res.flushHeaders(); // Ensure headers are sent immediately const userId = req.params.userId as string; // Get userId from URL parameters - const timeout = 30000; // 30-second timeout for example + const timeout = 33330; // 30-second timeout for example const startTime = Date.now(); // Function to send data to client diff --git a/peerprep/backend/matching-service/src/server.ts b/peerprep/backend/matching-service/src/server.ts index bd1c8efd3a..64003fb506 100644 --- a/peerprep/backend/matching-service/src/server.ts +++ b/peerprep/backend/matching-service/src/server.ts @@ -8,7 +8,7 @@ import apiRoutes from './routes/apiRoutes'; // Import your routes dotenv.config(); -const PORT = process.env.PORT ?? 3000; +const PORT = process.env.PORT ?? 3333; const app = express(); diff --git a/peerprep/frontend/.env.development b/peerprep/frontend/.env.development index 794be3a003..1b21ad7875 100644 --- a/peerprep/frontend/.env.development +++ b/peerprep/frontend/.env.development @@ -1,5 +1,5 @@ VITE_AUTH_API_URL=http://localhost:3001/auth -VITE_MATCHING_API_URL=http://localhost:3000/matchingrequest +VITE_MATCHING_API_URL=http://localhost:3333/matchingrequest VITE_USER_API_URL=http://localhost:3001/api/users VITE_USERS_API_URL=http://localhost:3001/users VITE_ASSESSCODE_API_URL=http://localhost:1234/api/gpt/assess