Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cambiando random por crypto e intentando solucionar problema del cors #181

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions gatewayservice/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,8 @@ RUN npm install --ignore-scripts
# Copy the app source code to the working directory
COPY . .

ARG API_ORIGIN_URI="http://localhost:3000"
ENV REACT_APP_API_ORIGIN_ENDPOINT=$API_ORIGIN_URI

# Define the command to run your app
CMD ["node", "gateway-service.js"]
10 changes: 7 additions & 3 deletions questions/creationservice/creation-service.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express');
const mongoose = require('mongoose');
const fetch = require('node-fetch');
const crypto = require('crypto');
const Question = require('./creation-model');

const app = express();
Expand Down Expand Up @@ -37,7 +38,8 @@ function getQuestionInfo(info){

// Select 4 random rows of the data
for (let i = 0; i<optionsNumber; i++){
let indexRow = Math.floor(Math.random() * numEles);
//let indexRow = Math.floor(Math.random() * numEles);
let indexRow = crypto.randomInt(0,numEles);
if(info[indexRow].answerLabel.value.charAt(0)=='Q' || info[indexRow].questionObjectLabel.value.charAt(0)=='Q'){
i = i - 1;
}else{
Expand All @@ -48,14 +50,16 @@ function getQuestionInfo(info){
}

// Select the row where it will extract the country and capital
var indexQuestion = Math.floor(Math.random() * optionsNumber);
//var indexQuestion = Math.floor(Math.random() * optionsNumber);
var indexQuestion = crypto.randomInt(0,optionsNumber);
// Store the country choosen and its capital
questionObject= questions[randomQuerySelector] + fourRows[indexQuestion].questionObjectLabel.value + "?";
correctOption = fourRows[indexQuestion].answerLabel.value;
}

function selectRandomQuery(){
randomQuerySelector = Math.floor(Math.random() * queries.length);
//randomQuerySelector = Math.floor(Math.random() * queries.length);
randomQuerySelector = crypto.randomInt(0,queries.length);
}

async function saveQuestion(){
Expand Down