Skip to content

Commit

Permalink
feat: Sanity endpoint for collab + change port from 3000 to 3333
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongbeom-Kim committed Nov 13, 2024
1 parent dc28346 commit 91e0eb8
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 10 deletions.
11 changes: 9 additions & 2 deletions peerprep/backend/collab-service/src/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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}`);
Expand Down
6 changes: 3 additions & 3 deletions peerprep/backend/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -41,6 +39,8 @@ services:
env_file:
- ./collab-service/.env
restart: always
volumes:
- "/etc/letsencrypt:/etc/letsencrypt"

networks:
my-network:
Expand Down
2 changes: 1 addition & 1 deletion peerprep/backend/matching-service/.env
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const createRequest = async (req: Request, res: Response): Promise<void>

// find within 30 seconds
let matchedUser = null;
const timeout = 30000;
const timeout = 33330;
const startTime = Date.now();

while (!matchedUser && Date.now() - startTime < timeout) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion peerprep/backend/matching-service/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/.env.development
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 91e0eb8

Please sign in to comment.