Skip to content
Snippets Groups Projects
infrastructure.js 941 B
Newer Older
const express = require('express');

const infrastructureApp = express.Router();

const libs = `${process.cwd()}/libs`;

const log = require(`${libs}/log`)(module);

const squel = require('squel');

const query = require(`${libs}/middlewares/query`);

const response = require(`${libs}/middlewares/response`);

const ReqQueryFields = require(`${libs}/middlewares/reqQueryFields`);

const config = require(`${libs}/config`); 

const cache = require('apicache').options({ debug: config.debug, statusCodes: {include: [200]} }).middleware;

let rqf = new ReqQueryFields();

infrastructureApp.use(cache('15 day'));

rqf.addField({
    name: 'filter',
    field: false,
    where: true
}).addField({
    name: 'dims',
    field: true,
    where: false
})
//TODO: add rqf values

infrastructureApp.get('/', rqf.parse(), (req, res, next) => {
    
    next();
}, rqf.build(), query, response('infrastructure'));

module.exports = infrastructureApp;