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);

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.5
    1
    • latest

Version History

Package Sidebar

Install

npm i express-domain

Weekly Downloads

5

Version

1.0.5

License

none

Last publish

Collaborators

  • nook