all files / raven-node/lib/middleware/ connect.js

50% Statements 5/10
0% Branches 0/4
0% Functions 0/3
50% Lines 5/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25                                       
'use strict';
 
var Raven = require('../client');
 
// Legacy support
var connectMiddleware = function (client) {
  return connectMiddleware.errorHandler(client);
};
 
// Error handler. This should be the last item listed in middleware, but
// before any other error handlers.
connectMiddleware.errorHandler = function (client) {
  client = client instanceof Raven.Client ? client : new Raven.Client(client);
  return client.errorHandler();
};
 
// Ensures asynchronous exceptions are routed to the errorHandler. This
// should be the **first** item listed in middleware.
connectMiddleware.requestHandler = function (client) {
  client = client instanceof Raven.Client ? client : new Raven.Client(client);
  return client.requestHandler();
};
 
module.exports = connectMiddleware;