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

middlewarify

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

middlewarify - npm Package Compare versions

Comparing version 2.1.2 to 2.2.0

LICENSE

99

package.json
{
"name": "middlewarify",
"description": "Apply the middleware pattern to any function.",
"version": "2.1.2",
"homepage": "https://github.com/thanpolas/middlewarify",
"author": {
"name": "Thanasis Polychronakis",
"url": "http://thanpol.as"
},
"repository": {
"type": "git",
"url": "git://github.com/thanpolas/middlewarify.git"
},
"bugs": {
"url": "https://github.com/thanpolas/middlewarify/issues"
},
"license": "MIT",
"engines": {
"node": ">= 10"
},
"scripts": {
"test": "npm run eslint; mocha -u tdd -R spec test/",
"eslint": "eslint middlewarify.js test",
"release": "release-it --ci",
"release:minor": "release-it minor --ci",
"release:major": "release-it major --ci"
},
"dependencies": {
"lodash": "~4.17.21",
"async": "~3.2.0"
},
"devDependencies": {
"chai": "~4.3.4",
"eslint": "~7.27.0",
"eslint-config-airbnb-base": "~14.2.1",
"eslint-config-prettier": "~8.3.0",
"eslint-plugin-import": "~2.23.4",
"eslint-plugin-jest": "~24.3.6",
"eslint-plugin-jsdoc": "~35.1.1",
"eslint-plugin-prettier": "~3.4.0",
"eslint-plugin-security": "~1.4.0",
"mocha": "~8.4.0",
"prettier": "~2.3.0",
"release-it": "^14.7.0",
"sinon": "~11.1.1"
},
"keywords": [
"middleware",
"middleware pattern"
]
"name": "middlewarify",
"description": "Apply the middleware pattern to any function.",
"version": "2.2.0",
"main": "./src/middlewarify",
"homepage": "https://github.com/thanpolas/middlewarify",
"author": {
"name": "Thanasis Polychronakis",
"url": "http://thanpol.as"
},
"repository": {
"type": "git",
"url": "git://github.com/thanpolas/middlewarify.git"
},
"bugs": {
"url": "https://github.com/thanpolas/middlewarify/issues"
},
"license": "ISC",
"engines": {
"node": ">= 10"
},
"scripts": {
"test": "npm run eslint; mocha -u tdd -R spec test/",
"eslint": "eslint middlewarify.js test",
"release": "release-it --ci",
"release:minor": "release-it minor --ci",
"release:major": "release-it major --ci"
},
"dependencies": {
"lodash": "~4.17.21",
"async": "~3.2.1"
},
"devDependencies": {
"chai": "~4.3.4",
"eslint": "~7.32.0",
"eslint-config-airbnb-base": "~14.2.1",
"eslint-config-prettier": "~8.3.0",
"eslint-plugin-import": "~2.24.2",
"eslint-plugin-jest": "~24.4.0",
"eslint-plugin-jsdoc": "~36.1.0",
"eslint-plugin-prettier": "~4.0.0",
"eslint-plugin-security": "~1.4.0",
"mocha": "~9.1.1",
"prettier": "~2.4.0",
"release-it": "^14.11.5",
"sinon": "~11.1.2"
},
"keywords": [
"middleware",
"middleware pattern"
]
}

@@ -50,3 +50,3 @@ # Middlewarify

tasks.create.use(function(data) {
tasks.create.use(function (data) {
console.log('middleware 1');

@@ -57,3 +57,3 @@ data.newAttr = 2;

// Add a second middleware to the 'create' operation
tasks.create.use(function(data) {
tasks.create.use(function (data) {
console.log('middleware 2. Title:', data.title);

@@ -122,2 +122,5 @@ data.secondAttr = 3;

Express middleware.
- `concurrent` type **Boolean**, default: `false` Enables concurrent invocation
of all middleware. Requires the `async` option to be true and cannot be used
with `beforeAfter` option.

@@ -160,7 +163,7 @@ ## The use(fn) Hook.

```js
app.connect.use(function(req) {
app.connect.use(function (req) {
req.a === 1; // true
req.a++;
});
app.connect.use(function(req) {
app.connect.use(function (req) {
req.a === 2; // true

@@ -207,3 +210,3 @@ });

```js
crud.create.use(function(arg1, arg2) {
crud.create.use(function (arg1, arg2) {
arg1 === { a: 1, b: 2 }; // true

@@ -269,3 +272,3 @@

// add a before hook
tasks.create.before(function() {
tasks.create.before(function () {
console.log('Invoked First');

@@ -275,3 +278,3 @@ });

// add an after hook
tasks.create.after(function() {
tasks.create.after(function () {
console.log('Invoked Third');

@@ -281,3 +284,3 @@ });

// add an always LAST hook, will always invoke last
task.create.last(function() {
task.create.last(function () {
console.log('Will always invoke last');

@@ -290,7 +293,7 @@ });

tasks.create().then(
function(val) {
function (val) {
// at this point all middleware have finished.
console.log(val); // 999
},
function(err) {
function (err) {
// handle error

@@ -308,7 +311,7 @@ },

```js
middlewarify.make(crud, 'create', function(arg1, arg2) {
middlewarify.make(crud, 'create', function (arg1, arg2) {
return 'abc';
});
crud.create.after(function(arg1, arg2, val) {
crud.create.after(function (arg1, arg2, val) {
console.log(val); // prints 'abc'

@@ -326,7 +329,7 @@ });

```js
middlewarify.make(crud, 'create', function() {
middlewarify.make(crud, 'create', function () {
return 'abc';
});
crud.create.after(function(result) {
crud.create.after(function (result) {
// return an altered outcome

@@ -336,3 +339,3 @@ return 'def';

crud.create().then(function(result) {
crud.create().then(function (result) {
console.log(result); // prints "def"

@@ -342,5 +345,11 @@ });

## Using Concurrent Execution
Concurrent execution will use the [Promise.allSettled()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled) function and return its raw results. So expect an array of result objects containing the `status` and either `value` on success or `reason` on failure.
## Release History
- **v2.1.2**, _31 May 2022_
- **v2.2.0**, _14 Sep 2021_
- Introduced "concurrent" option.
- **v2.1.2**, _31 May 2021_
- Updated all dependencies to latest.

@@ -351,4 +360,4 @@ - **v2.1.1**, _30 Oct 2020_

- **v2.1.0**, _30 Oct 2020_
- Updated all dependencies to latest (minor bump was a mistake, should
be patch ¯\_(ツ)_/¯).
- Updated all dependencies to latest (minor bump was a mistake, should
be patch ¯\_(ツ)\_/¯).
- **v2.0.0**, _09 Mar 2020_ **Breaking Changes**

@@ -397,3 +406,3 @@ - Middlewarify will now execute all middleware synchronously by default.

Copyright Thanasis Polychronakis, licensed under the [MIT License](LICENSE-MIT).
Copyright Thanos Polychronakis, licensed under the [ISC License](LICENSE).

@@ -400,0 +409,0 @@ [grunt]: http://gruntjs.com/

Sorry, the diff of this file is not supported yet

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