1
1
import express from 'express' ;
2
2
import httpProxy from 'http-proxy' ;
3
3
import cors from 'cors' ;
4
+ // import http from 'http';
5
+ // import { Server } from 'socket.io';
4
6
5
7
const app = express ( ) ;
6
8
const proxy = httpProxy . createProxyServer ( ) ;
7
9
app . use ( cors ( ) ) ;
8
10
9
- // Define routes for each backend service
11
+ // // Create an HTTP server and attach Socket.IO to it
12
+ // const server = http.createServer(app);
13
+ // const io = new Server(server, {
14
+ // cors: {
15
+ // origin: '*',
16
+ // },
17
+ // path: 'ws'
18
+ // });
19
+
20
+ // Define routes for each backend service for local development
21
+ // app.use('/questionservice', (req, res) => {
22
+ // proxy.web(req, res, { target: 'http://localhost:3002' });
23
+ // });
24
+
25
+ // app.use('/authservice', (req, res) => {
26
+ // proxy.web(req, res, { target: 'http://localhost:3003' });
27
+ // });
28
+
29
+ // app.use('/userservice', (req, res) => {
30
+ // proxy.web(req, res, { target: 'http://localhost:3004' });
31
+ // });
32
+
33
+ // app.use('/matchingservice', (req, res) => {
34
+ // proxy.web(req, res, { target: 'http://localhost:3005' });
35
+ // });
36
+
37
+ //Define routes for each backend service for production/docker containers
10
38
app . use ( '/questionservice' , ( req , res ) => {
11
- proxy . web ( req , res , { target : 'http://localhost :3002' } ) ;
39
+ proxy . web ( req , res , { target : 'http://question-service :3002' } ) ;
12
40
} ) ;
13
41
14
42
app . use ( '/authservice' , ( req , res ) => {
15
- proxy . web ( req , res , { target : 'http://localhost :3003' } ) ;
43
+ proxy . web ( req , res , { target : 'http://auth-service :3003' } ) ;
16
44
} ) ;
17
45
18
46
app . use ( '/userservice' , ( req , res ) => {
19
- proxy . web ( req , res , { target : 'http://localhost :3004' } ) ;
47
+ proxy . web ( req , res , { target : 'http://user-service :3004' } ) ;
20
48
} ) ;
21
49
22
50
app . use ( '/matchingservice' , ( req , res ) => {
23
- proxy . web ( req , res , { target : 'http://localhost :3005' } ) ;
51
+ proxy . web ( req , res , { target : 'http://matching-service :3005' } ) ;
24
52
} ) ;
25
-
26
53
// Start the server
27
54
app . listen ( 3001 , ( ) => {
28
55
console . log ( 'API Gateway listening on port 3001' ) ;
29
- } ) ;
56
+ } ) ;
0 commit comments