• Stars
    star
    101
  • Rank 338,166 (Top 7 %)
  • Language
    JavaScript
  • License
    Other
  • Created over 11 years ago
  • Updated over 11 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

`uncaughtException` middleware for connect, base on `domain` module.

domain-middleware Build Status

logo

uncaughtException middleware for connect, base on domain module.

Try to make a better connect-domain module.

Warning: Don't Ignore Errors!

Install

$ npm install domain-middleware

Usage

Usually, domain usage goes hand-in-hand with the cluster module, since the master process can fork a new worker when a worker encounters an error. Please see connect_with_cluster example.

This below code just for dev demo, don't use it on production env:

var http = require('http');
var connect = require('connect');
var domainMiddleware = require('domain-middleware');

var server = http.createServer();
var app = connect()
.use(domainMiddleware({
  server: server,
  killTimeout: 30000,
}))
.use(function(req, res){
  if (Math.random() > 0.5) {
    foo.bar();
  }
  setTimeout(function() {
    if (Math.random() > 0.5) {
      throw new Error('Asynchronous error from timeout');
    } else {
      res.end('Hello from Connect!');
    }
  }, 100);
  setTimeout(function() {
    if (Math.random() > 0.5) {
      throw new Error('Mock second error');
    }
  }, 200);
})
.use(function(err, req, res, next) {
  res.end(err.message);
});

server.on('request', app);
server.listen(1984);

License

(The MIT License)

Copyright (c) 2013 fengmk2 <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

More Repositories

1

express

Fast, unopinionated, minimalist web framework for node.
JavaScript
63,539
star
2

multer

Node.js middleware for handling `multipart/form-data`.
JavaScript
11,285
star
3

morgan

HTTP request logger middleware for node.js
JavaScript
7,790
star
4

session

Simple session middleware for Express
JavaScript
6,163
star
5

cors

Node.js CORS middleware
JavaScript
5,961
star
6

body-parser

Node.js body parsing middleware
JavaScript
5,376
star
7

expressjs.com

HTML
5,138
star
8

compression

Node.js compression middleware
JavaScript
2,722
star
9

csurf

CSRF token middleware
2,299
star
10

cookie-parser

Parse HTTP request cookies
JavaScript
1,907
star
11

generator

Express' application generator
JavaScript
1,803
star
12

serve-static

Serve static files
JavaScript
1,368
star
13

cookie-session

Simple cookie-based session middleware
JavaScript
1,104
star
14

vhost

virtual domain hosting
JavaScript
758
star
15

serve-favicon

favicon serving middleware
JavaScript
620
star
16

method-override

Override HTTP verbs.
JavaScript
614
star
17

response-time

Response time header for node.js
JavaScript
458
star
18

serve-index

Serve directory listings
JavaScript
435
star
19

errorhandler

Development-only error handler middleware
JavaScript
423
star
20

express-paginate

Paginate middleware
JavaScript
419
star
21

connect-multiparty

connect middleware for multiparty
JavaScript
347
star
22

express-namespace

Adds namespaced routing capabilities to Express
JavaScript
345
star
23

timeout

Request timeout middleware for Connect/Express
JavaScript
312
star
24

express-expose

Expose raw js, objects, and functions to the client-side (awesome for sharing utils, settings, current user data etc)
JavaScript
299
star
25

basic-auth-connect

Basic auth middleware for node and connect
JavaScript
129
star
26

api-error-handler

Express error handlers for JSON APIs
JavaScript
100
star
27

flash

JavaScript
92
star
28

restful-router

Simple RESTful url router.
JavaScript
86
star
29

urlrouter

http url router, `connect` missing router middleware
JavaScript
59
star
30

discussions

Public discussions for the Express.js organization
55
star
31

vhostess

virtual host sub-domain mapping
JavaScript
24
star
32

connect-markdown

Auto convert markdown to html for connect.
JavaScript
20
star
33

expressjs.github.io

16
star
34

connect-rid

connect request id middleware
JavaScript
11
star
35

routification

DEPRECATED
JavaScript
10
star
36

mime-extended

DEPRECATED - Please use mime-types instead.
JavaScript
7
star
37

statusboard

A project status board for the Express community
6
star
38

.github

5
star
39

set-type

DEPRECATED - Please use mime-types instead.
JavaScript
5
star
40

security-wg

Express.js Security Working Group
4
star
41

Admin

Admin repository for the Express Organization, including pillarjs and jshttp
2
star