Skip to content

Commit b236ca3

Browse files
authored
Merge pull request #67 from Arquisoft/newstatsservice
Newstatsservice
2 parents 22316ca + e27117d commit b236ca3

27 files changed

+1050
-378
lines changed

docker-compose.yml

+1-3
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,12 @@ services:
2828
build: ./statsservice
2929
depends_on:
3030
- mongodb
31-
- userservice
3231
ports:
3332
- "8004:8004"
3433
networks:
3534
- mynetwork
3635
environment:
37-
MONGODB_URI: mongodb://mongodb:27017/userdb
38-
USER_SERVICE_URL: http://userservice:8001
36+
MONGODB_URI: mongodb://mongodb:27017/statsdb
3937

4038
authservice:
4139
container_name: authservice-${teamname:-defaultASW}

gatewayservice/gateway-service.js

+3-19
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const authServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8002";
1010
const userServiceUrl = process.env.USER_SERVICE_URL || "http://localhost:8001";
1111
const questionServiceUrl =
1212
process.env.QUESTION_SERVICE_URL || "http://localhost:8003";
13-
const statsServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8004";
13+
const statsServiceUrl = process.env.STATS_SERVICE_URL || "http://localhost:8004";
1414

1515
app.use(cors());
1616
app.use(express.json());
@@ -112,10 +112,9 @@ app.post("/saveGame", async (req, res) => {
112112
}
113113
});
114114

115-
app.get("/getstats", async (req, res) => {
115+
app.get("/ranking", async (req, res) => {
116116
try {
117-
// Forward the stats request to the stats service
118-
const statsResponse = await axios.get(userServiceUrl + "/getstats", {
117+
const statsResponse = await axios.get(statsServiceUrl + "/ranking", {
119118
params: req.query,
120119
});
121120
res.json(statsResponse.data);
@@ -126,21 +125,6 @@ app.get("/getstats", async (req, res) => {
126125
}
127126
});
128127

129-
app.post("/userSaveGame", async (req, res) => {
130-
try {
131-
// Forward the save game request to the stats service
132-
const gameResponse = await axios.post(
133-
userServiceUrl + "/userSaveGame",
134-
req.body
135-
);
136-
res.json(gameResponse.data);
137-
} catch (error) {
138-
res
139-
.status(error.response.status)
140-
.json({ error: error.response.data.error });
141-
}
142-
});
143-
144128
// Start the gateway service
145129
const server = app.listen(port, () => {
146130
console.log(`Gateway Service listening at http://localhost:${port}`);

0 commit comments

Comments
 (0)