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

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.3 to 1.0.4

2

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

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

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

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();
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();
var dir = path.join(module.options.dirname, '../routes.js');
if (fs.existsSync(dir)) {
routes = require(dir)(module);
}
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.an.array( _middleware ) && 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