Skip to content

Commit

Permalink
Control exceptions on question generation service
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287687 committed Feb 23, 2024
1 parent de57f9e commit 777ee13
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
21 changes: 18 additions & 3 deletions question_generator/questionGenerationService.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,28 @@ app.use(bodyParser.json());


app.get('/api/questions/create', async (req, res) => {
res.status(200).json(await generalTemplate.getRandomQuestion())
try {
const randomQuestion = await generalTemplate.getRandomQuestion();
res.status(200).json(randomQuestion);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
});
app.get('/api/questions/planets/create', async (req, res) => {
res.status(200).json(await planetTemplate.getRandomQuestion())
try {
const randomQuestion = await planetTemplate.getRandomQuestion();
res.status(200).json(randomQuestion);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
});
app.get('/api/questions/cities/create', async (req, res) => {
res.status(200).json(await citiesTemplate.getRandomQuestion())
try {
const randomQuestion = await citiesTemplate.getRandomQuestion();
res.status(200).json(randomQuestion);
} catch (error) {
res.status(500).json({ error: 'Internal Server Error' });
}
});

generalTemplate.loadData();
Expand Down
1 change: 1 addition & 0 deletions webapp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ unit-tests:
- run: npm --prefix webapp ci
- run: npm --prefix users/authservice test -- --coverage
- run: npm --prefix users/userservice test -- --coverage
- run: npm --prefix question_generator/questionGenerationService test -- --coverage
- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- name: Analyze with SonarCloud
Expand Down

0 comments on commit 777ee13

Please sign in to comment.