Skip to content

cavinsmith/express-exorcism

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Express Exorcism

Build Status Coverage Status NPM Downloads

dependencies Status devDependencies Status Codacy Badge

express-exorcism is an Express.js Router wrapper that helps to handle async routes.

NB: Minimal Node version is 7.5.0 with --harmony or 7.6.0.

Installation

npm install express-exorcism --save

or

yarn add express-exorcism

Usage

Run espress-exorcism once before first router usage to wrap entire express. e.g. right after fist express require:

var express = require('express');
require('express-exorcism')(express);
var router = express.Router();
...

or es6

import express from 'express'
import exorcism from 'express-exorcism'
exorcism(express)
const router = express.Router();
...

NB: If you're using import instead of require and express-exorcism is not working for you, it means that express.Router instances are created before express-exorcism wrapper is run. For example if you have import './routes' even after wrapping express - node will run it before.

Singleton wrapper

By default you can wrap express only once with one configuration.

If you need different configurations for different routers or other strange stuff - consider to use singletonRouter option to create router instance wrappers:

var express = require('express');
var router = require('express-exorcism')(express, {singletonRouter: true});
...

or es6

import express from 'express'
import exorcism from 'express-exorcism'

const router = exorcism(express, {singletonRouter: true})
...

NB: router will represent wrapped express.Router() instance, instead of modifying original express.Router methods.

Problems?

Please file an issue on github!

About

Async routes support for Express router

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published