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 2.2.0 to 2.3.0

test/server/controllers/all.filters.js

27

index.js

@@ -14,4 +14,4 @@ delete require.cache[__filename];

} else if (param instanceof RegExp) {
ret = new RegExp('^' + url.replace(/([\.\-])/g, '\\$1') + '/' +
param.toString().replace(/^\/(\\\/)*|\/$/g, '') + '$');
ret = new RegExp(url.replace(/([\.\-])/g, '\\$1') + '/' +
param.toString().replace(/^\/(\\\/)*|\/$/g, ''));
}

@@ -28,3 +28,5 @@ return ret;

module.exports = function (options = {}) {
var middleware = express.Router();
var middleware = express.Router({
strict: options.strict
});
var optionControllers = options.controllers || 'controllers';

@@ -41,3 +43,3 @@ var ctrlDir = path.isAbsolute(optionControllers) ?

var instance = require(file);
var url = file.replace(ctrlDir, '').replace(/\/index$/, '/');
var url = file.replace(ctrlDir, '').replace(/\/index$/, '');

@@ -52,3 +54,3 @@ Object.keys(instance).forEach(function (key) {

if (!matcher) {
return console.error('[rainbow]: Router key pattern "%s" is invalid.', key);
return console.warn('[rainbow]: Router key pattern "%s" is invalid.', key);
}

@@ -59,7 +61,7 @@

if (methods.indexOf(method) === -1 && method !== 'all') {
return console.error('[rainbow]: Unknown HTTP method "%s".', method);
return console.warn('[rainbow]: Unknown HTTP method "%s".', method);
}
if (typeof middleware[method] !== 'function') {
return console.error('[rainbow]: HTTP method "%s" is not supported.', method);
return console.warn('[rainbow]: HTTP method "%s" is not supported.', method);
}

@@ -70,5 +72,10 @@

var chain = filters.concat(router instanceof Array ? router : [router]);
var params = matcher[2] ?
(matcher[3] ? new RegExp(matcher[3]) : matcher[4]) :
router.params;
var params = router.params;
if (matcher[2]) {
if (matcher[3]) {
params = new RegExp(matcher[3]);
} else {
params = matcher[4];
}
}
var pathname = joinParam(url, params);

@@ -75,0 +82,0 @@

{
"name": "rainbow",
"description": "Express router middleware for RESTful API base on certain folder path",
"version": "2.2.0",
"version": "2.3.0",
"author": "mytharcher <mytharcher@gmail.com>",

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

@@ -6,3 +6,3 @@ Rainbow

A node [Express][] router middleware for Ajax RESTful API base on certain folder path.
A node [Express][] router middleware for RESTful API base on certain folder path.

@@ -223,2 +223,10 @@ Rainbow mapping all HTTP request route to controllers folder each as path to file as URL.

### Express router options ###
From v2.3.0 rainbow added [express router option](http://expressjs.com/en/api.html#express.router) `strict` into options, default to `false`.
~~~javascript
app.use(rainbow({ strict: true }));
~~~
Change log

@@ -225,0 +233,0 @@ ----------

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