Return error in request
This commit is contained in:
@ -23,10 +23,14 @@ module.exports.run = function(worker) {
|
||||
app.post('/', function(req, res) {
|
||||
if (!req.body) return res.status(404).end();
|
||||
if (!store) store = createStore(worker.options);
|
||||
store.add(req.body).then(function(r) {
|
||||
scServer.exchange.publish('log', req.body);
|
||||
res.send({ id: r.id });
|
||||
});
|
||||
|
||||
switch(req.body.op) {
|
||||
default:
|
||||
store.add(req.body).then(function(r) {
|
||||
scServer.exchange.publish('log', req.body);
|
||||
res.send({ id: r.id, error: r.error });
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
scServer.addMiddleware(scServer.MIDDLEWARE_EMIT, function (req, next) {
|
||||
|
Reference in New Issue
Block a user