|
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'; |
6 | 4 |
|
7 | 5 | const app = express();
|
8 | 6 | const proxy = httpProxy.createProxyServer();
|
9 | 7 | app.use(cors());
|
10 | 8 |
|
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 | 9 | // Define routes for each backend service for local development
|
21 | 10 | // app.use('/questionservice', (req, res) => {
|
22 | 11 | // proxy.web(req, res, { target: 'http://localhost:3002' });
|
23 | 12 | // });
|
24 |
| - |
25 | 13 | // app.use('/authservice', (req, res) => {
|
26 | 14 | // proxy.web(req, res, { target: 'http://localhost:3003' });
|
27 | 15 | // });
|
28 |
| - |
29 | 16 | // app.use('/userservice', (req, res) => {
|
30 | 17 | // proxy.web(req, res, { target: 'http://localhost:3004' });
|
31 | 18 | // });
|
32 | 19 |
|
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 |
| 20 | +// Define routes for each backend service for production/docker containers |
38 | 21 | app.use("/questionservice", (req, res) => {
|
39 |
| - proxy.web(req, res, { target: "http://localhost:3002" }); |
40 |
| - //http://question-service:3002 |
41 |
| - //http://localhost:3002 |
| 22 | + proxy.web(req, res, { target: "http://question-service:3002" }); |
42 | 23 | });
|
43 |
| - |
44 | 24 | app.use("/authservice", (req, res) => {
|
45 |
| - proxy.web(req, res, { target: "http://localhost:3003" }); |
46 |
| - //http://auth-service:3003 |
47 |
| - //http://localhost:3003 |
| 25 | + proxy.web(req, res, { target: "http://auth-service:3003" }); |
48 | 26 | });
|
49 |
| - |
50 | 27 | app.use("/userservice", (req, res) => {
|
51 |
| - proxy.web(req, res, { target: "http://localhost:3004" }); |
52 |
| - // http://user-service:3004 |
53 |
| - //http://localhost:3004 |
54 |
| -}); |
55 |
| - |
56 |
| -app.use("/matchingservice", (req, res) => { |
57 |
| - proxy.web(req, res, { target: "http://localhost:3005" }); |
58 |
| - //http://matching-service:3005 |
59 |
| - //http://localhost:3005 |
| 28 | + proxy.web(req, res, { target: "http://user-service:3004" }); |
60 | 29 | });
|
61 | 30 |
|
62 |
| -//Define routes for each backend service for production/docker containers |
63 |
| -// app.use("/questionservice", (req, res) => { |
64 |
| -// proxy.web(req, res, { target: "http://question-service:3002" }); |
65 |
| -// }); |
66 |
| - |
67 |
| -// app.use("/authservice", (req, res) => { |
68 |
| -// proxy.web(req, res, { target: "http://auth-service:3003" }); |
69 |
| -// }); |
70 |
| - |
71 |
| -// app.use("/userservice", (req, res) => { |
72 |
| -// proxy.web(req, res, { target: "http://user-service:3004" }); |
73 |
| -// }); |
74 |
| - |
75 |
| -// app.use("/matchingservice", (req, res) => { |
76 |
| -// proxy.web(req, res, { target: "http://matching-service:3005" }); |
77 |
| -// }); |
78 |
| - |
79 |
| - |
80 | 31 | // Start the server
|
81 | 32 | app.listen(3001, () => {
|
82 | 33 | console.log("API Gateway listening on port 3001");
|
|
0 commit comments