diff --git a/docker-compose.yml b/docker-compose.yml index c0dca7ab..94d94ae8 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -59,7 +59,7 @@ services: - mongodb_wiki - storequestionservice ports: - - "8007:8006" + - "8007:8007" networks: - mynetwork environment: @@ -83,6 +83,7 @@ services: AUTH_SERVICE_URL: http://authservice:8002 USER_SERVICE_URL: http://userservice:8001 STORE_QUESTION_SERVICE_URL: http://storequestionservice:8004 + QUESTIONS_GENERATOR_SERVICE_URL: http://questiongeneratorservice:8007 webapp: container_name: webapp-${teamname:-defaultASW} diff --git a/gatewayservice/gateway-service.js b/gatewayservice/gateway-service.js index 9a969b11..4d8074ad 100644 --- a/gatewayservice/gateway-service.js +++ b/gatewayservice/gateway-service.js @@ -9,6 +9,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 storeQuestionsServiceUrl = process.env.STORE_QUESTION_SERVICE_URL || 'http://localhost:8004' +const questionsGeneratorServiceUrl = process.env.QUESTIONS_GENERATOR_SERVICE_URL || 'http://localhost:8007' app.use(cors()); app.use(express.json()); @@ -51,6 +52,15 @@ app.get('/history/questions', async (req, res) => { } }) +app.get(`/questions`, async (req, res) => { + try { + const response = await axios.get(questionsGeneratorServiceUrl+`/questions`); + 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}`); diff --git a/questionsservice/questiongeneratorservice/Dockerfile b/questionsservice/questiongeneratorservice/Dockerfile index 1e9335e0..d5f0af0b 100644 --- a/questionsservice/questiongeneratorservice/Dockerfile +++ b/questionsservice/questiongeneratorservice/Dockerfile @@ -14,7 +14,7 @@ RUN npm install COPY . . # Expose the port the app runs on -EXPOSE 8006 +EXPOSE 8007 # Define the command to run your app CMD ["node", "questiongenerator-service.js"] diff --git a/questionsservice/questiongeneratorservice/questiongenerator-service.js b/questionsservice/questiongeneratorservice/questiongenerator-service.js index b59b0c80..c8ddd488 100644 --- a/questionsservice/questiongeneratorservice/questiongenerator-service.js +++ b/questionsservice/questiongeneratorservice/questiongenerator-service.js @@ -5,7 +5,7 @@ const mongoose = require('mongoose'); const { Question } = require('./questiongenerator-model') const app = express(); -const port = 8006; +const port = 8007; const questionHistoryServiceUrl = process.env.STORE_QUESTION_SERVICE_URL || 'http://localhost:8004'; diff --git a/webapp/.env b/webapp/.env index b816b0a1..c810bde7 100644 --- a/webapp/.env +++ b/webapp/.env @@ -1,2 +1 @@ -REACT_APP_API_ENDPOINT=http://localhost:8000 -CONNECTION_WITH_QUESTIONS_API=http://localhost:8007 \ No newline at end of file +REACT_APP_API_ENDPOINT=http://localhost:8000 \ No newline at end of file diff --git a/webapp/Dockerfile b/webapp/Dockerfile index c23d62fa..3cbad8b7 100644 --- a/webapp/Dockerfile +++ b/webapp/Dockerfile @@ -9,9 +9,6 @@ RUN npm install ARG API_URI="http://localhost:8000" ENV REACT_APP_API_ENDPOINT=$API_URI -ARG QUESTIONS_API="http://localhost:8007" -ENV CONNECTION_WITH_QUESTIONS_API=$QUESTIONS_API - #Create an optimized version of the webapp RUN npm run build RUN npm install serve diff --git a/webapp/src/components/FirstGame.js b/webapp/src/components/FirstGame.js index 5b9dc84d..ece75887 100644 --- a/webapp/src/components/FirstGame.js +++ b/webapp/src/components/FirstGame.js @@ -6,7 +6,7 @@ import axios from 'axios'; import { useNavigate, useLocation } from 'react-router-dom'; -const apiEndpoint = process.env.CONNECTION_WITH_QUESTIONS_API || 'http://localhost:8007'; +const apiEndpoint = process.env.REACT_APP_API_ENDPOINT|| 'http://localhost:8000'; const Quiz = () => { const navigation = useNavigate(); // AƱade esto