Skip to content

Commit e84cf61

Browse files
authored
Merge pull request #28 from CS3219-AY2425S1/user-service-frontend
Update Main with user service frontend and d4 milestone set up
2 parents b03ba5d + 5460b7b commit e84cf61

28 files changed

+1967
-11
lines changed

Backend/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
QuestionService/.env
22
user-service/.env
3+
MatchingService/.env
34
QuestionService/insert_questions_script.py
45

56
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
67

78
# dependencies
89
QuestionService/node_modules
910
user-service/node_modules
11+
MatchingService/node_modules
1012
/.pnp
1113
.pnp.js
1214

Backend/MatchingService/app.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
const express = require('express');
2+
const cors = require("cors");
3+
const dotenv = require("dotenv");
4+
//const matchmakingRouter = require("./controllers/matchmaking");
5+
//const { consumeQueue } = require('./rabbitmq/subscriber');
6+
//const { setupRabbitMQ } = require('./rabbitmq/setup');
7+
//const { publishToQueue } = require('./rabbitmq/publisher')
8+
9+
dotenv.config();
10+
11+
const app = express();
12+
app.use(cors());
13+
app.use(express.json());
14+
15+
app.use('/api/match', matchmakingRouter);
16+
17+
// TODO: Start consuming RabbitMQ queues
18+
/*
19+
setupRabbitMQ().then(() => {
20+
21+
consumeQueue().catch(console.error);
22+
publishToQueue("user_234", "easy", "python")
23+
publishToQueue("user_100", "easy", "java")
24+
25+
})
26+
*/
27+
28+
module.exports = app;
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// TODO: WRITE API FOR MATCHING USER, REMEMBER TO DEAL WITH CORS ALLOW ACCESS ORIGIN ERROR
2+
3+
/*
4+
const express = require('express');
5+
const router = express.Router();
6+
const { publishToQueue } = require('../rabbitmq/publisher');
7+
8+
// Route for frontend to send user matching info
9+
router.post('/match', async (req, res) => {
10+
const { userId, language, difficulty } = req.body;
11+
12+
try {
13+
// Publish user info to RabbitMQ
14+
await publishToQueue(userId, language, difficulty);
15+
res.status(200).send('User info sent for matching.');
16+
} catch (error) {
17+
console.error('Error publishing user info:', error);
18+
res.status(500).send('Error in matchmaking process.');
19+
}
20+
});
21+
22+
module.exports = router;
23+
*/

Backend/MatchingService/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
const app = require('./app');
2+
3+
app.listen(3003, () => {
4+
console.log("Matchmaking Server is Running.");
5+
})
6+
7+
8+

0 commit comments

Comments
 (0)