Skip to content

Commit

Permalink
Deploying with openapi fixed
Browse files Browse the repository at this point in the history
Mergin develop into master for final release to delivery 3
  • Loading branch information
UO289930 authored Apr 10, 2024
2 parents 305fedc + d829bb5 commit b42ea98
Show file tree
Hide file tree
Showing 7 changed files with 130 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
- uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.0'

- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
Expand Down
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,48 @@ on:
types: [published]

jobs:
unit-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20

- run: npm --prefix gatewayservice ci
- run: npm --prefix webapp ci
- run: npm --prefix wikidataservice ci
- run: npm --prefix users ci

- run: npm --prefix gatewayservice test -- --coverage
- run: npm --prefix webapp test -- --coverage
- run: npm --prefix wikidataservice test -- --coverage
- run: npm --prefix users test -- --coverage
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Analyze with SonarCloud
uses: sonarsource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
e2e-tests:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix wikidataservice install
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e
docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down
3 changes: 1 addition & 2 deletions docs/src/09_architecture_decisions.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ The following table contains the most interesting the design decisions that we h
|ADR4| Docker | Fast deployment, ease of moving/maintaining your applications. Easy as we already have DockerFiles example| We do not have much experience using Docker
|ADR5| PlantUML | Allows drawing diagrams very easily, with a simple syntax.| Does not allow as much control over the exact layout of the elements in the diagram as other tools.
|ADR6| Node.js | For small applications it's a very fast techonology. It's easy to learn and we already know a bit about it| Its performance is reduced with heavy computational tasks
|ADR7| Wikidata API in C# | Better structure and two people knew about the language| Dificulties with deployment, using another editor to run it, problems when committing new files.
|ADR8| Database for questions | Support if wikidata service stops working | New different relational database into the aplication, new api to develop, dependency on the database server we choose to use.
|ADR7| Wikidata API also in Node.js | Better project structure. Same language as users API. Easier for us to deploy it| Its performance is reduced with heavy computational tasks
|===


Expand Down
6 changes: 0 additions & 6 deletions docs/src/11_technical_risks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,6 @@ self-explanatory description, the probability of its occurrence, its impact on t
| High
| Each member will try to maximize its knowledge on some aspect of the project in the first weeks, in order to be able to be something similar to a leader in each one of the posible key aspects of the project.

|*Problems with C#*
| As a team we decided to try .NET to code the API of wikidata.
| High
| High
| The team will practice with the language to be able to do a good job when implementing the back-end.

|*Problems with wikidata*
| The team only used wikidata once before and not even everyone of us.
| High
Expand Down
21 changes: 21 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,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 @@ -99,6 +104,22 @@ async function getQuestions(specificPath, res){
}
}

// 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.")
}

app.get('/*', (_req,res) =>{
res.status(404).json({
status:"not found",
Expand Down
63 changes: 62 additions & 1 deletion gatewayservice/package-lock.json

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

5 changes: 4 additions & 1 deletion gatewayservice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@
"axios": "^1.6.5",
"cors": "^2.8.5",
"express": "^4.18.2",
"express-prom-bundle": "^7.0.0"
"express-prom-bundle": "^7.0.0",
"fs": "^0.0.1-security",
"swagger-ui-express": "^5.0.0",
"yaml": "^2.4.1"
},
"devDependencies": {
"jest": "^29.7.0",
Expand Down

0 comments on commit b42ea98

Please sign in to comment.