diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 408f9852..f047aef9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -22,8 +22,9 @@ jobs: - run: npm --prefix webapp ci - run: npm --prefix users/authservice test -- --coverage - run: npm --prefix users/userservice test -- --coverage - - run: npm --prefix gameservice test -- --coverage + - run: npm --prefix question_generator test - run: npm --prefix questionservice test -- --coverage + - run: npm --prefix gameservice test -- --coverage - run: npm --prefix gatewayservice test -- --coverage - run: npm --prefix webapp test -- --coverage - name: Analyze with SonarCloud diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 692e04e8..7cc6023b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: - run: npm --prefix webapp ci - run: npm --prefix users/authservice test -- --coverage - run: npm --prefix users/userservice test -- --coverage + - run: npm --prefix question_generator test - run: npm --prefix questionservice test -- --coverage - run: npm --prefix gameservice test -- --coverage - run: npm --prefix gatewayservice test -- --coverage @@ -113,7 +114,7 @@ jobs: - name: Publish to Registry uses: elgohr/Publish-Docker-Github-Action@v5 with: - name: arquisoft/wiq_es3b/question_generator + name: arquisoft/wiq_es3b/questiongenerationservice username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} registry: ghcr.io @@ -184,4 +185,4 @@ jobs: wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/docker-compose.yml -O docker-compose.yml wget https://raw.githubusercontent.com/arquisoft/wiq_es3b/master/.env -O .env docker compose down - docker compose --profile prod up -d + docker compose --profile prod up -d \ No newline at end of file diff --git a/README.md b/README.md index 25b02d26..e64cc4fe 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ This repo is a basic application composed of several components. Both the user and auth service share a Mongo database that is accessed with mongoose. +App Link: http://172.187.201.54:3000/ + ## Quick start guide ### Using docker diff --git a/docker-compose.yml b/docker-compose.yml index 4683cd54..46f9843d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -109,6 +109,8 @@ services: - gatewayservice ports: - "3000:3000" + environment: + GATEWAY_SERVICE_URL: http://gatewayservice:8000 #volumes: #- ./webapp:/app diff --git a/question_generator/questionGenerationService.test.js b/question_generator/questionGenerationService.test.js index 2b00f2c5..9a00e998 100644 --- a/question_generator/questionGenerationService.test.js +++ b/question_generator/questionGenerationService.test.js @@ -18,7 +18,7 @@ describe('Question generation service', () => { expect(response.body).toHaveProperty('question'); expect(response.body).toHaveProperty('correct'); expect(response.body).toHaveProperty('incorrects'); - },10000); + },100000); it('should forward create question request to question generation service', async () => { const response = await request(app) @@ -28,7 +28,7 @@ describe('Question generation service', () => { expect(response.body).toHaveProperty('question'); expect(response.body).toHaveProperty('correct'); expect(response.body).toHaveProperty('incorrects'); - },10000); + },100000); it('should forward create question request to question generation service', async () => { const response = await request(app) @@ -38,5 +38,5 @@ describe('Question generation service', () => { expect(response.body).toHaveProperty('question'); expect(response.body).toHaveProperty('correct'); expect(response.body).toHaveProperty('incorrects'); - },10000); + },100000); }); diff --git a/question_generator/questionTemplate.js b/question_generator/questionTemplate.js index 4211e196..fced6815 100644 --- a/question_generator/questionTemplate.js +++ b/question_generator/questionTemplate.js @@ -7,9 +7,9 @@ function loadData(){ sportTemplates.loadData() } const templates=[ - planetsTemplates.getRandomQuestion, - geographyTemplates.getRandomQuestion, - sportTemplates.getRandomQuestion + ...Array(1).fill(planetsTemplates.getRandomQuestion), + ...Array(4).fill(geographyTemplates.getRandomQuestion), + ...Array(4).fill(sportTemplates.getRandomQuestion) ] module.exports.getRandomQuestion = () => templates[Math.floor(Math.random()*templates.length)](); diff --git a/webapp/src/components/Game.jsx b/webapp/src/components/Game.jsx index 27f9b5f4..1dea9ae8 100644 --- a/webapp/src/components/Game.jsx +++ b/webapp/src/components/Game.jsx @@ -7,6 +7,8 @@ import { PostGame } from './PostGame' const N_QUESTIONS = 10 const MAX_TIME = 600; +const gatewayUrl=process.env.REACT_APP_API_ENDPOINT||"http://localhost:8000" + const Question = ({ goTo, setGameFinished }) => { const [question, setQuestion] = useState(''); @@ -21,7 +23,6 @@ const Question = ({ goTo, setGameFinished }) => { const [nQuestion, setNQuestion] = useState(0); const [segundos, setSegundos] = useState(MAX_TIME); - useEffect(() => { const intervalId = setInterval(() => { @@ -32,6 +33,7 @@ const Question = ({ goTo, setGameFinished }) => { }, 1000); return () => clearInterval(intervalId); + // eslint-disable-next-line }, []); const formatTiempo = (segundos) => { @@ -43,7 +45,9 @@ const Question = ({ goTo, setGameFinished }) => { const fetchQuestion = async () => { try { - const response = await fetch('http://localhost:8000/api/questions/create'); + const response = await fetch(`${gatewayUrl}/api/questions/create`, { + method: 'GET' + }); const data = await response.json(); setQuestion(data.question); @@ -116,6 +120,7 @@ const Question = ({ goTo, setGameFinished }) => { useEffect(() => { fetchQuestion(); + // eslint-disable-next-line }, []); return(