1.3.0 • Published 7 years ago

debug-error-middleware v1.3.0

Weekly downloads
345
License
MIT
Repository
-
Last release
7 years ago

Express/Koa error handling middleware

Build Status

Apply this debug middleware to display context information in the response to a failed request.

Example Page

Currently we support these two HTTP frameworks:

  • Express
  • Koa

Setup

Never enable the DEBUG middleware in a production environment. This could result in leaking sensitive information (e.g. ENV variables). The middleware throws an error if you try to load it when NODE_ENV is set to "production".

Express

The debug middleware should be loaded first so we can catch errors from all other middleware.

var debugMiddleware = require('debug-error-middleware').express;

var app = express();

if (process.env.NODE_ENV === 'development') {
  app.use(debugMiddleware());
}

Koa

var debugMiddleware = require('debug-error-middleware').koa;

var app = new Koa();

if (process.env.NODE_ENV === 'development') {
  app.use(debugMiddleware());
}

Source Map Support

Even though it is not desirable to run transpiled source code inside the node js runtime, you often do not escape the use of it because of Server Side Rendering applications. debug-error-middleware automatically supports sourcemaps. This will result in stack traces that are easier to interpret. You can disable source map support through a configuration option.

Configuration

The following configuration options are available:

{
  theme: 'okaidia', // The prismjs theme to use
  disabledForXHR: true // Disable the middleware for XHR requests
  disableSourceMapSupport: false // Disables support for sourcemaps
}
1.3.0

7 years ago

1.2.0

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago