Skip to content

Commit

Permalink
Creo que está arreglado, he movido las peticiones al generador de pre…
Browse files Browse the repository at this point in the history
…guntas a la gateway y cambiado el 8006:8007 a 8007:8007
  • Loading branch information
marco-qg committed Mar 14, 2024
1 parent 80ee6dd commit 0f7269c
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 9 deletions.
3 changes: 2 additions & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ services:
- mongodb_wiki
- storequestionservice
ports:
- "8007:8006"
- "8007:8007"
networks:
- mynetwork
environment:
Expand All @@ -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}
Expand Down
10 changes: 10 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down Expand Up @@ -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}`);
Expand Down
2 changes: 1 addition & 1 deletion questionsservice/questiongeneratorservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions webapp/.env
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
REACT_APP_API_ENDPOINT=http://localhost:8000
CONNECTION_WITH_QUESTIONS_API=http://localhost:8007
REACT_APP_API_ENDPOINT=http://localhost:8000
3 changes: 0 additions & 3 deletions webapp/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion webapp/src/components/FirstGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0f7269c

Please sign in to comment.