Skip to content

Commit

Permalink
Merge branch 'PruebaConjunto'
Browse files Browse the repository at this point in the history
  • Loading branch information
lauracc97 committed Mar 23, 2024
2 parents b1f70c7 + 319b34f commit 967afb4
Show file tree
Hide file tree
Showing 21 changed files with 33,944 additions and 653 deletions.
32 changes: 32 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ services:
networks:
- mynetwork

wikidata:
container_name: wikidata-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es2a/query-questions:latest
profiles: ["dev", "prod"]
build: ./questions/query-questions
depends_on:
- mongodb
ports:
- "8003:8003"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

questionservice:
container_name: questionservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es2a/questionservice:latest
profiles: ["dev", "prod"]
build: ./questions/template-questions
depends_on:
- mongodb
ports:
- "8004:8004"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

authservice:
container_name: authservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es2a/authservice:latest
Expand Down Expand Up @@ -48,11 +76,15 @@ services:
- mongodb
- userservice
- authservice
- wikidata
- questionservice
ports:
- "8000:8000"
networks:
- mynetwork
environment:
QUESTIONS_SERVICE_URL: http://questionservice:8004
WIKIDATA_SERVICE_URL: http://wikidata:8003
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001

Expand Down
25 changes: 25 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ const promBundle = require('express-prom-bundle');
const app = express();
const port = 8000;

const questServiceUrl = process.env.QUESTIONS_SERVICE_URL || 'http://localhost:8004';
const questRandServiceUrl = process.env.WIKIDATA_SERVICE_URL || 'http://localhost:8003';
const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';

Expand Down Expand Up @@ -41,6 +43,29 @@ app.post('/adduser', async (req, res) => {
}
});

app.post('/questions', async (req, res) => {
try {
console.log("pasando por el gateway por /questions");
// Forward the add user request to the user service
const userResponse = await axios.post(questServiceUrl+'/questions', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});

app.post('/randomQuest', async (req, res) => {

try {
//console.log("hola");
// Forward the add user request to the user service
const response = await axios.post(questRandServiceUrl+'/randomQuest', req.body);
res.json(response.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 967afb4

Please sign in to comment.