mirror of
https://gitlab.silvrtree.co.uk/martind2000/mdot_server.git
synced 2025-01-30 23:10:15 +00:00
de8af028e5
Before convertion of graph object to use AMCharts..
52 lines
1.1 KiB
JavaScript
52 lines
1.1 KiB
JavaScript
'use strict';
|
|
var logger = require('log4js').getLogger();
|
|
var mdot = require('./mdot.js');
|
|
|
|
var db = require('../server/db-connector').dbConnection;
|
|
|
|
var dbMdot = require('../server/db-mdot')(db);
|
|
|
|
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;
|
|
|
|
dbMdot.doGet(data)
|
|
.then((d) => {
|
|
res.json({events:d});
|
|
})
|
|
.catch((e) => {
|
|
logger.error(e);
|
|
res.status(500).json({});
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
app.use('/apiv2/mdot/', mdotRouter);
|
|
};
|
|
|