Persist reports in memory
This commit is contained in:
@ -2,10 +2,12 @@ var path = require('path');
|
||||
var app = require('express')();
|
||||
var bodyParser = require('body-parser');
|
||||
var cors = require('cors');
|
||||
var createStore = require('./store');
|
||||
|
||||
module.exports.run = function(worker) {
|
||||
var httpServer = worker.httpServer;
|
||||
var scServer = worker.scServer;
|
||||
var store;
|
||||
|
||||
httpServer.on('request', app);
|
||||
|
||||
@ -20,8 +22,11 @@ module.exports.run = function(worker) {
|
||||
app.use(bodyParser.json());
|
||||
app.post('/', function(req, res) {
|
||||
if (!req.body) return res.status(404).end();
|
||||
scServer.exchange.publish('log', req.body);
|
||||
res.send('OK');
|
||||
if (!store) store = createStore(worker.options);
|
||||
store.add(req.body).then(function(r) {
|
||||
scServer.exchange.publish('log', req.body);
|
||||
res.send({ id: r.id });
|
||||
});
|
||||
});
|
||||
|
||||
scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (req, next) {
|
||||
|
Reference in New Issue
Block a user