express-exorcism
Advanced tools
Comparing version 0.0.3 to 0.0.5
{ | ||
"env": { | ||
"node": true, | ||
"es6": true | ||
}, | ||
"ecmaFeatures": { | ||
"arrowFunctions": true, | ||
"blockBindings": true, | ||
"classes": true, | ||
"defaultParameters": true, | ||
"destructuring": true, | ||
"forOf": true, | ||
"generators": true, | ||
"modules": true, | ||
"objectLiteralComputedProperties": true, | ||
"objectLiteralDuplicateProperties": true, | ||
"objectLiteralShorthandMethods": true, | ||
"objectLiteralShorthandProperties": true, | ||
"regexUFlag": true, | ||
"regexYFlag": true, | ||
"restParams": true, | ||
"spread": true, | ||
"superInFunctions": true, | ||
"templateStrings": true, | ||
"unicodeCodePointEscapes": true, | ||
"globalReturn": true | ||
}, | ||
"rules": { | ||
@@ -3,0 +29,0 @@ "indent": [ |
@@ -79,7 +79,7 @@ 'use strict'; | ||
// Replacing original methods | ||
//if (config.replaceOriginalMethods) { | ||
Router[method.name] = method.wrapped; | ||
//} | ||
// if (config.replaceOriginalMethods) { | ||
Router[method.name] = method.wrapped; | ||
// } | ||
}); | ||
return Router; | ||
}; |
{ | ||
"name": "express-exorcism", | ||
"version": "0.0.3", | ||
"description": "", | ||
"version": "0.0.5", | ||
"description": "Express.js router wrapper for async routes", | ||
"author": "Andrew G Kuznetsov <cav@cav.ru>", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/cavinsmith/express-exorcism.git" | ||
}, | ||
"homepage": "https://github.com/cavinsmith/express-exorcism", | ||
"keywords": [ | ||
"express", | ||
"promise", | ||
"async", | ||
"router", | ||
"promisify", | ||
"asynchronous", | ||
"wrapper", | ||
"middleware", | ||
"extension", | ||
"plugin", | ||
"catch", | ||
"then", | ||
"es6", | ||
"es7" | ||
], | ||
"main": "lib/express-exorcism.js", | ||
@@ -10,5 +33,2 @@ "scripts": { | ||
}, | ||
"author": "Andrew G Kuznetsov <cav@cav.ru>", | ||
"license": "MIT", | ||
"repository": "cavinsmith/express-exorcism", | ||
"engines": { | ||
@@ -15,0 +35,0 @@ "node": ">=7.5.0" |
@@ -28,3 +28,3 @@ # Express Exorcism | ||
Run `espress-exorcism` once before first router usage. | ||
Run `espress-exorcism` once before first router usage to wrap entire `express`. | ||
e.g. right after fist `express` require: | ||
@@ -34,3 +34,3 @@ | ||
var express = require('express'); | ||
require('./lib/express-exorcism')(express); | ||
require('express-exorcism')(express); | ||
var router = express.Router(); | ||
@@ -50,7 +50,29 @@ ... | ||
Development Notes | ||
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: | ||
```javascript | ||
var express = require('express'); | ||
var router = require('express-exorcism')(express, {singletonRouter: true}); | ||
... | ||
``` | ||
or es6 | ||
```javascript | ||
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? | ||
@@ -57,0 +79,0 @@ -------------- |
@@ -1,8 +0,8 @@ | ||
module.exports = function (router) { | ||
module.exports = router => { | ||
router.get('/sync/res.send', function (req, res) { | ||
router.get('/sync/res.send', (req, res) => { | ||
res.send({result: 'OK'}); | ||
}); | ||
router.get('/sync/res.send/error', function (req, res, next) { | ||
router.get('/sync/res.send/error', (req, res, next) => { | ||
res.status(500); | ||
@@ -12,7 +12,7 @@ next('ERROR'); | ||
router.get('/async/return', async function () { | ||
router.get('/async/return', async () => { | ||
return {result: 'OK'}; | ||
}); | ||
router.get('/async/res.send', async function (req, res) { | ||
router.get('/async/res.send', async (req, res) => { | ||
res.send({result: 'OK'}); | ||
@@ -23,3 +23,3 @@ return; | ||
router.get('/async/return/error', async function (req, res) { | ||
router.get('/async/return/error', async (req, res) => { | ||
res.status(500); | ||
@@ -29,3 +29,3 @@ throw 'ERROR'; | ||
router.get('/async/promise', async function () { | ||
router.get('/async/promise', async () => { | ||
return new Promise( function (resolve) { | ||
@@ -36,3 +36,3 @@ resolve({result: 'OK'}); | ||
router.get('/async/promise/error', async function () { | ||
router.get('/async/promise/error', async () => { | ||
return new Promise( function (resolve, reject) { | ||
@@ -39,0 +39,0 @@ reject('ERROR'); |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
18769
543
1
79
0