Skip to content

Commit 4914b77

Browse files
committed
Update source
1 parent a8a55fe commit 4914b77

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+13268
-0
lines changed

api-gateway/index.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const express = require("express");
2+
const httpProxy = require("http-proxy");
3+
4+
const proxy = httpProxy.createProxyServer();
5+
const app = express();
6+
7+
// Route requests to the auth service
8+
app.use("/auth", (req, res) => {
9+
proxy.web(req, res, { target: "http://auth:3000" });
10+
});
11+
12+
// Route requests to the product service
13+
app.use("/products", (req, res) => {
14+
proxy.web(req, res, { target: "http://product:3001" });
15+
});
16+
17+
// Route requests to the order service
18+
app.use("/orders", (req, res) => {
19+
proxy.web(req, res, { target: "http://order:3002" });
20+
});
21+
22+
// Start the server
23+
const port = process.env.PORT || 3003;
24+
app.listen(port, () => {
25+
console.log(`API Gateway listening on port ${port}`);
26+
});

0 commit comments

Comments
 (0)