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

rainbow

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rainbow - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

54

index.js

@@ -27,23 +27,24 @@ var approot = process.env.PWD;

exports.route = function (app, paths) {
function route (app, method, url, router) {
var filters = (router.filters || []).map(function (item) {
switch(typeof item) {
case 'function':
return item;
function route (url, method, instance) {
var router = instance[method.toLowerCase()] || instance[method.toUpperCase()];
case 'string':
return require(path.join(fltrDir, item));
if (router) {
if (instance[method.toLowerCase()]) {
console.warn('[rainbow]: Lower case HTTP methods are deprecated. Please change "' + method + '" in file:' + file + ' to upper case.');
}
default:
console.log('[rainbow]: Filter only support function or string of path.');
return null;
}
}).filter(function (item) {
return !!item;
});
app[method.toLowerCase()].apply(app, [joinParam(url, router.params)]
.concat(filters)
.concat([router])
);
var filters = (instance[filters] || []).concat(router.filters || []).map(function (item) {
return ({
'function': item,
'string': require(path.join(fltrDir, item))
})[typeof item];
}).filter(function (item) {
return !!item;
});
app[method.toLowerCase()].apply(app, [joinParam(url, router.params)]
.concat(filters)
.concat([router])
);
}
}

@@ -57,18 +58,11 @@

file = file.replace(/\.[^.]*$/, '');
var router = require(file);
var single = typeof router == 'function';
var instance = require(file);
var single = typeof instance == 'function';
var url = file.replace(ctrlDir, '').replace(/\/index$/, '/');
single ? route(app, 'all', url, router) :
single ? route(url, 'ALL', {ALL: instance}) :
methods.forEach(function (method) {
var eachRouter = router[method.toLowerCase()] || router[method.toUpperCase()];
if (eachRouter) {
if (router[method.toLowerCase()]) {
console.log('[rainbow]: Lower case HTTP methods are deprecated. Please change "' + method + '" in file:' + file + ' to upper case.');
}
route(app, method, url, eachRouter);
}
route(url, method, instance);
});
});
};
{
"name": "rainbow",
"description": "Express router middleware for RESTful API base on certain folder path",
"version": "0.4.0",
"version": "0.5.0",
"author": "mytharcher <mytharcher@gmail.com>",

@@ -6,0 +6,0 @@ "main" : "index.js",

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