|
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
|
| 10 | +// app.use('/questionservice', (req, res) => { |
| 11 | +// proxy.web(req, res, { target: 'http://localhost:3002' }); |
| 12 | +// }); |
| 13 | +// app.use('/authservice', (req, res) => { |
| 14 | +// proxy.web(req, res, { target: 'http://localhost:3003' }); |
| 15 | +// }); |
| 16 | +// app.use('/userservice', (req, res) => { |
| 17 | +// proxy.web(req, res, { target: 'http://localhost:3004' }); |
| 18 | +// }); |
| 19 | + |
| 20 | +// Define routes for each backend service for production/docker containers |
21 | 21 | app.use("/questionservice", (req, res) => {
|
22 | 22 | proxy.web(req, res, { target: "http://question-service:3002" });
|
23 | 23 | });
|
24 |
| - |
25 | 24 | app.use("/authservice", (req, res) => {
|
26 | 25 | proxy.web(req, res, { target: "http://auth-service:3003" });
|
27 | 26 | });
|
28 |
| - |
29 | 27 | app.use("/userservice", (req, res) => {
|
30 | 28 | proxy.web(req, res, { target: "http://user-service:3004" });
|
31 | 29 | });
|
32 | 30 |
|
33 |
| -app.use("/matchingservice", (req, res) => { |
34 |
| - proxy.web(req, res, { target: "http://matching-service:3005" }); |
35 |
| -}); |
36 |
| - |
37 | 31 | // Start the server
|
38 | 32 | app.listen(3001, () => {
|
39 | 33 | console.log("API Gateway listening on port 3001");
|
|
0 commit comments