Skip to content

Commit

Permalink
Merge pull request #174 from Arquisoft/separate_api_deployment
Browse files Browse the repository at this point in the history
Separate api deployment
  • Loading branch information
UO289930 authored Apr 10, 2024
2 parents 71c7ddf + 754f1d7 commit d829bb5
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 5 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
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 d829bb5

Please sign in to comment.