var logger = require('log4js').getLogger(); var mdot = require('./mdot.js'); module.exports = function(app) { var express = require('express'); var mdotRouter = express.Router(); mdotRouter.get('/:id', function(req, res) { console.log(req.headers); var data = {}; logger.debug('mDot-GetData'); if (!req.params.id) { logger.error('MDot','Missing required parameter'); res.status(400).send({ status: 'error', error: 'missing required parameter' }); return; } if (req.query.hasOwnProperty('start') && req.query.hasOwnProperty('start')) { data.start = req.query.start; data.end = req.query.end; } if (req.params.hasOwnProperty('id')) { data.id = req.params.id; mdot.doGet(data) .then((d) => { 'use strict'; res.json(d); }) .catch((e) => { logger.error(e); res.status(500).json({}); }); } }); app.use('/api/mdot/', mdotRouter); };