Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

expressjs-plus

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expressjs-plus - npm Package Compare versions

Comparing version 0.0.2 to 0.0.3

58

lib/index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc