Extend store API
This commit is contained in:
@ -17,15 +17,15 @@ module.exports.run = function(worker) {
|
||||
app.set('view engine', 'ejs');
|
||||
app.set('views', path.resolve(__dirname, '..', 'views'));
|
||||
|
||||
app.get('*', function(req, res) {
|
||||
res.render('index', { port: worker.options.port });
|
||||
});
|
||||
|
||||
if (logHTTPRequests) {
|
||||
if (typeof logHTTPRequests === 'object') app.use(morgan('combined', logHTTPRequests));
|
||||
else app.use(morgan('combined'));
|
||||
}
|
||||
|
||||
app.get('*', function(req, res) {
|
||||
res.render('index', { port: worker.options.port });
|
||||
});
|
||||
|
||||
app.use(cors({ methods: 'POST' }));
|
||||
app.use(bodyParser.json({ limit: limit }));
|
||||
app.use(bodyParser.urlencoded({ limit: limit, extended: false }));
|
||||
@ -34,7 +34,7 @@ module.exports.run = function(worker) {
|
||||
switch(req.body.op) {
|
||||
case 'get':
|
||||
store.get(req.body.id).then(function(r) {
|
||||
res.send(r[0] || {});
|
||||
res.send(r || {});
|
||||
}).catch(function(error) {
|
||||
console.error(error);
|
||||
res.sendStatus(500)
|
||||
@ -98,7 +98,7 @@ module.exports.run = function(worker) {
|
||||
});
|
||||
socket.on('getReport', function (id, respond) {
|
||||
store.get(id).then(function(data) {
|
||||
respond(null, data[0]);
|
||||
respond(null, data);
|
||||
}).catch(function(error) {
|
||||
console.error(error);
|
||||
});
|
||||
|
Reference in New Issue
Block a user