mdot_server/lib/mdot/api.js

48 lines
955 B
JavaScript
Raw Normal View History

2016-08-08 10:46:31 +00:00
var logger = require('log4js').getLogger();
var util = require('util');
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');
logger.debug(req);
if (!req.params.id) {
logger.error('MDot','Missing required paramter');
res.status(400).send({
status: 'error',
error: 'missing required parameter'
});
return;
}
logger.debug(req.params.id);
if (req.params.hasOwnProperty('id')) {
data.id = req.params.id;
logger.debug(data);
mdot.doGet()
.then(() => {
'use strict';
console.log('outside the promise');
});
//logger.debug(util.inspect(mdot,{showHidden:true}));
}
});
app.use('/api/mdot/', mdotRouter);
};