Skip to content

Commit

Permalink
chore(lint): fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
WikiRik committed Nov 25, 2020
1 parent 6a01927 commit af8e6f9
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 28 deletions.
1 change: 0 additions & 1 deletion lib/info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
'use strict';
const os = require('os');

// Assuming by default that we run in 'development' environment, if no
Expand Down
13 changes: 7 additions & 6 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const express = require('express');
const router = require('express-promise-router');
const bodyParser = require('body-parser');
const boolParser = require('express-query-boolean');
const swaggerJSDoc = require('swagger-jsdoc');

const morgan = require('./morgan');
const db = require('./sequelize');
Expand Down Expand Up @@ -55,18 +56,18 @@ process.on('unhandledRejection', (err) => {
}
});

const swaggerJSDoc = require('swagger-jsdoc');
const options = {}; // (1/3) stupid gimmick because fuck the library lol
options.definition = require('./swaggerDef.js'); // (2/3) cli options are slightly different
options.apis = require('./swaggerDef.js').apis; // (3/3) so i have to make this gimmick
options.apis = require('./swaggerDef.js').apis;
// (3/3) so i have to make this gimmick
const swaggerSpec = swaggerJSDoc(options); // Initialize swagger-jsdoc -> returns validated swagger spec in json format

// Endpoints not requiring authorization.
GeneralRouter.get('/api-docs.json', (req, res) => { // mini-route to retrieve the docs
log.info('request coming from ' + req.ip + ' to ' + req.hostname);
res.setHeader('Content-Type', 'application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
res.status(200).send(swaggerSpec);
log.info('request coming from ' + req.ip + ' to ' + req.hostname);
res.setHeader('Content-Type', 'application/json');
res.setHeader('Access-Control-Allow-Origin', '*');
res.status(200).send(swaggerSpec);
});

GeneralRouter.get('/healthcheck', middlewares.healthcheck);
Expand Down
35 changes: 17 additions & 18 deletions lib/swaggerDef.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,24 @@
'use strict';
const config = require('../config');
const serverInfo = require('./info.js');

module.exports = {
info: {
info: {
// API informations (required)
title: serverInfo.name, // Title (required)
version: serverInfo.version, // Version (required)
description: serverInfo.description, // Description (optional)
termsOfService: "https://my.aegee.eu/legal/simple",
license: {
name: "Apache 2.0",
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
title: serverInfo.name, // Title (required)
version: serverInfo.version, // Version (required)
description: serverInfo.description, // Description (optional)
termsOfService: 'https://my.aegee.eu/legal/simple',
license: {
name: 'Apache 2.0',
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
}
},
// host, // Host (optional) -- automatically taken who's serving this docs
apis: ['middlewares/*.js'], // where are the files with the comments
basePath: config.basePath, // Base path (optional)
schemes: ['http'],
externalDocs: {
description: 'Find out more about MyAEGEE',
url: 'https://myaegee.atlassian.net/wiki/spaces/GENERAL/overview'
}
},
// host, // Host (optional) -- automatically taken who's serving this docs
apis: ['middlewares/*.js'], // where are the files with the comments
basePath: config.basePath, // Base path (optional)
schemes: ['http'],
externalDocs: {
description: "Find out more about MyAEGEE",
url: "https://myaegee.atlassian.net/wiki/spaces/GENERAL/overview"
}
};
5 changes: 2 additions & 3 deletions middlewares/generic.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ exports.errorHandler = (err, req, res, next) => {
return errors.makeInternalError(res, err);
};

//////////////////////////////////////////////////////////////
/// ///////////////////////////////////////////////////////////
// GENERIC SWAGGER DEFINITION: 'tags' and example responses
/**
* @swagger
Expand Down Expand Up @@ -349,5 +349,4 @@ exports.errorHandler = (err, req, res, next) => {
* location: "Tallahassee, Florida"
* eventID: "rtctallahassee19"
*/
//////////////////////////////////////////////////////////////

/// ///////////////////////////////////////////////////////////
98 changes: 98 additions & 0 deletions package-lock.json

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

0 comments on commit af8e6f9

Please sign in to comment.