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

✨ Manejo de tiempo agotado con modal #96

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
f179ce6
Added fetch-depth 0
labra Jan 22, 2024
ff5fadb
Update sonar-project.properties
ExarcaFidalgo Jan 22, 2024
3a7d874
Update README.md
ExarcaFidalgo Jan 22, 2024
f67f94d
Update sonar-project.properties
ExarcaFidalgo Jan 22, 2024
caa267f
Update README.md
ExarcaFidalgo Jan 22, 2024
72fedaf
Fixing some old-fashioned code in the actions and README.md file
augustocristian Jan 23, 2024
09590d8
0 por es6b
ExarcaFidalgo Jan 23, 2024
d7948e9
0 por es6c
ExarcaFidalgo Jan 23, 2024
2f84702
Merge pull request #3 from Arquisoft/dev_fixcomposeandactions
pglez82 Jan 23, 2024
d658968
Adding the .env to the service deployment
augustocristian Jan 23, 2024
d6ec049
Merge pull request #4 from Arquisoft/ft_Addenvfiledeployment
augustocristian Jan 23, 2024
f7c5893
Adding -O to wget to overwrite existing files
augustocristian Jan 23, 2024
88c299b
Changed welcome message and some devDependencies
labra Jan 26, 2024
fa9aec3
Merge branch 'master' of https://github.com/Arquisoft/wiq_0
labra Jan 26, 2024
dbaea69
Merge branch 'master' into master
ExarcaFidalgo Jan 26, 2024
dc74163
Revert "Merge branch 'master' into master"
ExarcaFidalgo Jan 26, 2024
a50371b
Merge branch 'master' into master
ExarcaFidalgo Jan 26, 2024
e049274
Revert "Merge branch 'master' of https://github.com/Arquisoft/wiq_0"
ExarcaFidalgo Jan 26, 2024
e9278f2
Expiando mis pecados
ExarcaFidalgo Jan 26, 2024
1f0cbfb
Minor fixes to tear-down the container
augustocristian Feb 12, 2024
f4f8efb
Merge pull request #6 from Arquisoft/ft_solveproblemcompose
labra Feb 12, 2024
dce1d3f
Merge branch 'develop', remote-tracking branch 'origin' into pablo
uo264915 Mar 13, 2024
304dd15
Adding --pull always to the deployment command to force image downloa…
augustocristian Mar 14, 2024
227b3f5
Added OpenAPI specification for wiq_0 gateway service (#17)
augustocristian Mar 17, 2024
6e9d94e
Sync package.json with package-lock.json (#18)
augustocristian Mar 17, 2024
789b3f2
Adding some examples to the OpenAPI spec (#19)
augustocristian Mar 17, 2024
7c88c7e
Fixing OpenAPI E2E Tests
pglez82 Mar 18, 2024
7b11b83
Merge remote-tracking branch 'origin' into pablo
uo264915 Mar 18, 2024
98b87b9
:sparkles: Temporizador añadido con cuenta atrás de 20 segundos
coral2742 Mar 18, 2024
997e0bc
Small local changes
labra Mar 19, 2024
8d15121
Sincronización con develop (24 Marzo)
uo264915 Mar 24, 2024
fef70b4
Merge de develop
uo264915 Mar 24, 2024
492a216
[APP] Implementación interfaz de MainPage Arquisoft/wiq_es2b#76
uo264915 Mar 28, 2024
d9d57fb
Sincronización con develop (28 Marzo)
uo264915 Mar 28, 2024
cbc574d
cambios css
uo264915 Mar 28, 2024
2bae69f
Arreglando fallo bucle infinito en peticiones
baraganio Mar 28, 2024
fc2de3a
Merge branch 'develop' into pablo
uo264915 Mar 30, 2024
78acdb3
Finalizacion del juego y mostrar puntuacion
uo264915 Mar 30, 2024
ada6418
Merge pull request #89 from Arquisoft/pablo
uo264915 Mar 30, 2024
2254984
Merge branch 'develop' into ray
UO290054 Mar 31, 2024
f540641
Merge branch 'develop' into ray
UO290054 Mar 31, 2024
7d11d8a
Historial de usuario implementado + errores varios
UO290054 Apr 1, 2024
e80c658
Implementación CSS de HistoricalData y otros cambios
uo264915 Apr 1, 2024
b33132f
Ajustes Histotico del usuario
UO290054 Apr 1, 2024
3613362
Merge branch 'master' into ray
UO290054 Apr 1, 2024
e197ad2
Merge pull request #92 from Arquisoft/ray
UO290054 Apr 1, 2024
2c0cf10
:sparkles: Modificaciones del reloj de juego
coral2742 Apr 1, 2024
f71db54
Sincronizacion con master (1 abril)
uo264915 Apr 1, 2024
11ffd55
:sparkles: Temporizador añadido
coral2742 Apr 3, 2024
0e50e0e
:sparkles: Especificación de API con Openapi
coral2742 Apr 3, 2024
b779725
Merge from develop
baraganio Apr 4, 2024
f86c7a3
Arreglando las respuestas que no traen nombre (traen la etiqueta Q1234)
baraganio Apr 4, 2024
af050db
Merge branch 'develop' of https://github.com/Arquisoft/wiq_es2b into …
uo264915 Apr 7, 2024
3cc157c
Resolucion de problemas fin de partida
uo264915 Apr 7, 2024
92cce23
Resolucion problemas fin de partida
uo264915 Apr 7, 2024
c7052a5
Merge pull request #95 from Arquisoft/pablo
uo264915 Apr 7, 2024
e0cdd4f
sparkles: Cambios en temporizador
coral2742 Apr 7, 2024
3e8ddb7
:sparkles: Pequeños cambios en temporizador
UO285240 Apr 7, 2024
12687e4
Merge branch 'develop' into coral
UO285240 Apr 7, 2024
d0fb796
:sparkles: Temporizador solucionado
UO285240 Apr 7, 2024
838e093
:sparkles: 6 preguntas por partida
UO285240 Apr 7, 2024
4983926
:sparkles: Pregunta incorrecta si pasa de tiempo
UO285240 Apr 7, 2024
f2f4236
:sparkles: Manejo de tiempo agotado con modal
coral2742 Apr 7, 2024
4573723
Cambiando alguna peticiones post por get
baraganio Apr 7, 2024
1d8a5fa
Merge con develop
baraganio Apr 7, 2024
597fe01
Merge con develop
baraganio Apr 7, 2024
668b401
Update 06_runtime_view
baraganio Apr 7, 2024
881154f
Merge pull request #98 from Arquisoft/carlos
baraganio Apr 7, 2024
cfd29cd
Arreglos de warnings
uo264915 Apr 7, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v4
with:
node-version: 20
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ jobs:
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Update OpenAPI configuration
run: |
DEPLOY_HOST=${{ secrets.DEPLOY_HOST }}
sed -i "s/SOMEIP/${DEPLOY_HOST}/g" gatewayservice/openapi.yaml
- name: Publish to Registry
uses: elgohr/Publish-Docker-Github-Action@v5
with:
Expand All @@ -164,3 +168,5 @@ jobs:
wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/.env -O .env
docker compose --profile prod down
docker compose --profile prod up -d --pull always


19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ and launch it with docker compose:
docker compose --profile dev up --build
```

and tear it down:

```sh
docker compose --profile dev down
```

### Starting Component by component

First, start the database. Either install and run Mongo or run it using docker:
Expand Down Expand Up @@ -100,15 +106,18 @@ deploy:
user: ${{ secrets.DEPLOY_USER }}
key: ${{ secrets.DEPLOY_KEY }}
command: |
wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_es2b/master/.env -O .env
docker compose down
docker compose --profile prod up -d

wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/docker-compose.yml -O docker-compose.yml
wget https://raw.githubusercontent.com/arquisoft/wiq_0/master/.env -O .env
docker compose --profile prod down
docker compose --profile prod up -d --pull always

```

This action uses three secrets that must be configured in the repository:
- DEPLOY_HOST: IP of the remote machine.
- DEPLOY_USER: user with permission to execute the commands in the remote machine.
- DEPLOY_KEY: key to authenticate the user in the remote machine.

Note that this action logs in the remote machine and downloads the docker-compose file from the repository and launches it. Obviously, previous actions have been executed which have uploaded the docker images to the GitHub Packages repository.
Note that this action logs in the remote machine and downloads the docker-compose file from the repository and launches it.
Obviously, previous actions have been executed which have uploaded the docker images to the GitHub Packages repository.
48 changes: 48 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
const axios = require('axios');
const cors = require('cors');
const promBundle = require('express-prom-bundle');
//libraries required for OpenAPI-Swagger
const swaggerUi = require('swagger-ui-express');
const fs = require("fs")
const YAML = require('yaml')


const app = express();
const port = 8000;
Expand Down Expand Up @@ -41,6 +46,29 @@
}
});


app.post('/addgame', async (req, res) => {
try {
const userResponse = await axios.post(userServiceUrl+'/addgame', req.body);
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});


app.get('/getgamehistory/:username', async (req, res) => {
try {
const username = req.params.username;
const userResponse = await axios.get(`${userServiceUrl}/getgamehistory/${username}`);

Check warning

Code scanning / SonarCloud

Server-side requests should not be vulnerable to forging attacks

<!--SONAR_ISSUE_KEY:AY66SO0pbroSQlYRTrNW-->Change this code to not construct the URL from user-controlled data. <p>See more on <a href="https://sonarcloud.io/project/issues?id=Arquisoft_wiq_es2b&issues=AY66SO0pbroSQlYRTrNW&open=AY66SO0pbroSQlYRTrNW&pullRequest=96">SonarCloud</a></p>
res.json(userResponse.data);
} catch (error) {
res.status(error.response.status).json({ error: error.response.data.error });
}
});



app.post('/createquestion', async (req, res) => {
try {
// Create a petition to the URL (le llegará a creation-service.js) with the option /createquestion and the req.body params
Expand All @@ -63,9 +91,29 @@
}
});



// Read the OpenAPI YAML file synchronously
openapiPath='./openapi.yaml'
if (fs.existsSync(openapiPath)) {
const file = fs.readFileSync(openapiPath, 'utf8');

// Parse the YAML content into a JavaScript object representing the Swagger document
const swaggerDocument = YAML.parse(file);

// Serve the Swagger UI documentation at the '/api-doc' endpoint
// This middleware serves the Swagger UI files and sets up the Swagger UI page
// It takes the parsed Swagger document as input
app.use('/api-doc', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
} else {
console.log("Not configuring OpenAPI. Configuration file not present.")
}


// Start the gateway service
const server = app.listen(port, () => {
console.log(`Gateway Service listening at http://localhost:${port}`);
});


module.exports = server
233 changes: 233 additions & 0 deletions gatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,233 @@
openapi: 3.0.0
info:
title: Gatewayservice API
description: Gateway OpenAPI specification.
version: 0.2.0
servers:
- url: http://localhost:8000
description: Development server
- url: http://SOMEIP:8000
description: Production server
paths:
/adduser:
post:
summary: Add a new user to the database.
operationId: addUser
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
username:
type: string
description: User ID.
example: student
password:
type: string
description: User password.
example: pass
responses:
'200':
description: User added successfully.
content:
application/json:
schema:
type: object
properties:
username:
type: string
description: User ID
password:
type: string
description: Hashed password
example: $2b$10$ZKdNYLWFQxzt5Rei/YTc/OsZNi12YiWz30JeUFHNdAt7MyfmkTuvC
_id:
type: string
description: Identification
example: 65f756db3fa22d227a4b7c7d
createdAt:
type: string
description: Creation date.
example: '2024-03-17T20:47:23.935Z'
___v:
type: integer
example: '0'
'400':
description: Failed to add user.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error information.
example: getaddrinfo EAI_AGAIN mongodb
/health:
get:
summary: Check the health status of the service.
operationId: checkHealth
responses:
'200':
description: Service is healthy.
content:
application/json:
schema:
type: object
properties:
status:
type: string
description: Health status.
example: OK
/login:
post:
summary: Log in to the system.
operationId: loginUser
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
username:
type: string
description: User ID.
example: student
password:
type: string
description: User password.
example: pass
responses:
'200':
description: Login successful. Returns user token, username, and creation date.
content:
application/json:
schema:
type: object
properties:
token:
type: string
description: User token.
example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VySWQiOiI2NWY3NTZkYjNmYTIyZDIyN2E0YjdjN2QiLCJpYXQiOjE3MTA3MDg3NDUsImV4cCI6MTcxMDcxMjM0NX0.VMG_5DOyQ4GYlJQRcu1I6ICG1IGzuo2Xuei093ONHxw
username:
type: string
description: Username.
example: student
createdAt:
type: string
description: Creation date.
example: '2024-03-17T20:47:23.935Z'
'401':
description: Invalid credentials.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Shows the error info..
example: Invalid credentials
'500':
description: Internal server error.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error information.
example: Internal Server Error
/addgame:
post:
summary: Add a new game to the database.
operationId: addGame
requestBody:
required: true
content:
application/json:
schema:
type: object
properties:
gameName:
type: string
description: Name of the game.
example: Game1
responses:
'200':
description: Game added successfully.
content:
application/json:
schema:
type: object
properties:
message:
type: string
description: Message indicating success.
example: Game added successfully.
'400':
description: Failed to add game.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error information.
example: Game already exists.


/getgamehistory/{username}:
get:
summary: Get game history for a specific user.
operationId: getGameHistory
parameters:
- name: username
in: path
description: Username for which to retrieve game history.
required: true
schema:
type: string
example: student
responses:
'200':
description: Game history retrieved successfully.
content:
application/json:
schema:
type: array
items:
type: object
properties:
gameId:
type: string
description: ID of the game.
example: 12345
gameName:
type: string
description: Name of the game.
example: Game1
score:
type: integer
description: Score achieved in the game.
example: 100
datePlayed:
type: string
description: Date when the game was played.
example: '2024-03-20T15:00:00Z'
'400':
description: Failed to retrieve game history.
content:
application/json:
schema:
type: object
properties:
error:
type: string
description: Error information.
example: User not found.
Loading