forked from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #84 from Arquisoft/develop
- Loading branch information
Showing
13 changed files
with
255 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# Use an official Node.js runtime as a parent image | ||
FROM node:20 | ||
|
||
# Set the working directory in the container | ||
WORKDIR /usr/src/retrieveservice | ||
|
||
# Copy package.json and package-lock.json to the working directory | ||
COPY package*.json ./ | ||
|
||
# Install app dependencies | ||
RUN npm install | ||
|
||
# Copy the app source code to the working directory | ||
COPY . . | ||
|
||
# Expose the port the app runs on | ||
EXPOSE 8004 | ||
|
||
# Define the command to run your app | ||
CMD ["node", "retrieve-service.js"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
{ | ||
"name": "retrieveservice", | ||
"version": "1.0.0", | ||
"description": " Retrieve service, in charge of claim the questions information stored on de database", | ||
"main": "service.js", | ||
"scripts": { | ||
"start": "node retrieve-service.js", | ||
"test": "jest" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/arquisoft/wiq_es2b.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/arquisoft/wiq_es2b/issues" | ||
}, | ||
"homepage": "https://github.com/arquisoft/wiq_es2b#readme", | ||
"dependencies": { | ||
"bcrypt": "^5.1.1", | ||
"body-parser": "^1.20.2", | ||
"express": "^4.18.2", | ||
"jsonwebtoken": "^9.0.2", | ||
"mongoose": "^8.0.4" | ||
}, | ||
"devDependencies": { | ||
"jest": "^29.7.0", | ||
"mongodb-memory-server": "^9.1.5", | ||
"supertest": "^6.3.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
const mongoose = require('mongoose'); | ||
|
||
// Crea la base de datos con las columnas especificadas | ||
const questionSchema = new mongoose.Schema({ | ||
question: String, | ||
correctAnswer: String, | ||
incorrectAnswer1: String, | ||
incorrectAnswer2: String, | ||
incorrectAnswer3: String | ||
}); | ||
|
||
const Question = mongoose.model('Question', questionSchema); | ||
|
||
module.exports = Question |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
const express = require('express'); | ||
const mongoose = require('mongoose'); | ||
const Question = require('./questionshistory-model') | ||
|
||
const app = express(); | ||
const port = 8004; | ||
|
||
app.use(express.json()); | ||
|
||
const mongoUri = process.env.MONGODB_URI || 'mongodb://localhost:27017/questiondb'; | ||
mongoose.connect(mongoUri); | ||
|
||
|
||
app.post('/getquestionshistory', async (req, res) => { | ||
const questions = await Question.find({}); | ||
|
||
var solution = []; | ||
questions.forEach(row => { | ||
solution.push([row.question,row.correctAnswer,row.incorrectAnswer1,row.incorrectAnswer2,row.incorrectAnswer3]); | ||
}); | ||
|
||
res.status(200).json(solution); | ||
}); | ||
|
||
const server = app.listen(port, () => { | ||
console.log(`Creation Service listening at http://localhost:${port}`); | ||
}); | ||
|
||
server.on('close', () => { | ||
mongoose.connection.close(); | ||
}); | ||
|
||
module.exports = server; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.