Skip to content

Commit

Permalink
Merge pull request #95 from Arquisoft/UO289659
Browse files Browse the repository at this point in the history
Uo289659
  • Loading branch information
UO289659 authored Apr 1, 2024
2 parents 3e65cf9 + 61d7577 commit c398c31
Show file tree
Hide file tree
Showing 21 changed files with 7,909 additions and 871 deletions.
23 changes: 22 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,22 @@ services:
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb

statisticsservice:
container_name: statisticsservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3a/statisticsservice:latest
profiles: ["dev", "prod"]
build: ./statistics/statisticsservice
depends_on:
- mongodb
ports:
- "8006:8006"
networks:
- mynetwork
environment:
MONGODB_URI: mongodb://mongodb:27017/userdb



gatewayservice:
container_name: gatewayservice-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3a/gatewayservice:latest
Expand All @@ -73,6 +89,7 @@ services:
- userservice
- authservice
- generatorservice
- statisticsservice
- questionservice
ports:
- "8000:8000"
Expand All @@ -81,9 +98,11 @@ services:
environment:
AUTH_SERVICE_URL: http://authservice:8002
USER_SERVICE_URL: http://userservice:8001
STATS_SERVICE_URL: http://statisticsservice:8006
GENERATOR_SERVICE_URL: http://generatorservice:8003
QUESTION_SERVICE_URL: http://questionservice:8004


webapp:
container_name: webapp-${teamname:-defaultASW}
image: ghcr.io/arquisoft/wiq_es3a/webapp:latest
Expand All @@ -93,6 +112,8 @@ services:
- gatewayservice
ports:
- "3000:3000"
environment:
GATEWAY_SERVICE_URL: http://gatewayservice:8000

prometheus:
image: prom/prometheus
Expand Down Expand Up @@ -135,4 +156,4 @@ volumes:

networks:
mynetwork:
driver: bridge
driver: bridge
22 changes: 22 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ const port = 8000;

const authServiceUrl = process.env.AUTH_SERVICE_URL || 'http://localhost:8002';
const userServiceUrl = process.env.USER_SERVICE_URL || 'http://localhost:8001';
const statisticssServiceUrl = process.env.STATS_SERVICE_URL || 'http://localhost:8006';
const generatorServiceUrl = process.env.GENERATOR_SERVICE_URL || 'http://localhost:8003';
const questionServiceUrl = process.env.QUESTION_SERVICE_URL || 'http://localhost:8004';


app.use(cors());
app.use(express.json());

Expand Down Expand Up @@ -57,6 +59,13 @@ app.get('/generate-question', async (req, res) => {
}
});


app.get('/statistics', async (req, res) => {
try {
const questionResponse = await axios.get(statisticssServiceUrl+'/statistics', {
params: req.query,
});

app.get('/questions', async (req, res) => {
try {
// Forward the get questions request to the question service
Expand All @@ -68,6 +77,18 @@ app.get('/questions', async (req, res) => {
});


app.post('/addStatistic', async (req, res) => {
try {
const questionResponse = await axios.post(statisticssServiceUrl+'/addStatistic',
req.body,
);
res.json(questionResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});


// Read the OpenAPI YAML file synchronously
openapiPath='./openapi.yaml'
if (fs.existsSync(openapiPath)) {
Expand All @@ -84,6 +105,7 @@ if (fs.existsSync(openapiPath)) {
console.log("Not configuring OpenAPI. Configuration file not present.")
}


// 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 c398c31

Please sign in to comment.