expressjs-plus
Advanced tools
Comparing version 0.0.2 to 0.0.3
@@ -22,33 +22,37 @@ 'use strict'; | ||
* // Usage | ||
* ```js | ||
* var express = require('express'); | ||
* var bodyParser = require('body-parser'); | ||
* var userHandler = function(param, paramsArray, req){ | ||
* if(param !== 'user') return false; | ||
* paramsArray.push(req.user); | ||
* return true; | ||
* }; | ||
* var app = express() | ||
* app.use(bodyParser.json()); | ||
* var appPlus = new ExpressPlus(app, [userHandler], []); | ||
* var regularFunction = function(user, id, cb){ | ||
* return cb(null, { response: {user: user, id: id}, status: 200 }); | ||
* }; | ||
* app.use(appPlus.GMV(regularFunction), appPlus.responder); | ||
* | ||
* appPlus.setErrorHandlers(); | ||
* ``` | ||
```js | ||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var userHandler = function(param, paramsArray, req){ | ||
if(param !== 'user') return false; | ||
paramsArray.push(req.user); | ||
return true; | ||
}; | ||
var app = express() | ||
app.use(bodyParser.json()); | ||
var appPlus = new ExpressPlus(app, [userHandler], []); | ||
var regularFunction = function(user, id, cb){ | ||
return cb(null, { response: {user: user, id: id}, status: 200 }); | ||
}; | ||
app.use(appPlus.GMV(regularFunction), appPlus.responder); | ||
appPlus.setErrorHandlers(); | ||
``` | ||
* @param {Object} app express app object | ||
* @param {Array} passedParamHandlers array of functions in the format of @see {@link lastHandler} | ||
* @example //this is an example of a paramHandler function that is interested in the user parameter | ||
* ```js | ||
* function userHandler(param, paramsArray, req){ | ||
* if(param === 'user'){ | ||
* paramsArray.push(req.user); | ||
* return true; | ||
* }else{ | ||
* return false; | ||
* } | ||
* } | ||
* ``` | ||
* | ||
```js | ||
function userHandler(param, paramsArray, req){ | ||
if(param === 'user'){ | ||
paramsArray.push(req.user); | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
``` | ||
* @param {Array} passedErrorHandlers array of middlewares | ||
@@ -55,0 +59,0 @@ * @constructor |
{ | ||
"name": "expressjs-plus", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A pluggable expansion to express js aimed at adding much needed features and helpers.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -31,5 +31,33 @@ <a name="ExpressPlus"></a> | ||
**Example** | ||
// Usage ```js var express = require('express'); var bodyParser = require('body-parser'); var userHandler = function(param, paramsArray, req){ if(param !== 'user') return false; paramsArray.push(req.user); return true; }; var app = express() app.use(bodyParser.json()); var appPlus = new ExpressPlus(app, [userHandler], []); var regularFunction = function(user, id, cb){ return cb(null, { response: {user: user, id: id}, status: 200 }); }; app.use(appPlus.GMV(regularFunction), appPlus.responder); appPlus.setErrorHandlers(); ``` | ||
// Usage | ||
```js | ||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var userHandler = function(param, paramsArray, req){ | ||
if(param !== 'user') return false; | ||
paramsArray.push(req.user); | ||
return true; | ||
}; | ||
var app = express() | ||
app.use(bodyParser.json()); | ||
var appPlus = new ExpressPlus(app, [userHandler], []); | ||
var regularFunction = function(user, id, cb){ | ||
return cb(null, { response: {user: user, id: id}, status: 200 }); | ||
}; | ||
app.use(appPlus.GMV(regularFunction), appPlus.responder); | ||
appPlus.setErrorHandlers(); | ||
``` | ||
**Example** | ||
//this is an example of a paramHandler function that is interested in the user parameter ```js function userHandler(param, paramsArray, req){ if(param === 'user'){ paramsArray.push(req.user); return true; }else{ return false; } } ``` | ||
//this is an example of a paramHandler function that is interested in the user parameter | ||
```js | ||
function userHandler(param, paramsArray, req){ | ||
if(param === 'user'){ | ||
paramsArray.push(req.user); | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
``` | ||
<a name="ExpressPlus+HTTPError"></a> | ||
@@ -36,0 +64,0 @@ |
@@ -9,33 +9,37 @@ /** | ||
* // Usage | ||
* ```js | ||
* var express = require('express'); | ||
* var bodyParser = require('body-parser'); | ||
* var userHandler = function(param, paramsArray, req){ | ||
* if(param !== 'user') return false; | ||
* paramsArray.push(req.user); | ||
* return true; | ||
* }; | ||
* var app = express() | ||
* app.use(bodyParser.json()); | ||
* var appPlus = new ExpressPlus(app, [userHandler], []); | ||
* var regularFunction = function(user, id, cb){ | ||
* return cb(null, { response: {user: user, id: id}, status: 200 }); | ||
* }; | ||
* app.use(appPlus.GMV(regularFunction), appPlus.responder); | ||
* | ||
* appPlus.setErrorHandlers(); | ||
* ``` | ||
```js | ||
var express = require('express'); | ||
var bodyParser = require('body-parser'); | ||
var userHandler = function(param, paramsArray, req){ | ||
if(param !== 'user') return false; | ||
paramsArray.push(req.user); | ||
return true; | ||
}; | ||
var app = express() | ||
app.use(bodyParser.json()); | ||
var appPlus = new ExpressPlus(app, [userHandler], []); | ||
var regularFunction = function(user, id, cb){ | ||
return cb(null, { response: {user: user, id: id}, status: 200 }); | ||
}; | ||
app.use(appPlus.GMV(regularFunction), appPlus.responder); | ||
appPlus.setErrorHandlers(); | ||
``` | ||
* @param {Object} app express app object | ||
* @param {Array} passedParamHandlers array of functions in the format of @see {@link lastHandler} | ||
* @example //this is an example of a paramHandler function that is interested in the user parameter | ||
* ```js | ||
* function userHandler(param, paramsArray, req){ | ||
* if(param === 'user'){ | ||
* paramsArray.push(req.user); | ||
* return true; | ||
* }else{ | ||
* return false; | ||
* } | ||
* } | ||
* ``` | ||
* | ||
```js | ||
function userHandler(param, paramsArray, req){ | ||
if(param === 'user'){ | ||
paramsArray.push(req.user); | ||
return true; | ||
}else{ | ||
return false; | ||
} | ||
} | ||
``` | ||
* @param {Array} passedErrorHandlers array of middlewares | ||
@@ -42,0 +46,0 @@ * @constructor |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
546
164
30101