Skip to content

Commit

Permalink
Merge pull request #67 from Arquisoft/newstatsservice
Browse files Browse the repository at this point in the history
Newstatsservice
  • Loading branch information
CANCI0 authored Mar 18, 2024
2 parents 22316ca + e27117d commit b236ca3
Show file tree
Hide file tree
Showing 27 changed files with 1,050 additions and 378 deletions.
4 changes: 1 addition & 3 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@ services:
build: ./statsservice
depends_on:
- mongodb
- userservice
ports:
- "8004:8004"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb
USER_SERVICE_URL: http://userservice:8001
MONGODB_URI: mongodb://mongodb:27017/statsdb

authservice:
container_name: authservice-${teamname:-defaultASW}
Expand Down
22 changes: 3 additions & 19 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const authServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8002";
const userServiceUrl = process.env.USER_SERVICE_URL || "http://localhost:8001";
const questionServiceUrl =
process.env.QUESTION_SERVICE_URL || "http://localhost:8003";
const statsServiceUrl = process.env.AUTH_SERVICE_URL || "http://localhost:8004";
const statsServiceUrl = process.env.STATS_SERVICE_URL || "http://localhost:8004";

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -112,10 +112,9 @@ app.post("/saveGame", async (req, res) => {
}
});

app.get("/getstats", async (req, res) => {
app.get("/ranking", async (req, res) => {
try {
// Forward the stats request to the stats service
const statsResponse = await axios.get(userServiceUrl + "/getstats", {
const statsResponse = await axios.get(statsServiceUrl + "/ranking", {
params: req.query,
});
res.json(statsResponse.data);
Expand All @@ -126,21 +125,6 @@ app.get("/getstats", async (req, res) => {
}
});

app.post("/userSaveGame", async (req, res) => {
try {
// Forward the save game request to the stats service
const gameResponse = await axios.post(
userServiceUrl + "/userSaveGame",
req.body
);
res.json(gameResponse.data);
} catch (error) {
res
.status(error.response.status)
.json({ error: error.response.data.error });
}
});

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
Loading

0 comments on commit b236ca3

Please sign in to comment.