Socket
Socket
Sign inDemoInstall

grailed-module-adapter

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grailed-module-adapter - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

2

package.json
{
"name": "grailed-module-adapter",
"version": "1.0.2",
"version": "1.0.3",
"description": "",

@@ -5,0 +5,0 @@ "main": "src/index.js",

@@ -1,40 +0,41 @@

module.exports = function ( _module ) {
var _ = require( 'underscore' ),
is = require( 'sc-is' ),
module = _module,
express = require( 'express' ),
path = require( 'path' ),
routes,
router = express.Router();
module.exports = function(_module) {
var _ = require('underscore'),
is = require('sc-is'),
module = _module,
express = require('express'),
path = require('path'),
fs = require('fs'),
routes,
router = express.Router();
try {
routes = require( path.join( module.options.dirname, '../routes' ) )( module );
} catch ( e ) {
}
var dir = path.join(module.options.dirname, '../routes.js');
if (fs.existsSync(dir)) {
routes = require(dir)(module);
}
if ( routes && !Array.isArray( routes ) ) throw new Error( 'The routes for the module ' + module.name + ' is not a valid Array.' );
if (routes && !Array.isArray(routes)) throw new Error('The routes for the module ' + module.name + ' is not a valid Array.');
if ( routes ) {
routes.forEach( function ( _route ) {
Object.keys( _route ).forEach( function ( _verb ) {
var route = _route[ _verb ],
errorString = 'The route `' + _verb.toUpperCase() + ' ' + _route.path + '` for the module `' + module.name + '` was not an Array or Function';
if (routes) {
routes.forEach(function(_route) {
Object.keys(_route).forEach(function(_verb) {
var route = _route[_verb],
errorString = 'The route `' + _verb.toUpperCase() + ' ' + _route.path + '` for the module `' + module.name + '` was not an Array or Function';
if ( _verb === 'path' ) return;
if (_verb === 'path') return;
if ( is.not.an.array( route ) && is.not.a.func( route ) )
throw new Error( errorString );
if (is.not.an.array(route) && is.not.a.func(route))
throw new Error(errorString);
if ( is.an.array( route ) ) {
_.each( route, function ( _middleware ) {
if ( is.not.a.func( _middleware ) ) throw new Error( errorString );
} );
}
if (is.an.array(route)) {
_.each(route, function(_middleware) {
if (is.not.a.func(_middleware)) throw new Error(errorString);
});
}
router[ _verb ]( _route.path, route );
} );
} );
}
router[_verb](_route.path, route);
});
});
}
return router;
return router;
};
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