Skip to content

Commit

Permalink
Merge pull request #22 from Arquisoft/GeneraciónPreguntas-#2
Browse files Browse the repository at this point in the history
Generación preguntas #2
  • Loading branch information
CANCI0 authored Feb 13, 2024
2 parents 8962531 + eca107a commit 630fa79
Show file tree
Hide file tree
Showing 10 changed files with 1,002 additions and 2 deletions.
11 changes: 11 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const port = 8000;

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';

app.use(cors());
app.use(express.json());
Expand Down Expand Up @@ -41,6 +42,16 @@ app.post('/adduser', async (req, res) => {
}
});

app.get('/randomQuestion', async (req, res) => {
try {
// Forward the question request to the question service
const questionResponse = await axios.get(questionServiceUrl+'/randomQuestion', req.body);
res.json(questionResponse.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
57 changes: 57 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"dependencies": {
"cross-fetch": "^4.0.0",
"date-fns": "^3.3.1",
"react-auth-kit": "^3.0.2-alpha.19"
}
}
Loading

0 comments on commit 630fa79

Please sign in to comment.