Skip to content
Snippets Groups Projects
Commit d97493ae authored by Vytor Calixto's avatar Vytor Calixto :space_invader:
Browse files

Add comments to middlewares

parent 54c9edc8
No related branches found
No related tags found
No related merge requests found
...@@ -12,6 +12,12 @@ ...@@ -12,6 +12,12 @@
* app.use(dimensions()) * app.use(dimensions())
*/ */
/**
* This function returns the intersection of two arrays
* @param {array} a [description]
* @param {array} b [description]
* @return {array} [description]
*/
function intersect(a, b) { function intersect(a, b) {
let t; let t;
if (b.length > a.length) { if (b.length > a.length) {
......
...@@ -2,6 +2,12 @@ const libs = `${process.cwd()}/libs`; ...@@ -2,6 +2,12 @@ const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module); const log = require(`${libs}/log`)(module);
const execQuery = require(`${libs}/db/query_exec`); const execQuery = require(`${libs}/db/query_exec`);
/**
* Middleware that executes a query defined by a squel object in req.sql
* @param {Object} req [description]
* @param {Object} res [description]
* @param {Function} next [description]
*/
function query(req, res, next) { function query(req, res, next) {
log.debug(req.sql); log.debug(req.sql);
execQuery(req.sql.text, req.sql.values).then((result) => { execQuery(req.sql.text, req.sql.values).then((result) => {
......
...@@ -2,6 +2,10 @@ const libs = `${process.cwd()}/libs`; ...@@ -2,6 +2,10 @@ const libs = `${process.cwd()}/libs`;
const log = require(`${libs}/log`)(module); const log = require(`${libs}/log`)(module);
const xml = require('js2xmlparser'); const xml = require('js2xmlparser');
/**
* Custom generic middleware used to send api responses
* @param {string} value text to be used in the xml response
*/
function response(value) { function response(value) {
return (req, res, next) => { return (req, res, next) => {
log.debug(req.query.format); log.debug(req.query.format);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment