Skip to content

Commit

Permalink
access to the question generation service from the gateway service
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287687 committed Feb 21, 2024
1 parent 178c7f1 commit 302bdb4
Showing 1 changed file with 11 additions and 0 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 questionGenerationServiceUrl = process.env.QUESTION_GENERATION_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('/api/questions/create', async (req, res) => {
try {
// Forward the add user request to the user service
const userResponse = await axios.get(questionGenerationServiceUrl+'/api/questions/create');
res.json(userResponse.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

0 comments on commit 302bdb4

Please sign in to comment.