Skip to content

Commit

Permalink
Merge pull request #146 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
AbelMH1 authored May 2, 2024
2 parents a4788c8 + fffbb23 commit e81358c
Show file tree
Hide file tree
Showing 30 changed files with 5,237 additions and 1,407 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ jobs:
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix apisgatewayservice test -- --coverage
- run: npm --prefix questionsservice/questiongeneratorservice test -- --coverage
# - run: npm --prefix questionsservice/wikidataExtractor test -- --coverage
- run: npm --prefix questionsservice/wikidataExtractor test -- --coverage

- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
- run: npm --prefix gameservice test -- --coverage
- run: npm --prefix apisgatewayservice test -- --coverage
- run: npm --prefix questionsservice/questiongeneratorservice test -- --coverage
# - run: npm --prefix questionsservice/wikidataExtractor test -- --coverage
- run: npm --prefix questionsservice/wikidataExtractor test -- --coverage

- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
Expand Down
35 changes: 32 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,48 @@
# wiq_es6c

## Contributors
<div align="center">

| Contributor | Contact |
| ------------- | ------------- |
| Liliana Suárez Díaz | <a href="https://github.com/uo288574"><img src="https://img.shields.io/badge/uo288574-Liliana Suárez-green"></a> |
| Marco Quintana García | <a href="https://github.com/marco-qg"><img src="https://img.shields.io/badge/marcoqg-Marco Quintana-red"></a> |
| Abel Menéndez Hernández | <a href="https://github.com/AbelMH1"><img src="https://img.shields.io/badge/AbelMH1-Abel Menéndez-purple"></a> |
| Marcos Barril Villaverde | <a href="https://github.com/MarcosBarrilVillaverde"><img src="https://img.shields.io/badge/MarcosBarrilVillaverde-Marcos Barril-yellow"></a> |
| Alejandro García Mansilla | <a href="https://github.com/alegarman2002"><img src="https://img.shields.io/badge/alegarman2002-Alejandro García-blue"></a> |

</div>

## Links
- [WIQEII](http://158.179.212.42:3000)
- [User's API](http://158.179.212.42:8100)
- [/users](http://158.179.212.42:8100/users) -> Información de los usuarios
- [/history/questions](http://158.179.212.42:8100/history/questions) -> Información de las preguntas generadas
- [/usersStats](http://158.179.212.42:8100/usersStats) -> Información de las estadísticas de los usuarios

## Code analisis

<div align="center">

[![Deploy on release](https://github.com/Arquisoft/wiq_es6c/actions/workflows/release.yml/badge.svg)](https://github.com/Arquisoft/wiq_es6c/actions/workflows/release.yml)
[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es6c&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es6c)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Arquisoft_wiq_es6c&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Arquisoft_wiq_es6c)

This is a base repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html).
</div>

This repo is a basic application composed of several components.
## Components

This is a repo for the [Software Architecture course](http://arquisoft.github.io/) in [2023/2024 edition](https://arquisoft.github.io/course2324.html) composed of the following components.

- **Game service**.
- **Gateway service**. Express service that is exposed to the public and serves as a proxy to the two previous ones.
- **Question service**.
- **Store question service**.
- **User service**. Express service that handles the insertion of new users in the system.
- **Auth service**. Express service that handles the authentication of users.
- **User stats service**.
- **Webapp**. React web application that uses the gateway service to allow basic login and new user features.

Both the user and auth service share a Mongo database that is accessed with mongoose.

## Quick start guide

Expand Down
22 changes: 22 additions & 0 deletions apisgatewayservice/apis-gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,28 @@ app.get('/usersStats', async (req, res) => {
}
})

//libraries required for OpenAPI-Swagger
const swaggerUi = require('swagger-ui-express');
const fs = require("fs")
const YAML = require('yaml')


// Read the OpenAPI YAML file synchronously
const 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}`);
Expand Down
109 changes: 109 additions & 0 deletions apisgatewayservice/openapi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
openapi: 3.0.0
info:
title: Sample API
version: 1.0.0
paths:
/users:
get:
summary: Get users
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
description: User ID
example: student
createdAt:
type: string
description: Creation date.
example: '2024-03-17T20:47:23.935Z'
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
error:
type: string
/history/questions:
get:
summary: Get history questions
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
pregunta:
type: string
description: The question.
example: ¿Cual es la capital de España?
respuesta_correcta:
type: string
description: The correct answer.
example: Madrid
respuestas_incorrectas:
type: array
items:
type: string
description: The other possible answers.
example: [Paris, Roma, Londres]
createdAt:
type: string
description: Creation date.
example: '2024-03-17T20:47:23.935Z'
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
error:
type: string
/usersStats:
get:
summary: Get users stats
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: array
items:
type: object
properties:
username:
type: string
tpoints:
type: integer
avgpoints:
type: number
ttime:
type: integer
avgtime:
type: number
createdAt:
type: string
'500':
description: Internal server error
content:
application/json:
schema:
type: object
properties:
error:
type: string
Loading

0 comments on commit e81358c

Please sign in to comment.