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

dpd-router-middleware

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dpd-router-middleware - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

.vscode/settings.json

58

index.js

@@ -1,32 +0,34 @@

module.exports = function (Router, accountresource) {
var middleware = function (req, res, next) {
module.exports = function(Router, accountresource) {
var middleware = function(req, res, next) {
var resources = process.server.resources
if (!resources || !res) return next()
var resources = process.server.resources;
if (!resources || !res) return next();
var resource = resources.find(function(r) {
return r.name == accountresource
})
var error = function(msg) {
console.error(msg)
if (!res.send) return next() // weird edgecase
res.status(400).send({ code: 400, message: msg })
}
if (!resource) {
return error(
"dpd-router-middleware: resource '" + accountresource + "' not found :("
)
}
var resource = resources.find(function (r) {
return r.name == accountresource;
});
var error = function (msg) {
console.error(msg);
if (!res.send) return next(); // weird edgecase
res.status(400).send({code: 400, message: msg});
};
if (!resource)
return error("dpd-global-events: resource '" + accountresource + "' not found :(");
var Context = require('deployd/lib/context')
var ctx = new Context(resource, req, res, process.server)
var Context = require('deployd/lib/context');
var ctx = new Context(resource, req, res, process.server);
resource.handle(ctx, next)
}
resource.handle(ctx, next);
};
var route = Router.prototype.route;
Router.prototype.route = function (req, res) {
var args = arguments;
var me = this;
middleware(req, res, function () {
return route.apply(me, args);
});
};
};
var route = Router.prototype.route
Router.prototype.route = function(req, res) {
var args = arguments
var me = this
middleware(req, res, function() {
return route.apply(me, args)
})
}
}
{
"name": "dpd-router-middleware",
"version": "1.0.0",
"version": "1.0.1",
"description": "A deployd module to extend the router to run the specified event before running the real target event.",

@@ -8,9 +8,10 @@ "main": "index.js",

"type": "git",
"url": "git://github.com/ezra-obiwale/dpd-router-middleware.git"
},
"url": "git@github.com:ezra-obiwale/dpd-router-middleware.git"
},
"author": "Ezra Obiwale <contact@ezraobiwale.com>",
"license": "MIT",
"keywords": [
"dpd-"
"dpd",
"deployd"
]
}

@@ -5,3 +5,5 @@ Simple router middleware for deployd

`npm install dpd-router-event dpd-router-middleware --save`
````
$ npm install dpd-router-event dpd-router-middleware dpd-event-extension --save
````

@@ -11,14 +13,18 @@ ## Usage

app.js:
````
require('dpd-router-middleware')( require('deployd/lib/router'), 'middleware') // <----- add this
try {
var deployd = require('deployd')
var dpd = deployd({port:3000});
dpd.listen();
} catch(e) {
console.error(err.toString()) // becomes exception in analytics
}
````
**NOTE:**
- *middleware* as used above can be anything but must be the name of the router event resource;
- module *dpd-event-extension* is needed only to ensure that `require` is available within the events.
require('dpd-router-middleware')( require('deployd/lib/router'), 'middleware') // <----- add this
try{
var deployd = require('deployd')
var dpd = deployd({port:3000});
dpd.listen();
}catch(e){
console.error(err.toString()) // becomes exception in analytics
}
Now, open dashboard and create a `Router Event` with the name given above (*middleware* or whatever you put there)
**NOTE:** *middleware* as used above can be anything but must be the name of the router event resource;
Now, open dashboard and create a `Router Event` with the name given above (*middleware* or whatever you put there)
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