express-domain

1.0.5 • Public • Published

About

Asynchronous error handler for Express

Installation

npm install express-domain

Usage

var express = require('express')
  , expressDomain = require('express-domain');
 
var app = express()
  .use(expressDomain())
  .use(function(req, res){
    if (Math.random() > 0.5) {
      throw new Error('Simple error');
    }
    setTimeout(function() {
      if (Math.random() > 0.5) {
        throw new Error('Asynchronous error from timeout');
      } else {
        res.end('Hello from Connect!');
      }
    }, 1000);
  })
  .use(function(err, req, res, next) {
    res.end(err.message);
  });
 
app.listen(3000);

Dependencies (0)

    Dev Dependencies (5)

    Package Sidebar

    Install

    npm i express-domain

    Weekly Downloads

    1

    Version

    1.0.5

    License

    none

    Last publish

    Collaborators

    • nook