Skip to content

Commit

Permalink
Estadisticas en proceso
Browse files Browse the repository at this point in the history
  • Loading branch information
uo276026 committed Mar 27, 2024
1 parent aa39cee commit f1b9442
Show file tree
Hide file tree
Showing 12 changed files with 601 additions and 95 deletions.
18 changes: 18 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,24 @@ app.get('/pregunta', async (req, res) => {
}
});

app.get('/updateCorrectAnswers', async (req, res) => {
console.log("prueba")
const { username } = req.body;
try {
const user = await User.findOne({ username });
if (!user) {
return res.status(404).json({ success: false, message: 'Usuario no encontrado' });
}
// Incrementa las respuestas correctas del usuario
user.correctAnswers += 1;
await user.save();
return res.status(200).json({ success: true, message: 'Respuesta correcta actualizada con éxito' });
} catch (error) {
console.error('Error al actualizar la respuesta correcta:', error);
return res.status(500).json({ success: false, message: 'Error al actualizar la respuesta correcta' });
}
});

// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
Expand Down
13 changes: 13 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{
"devDependencies": {
"@babel/plugin-proposal-private-property-in-object": "^7.21.11"
},
"dependencies": {
"path-browserify": "^1.0.1"
}
}
2 changes: 1 addition & 1 deletion userservice/authservice/auth-service.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const request = require('supertest');
const { MongoMemoryServer } = require('mongodb-memory-server');
const bcrypt = require('bcrypt');
const User = require('./auth-model');
const User = require('../../webapp/src/model/auth-model');

let mongoServer;
let app;
Expand Down
2 changes: 1 addition & 1 deletion userservice/userservice/user-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const express = require('express');
const mongoose = require('mongoose');
const bcrypt = require('bcrypt');
const bodyParser = require('body-parser');
const User = require('./user-model')
const User = require('../../webapp/src/model/auth-model');

const app = express();
const port = 8001;
Expand Down
Loading

0 comments on commit f1b9442

Please sign in to comment.