New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

express-route-directory

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

express-route-directory - npm Package Compare versions

Comparing version 0.0.1 to 2.0.2

94

index.js

@@ -5,26 +5,82 @@ 'use strict';

const INFO = require('./package');
const MODULE_NAME = INFO.name;
const PACKAGE_NAME = INFO.name;
class ExpressRouteDirectory {
class Modulizer {
constructor(directory, options) {
if(!directory){
throw new Error(`${MODULE_NAME}: constructor(): "directory" argument is undefined.`);
}
this._directory = directory;
// default function arguments still unsupported :(
this._options = options || {};
}
/**
* @param {string} directory - String path to module directory. Required.
* @param {object} options - Object for options. Optional.
*/
constructor(directory, options) {
if(!directory){
throw new Error(`${PACKAGE_NAME}: constructor(): "directory" argument is undefined.`);
}
initialize() {
let self = this;
FS.readdirSync(self._directory).forEach((file) => {
if(file.indexOf('.js') !== -1) {
require(self._directory + '/' + file)(self._options);
}
});
}
let self = this;
self._directory = directory;
self._options = options || {};
this._methodArray = [];
this._methodObject = {};
FS.readdirSync(self._directory).forEach((file) => {
if(file.indexOf('.js') !== -1) {
let moduleFunction = require(self._directory + '/' + file);
if(typeof moduleFunction !== 'function') {
console.log(`WARNING: ${PACKAGE_NAME}: constructor(): "${self._directory}/${file}" does not export a function. Execution of it has been skipped.`);
} else {
let filePathFragments = file.split('/');
let filePathFragmentsLength = filePathFragments.length;
let _id = (filePathFragments[filePathFragmentsLength - 1]).replace('.js', '');
this._methodObject[_id] = moduleFunction;
this._methodArray.push(moduleFunction);
}
}
});
}
/**
* Returns all methods as an object.
*/
get methodObject() {
return this._methodObject;
}
/**
* Returns all methods as an array.
*/
get methodArray() {
return this._methodArray;
}
/**
* Execute a specific module identified by the file name (without ".js").
* @param {string} moduleName - Name of module to be executed. The file name from where
* the code originated. Optional.
* @param {object} options - Object for options. Optional.
*/
execute(moduleName, options) {
let self = this;
let extendedOptions = Object.assign(self._options, options);
if(!this._methodObject[moduleName]) {
throw new Error(`${PACKAGE_NAME}: execute(): "${moduleName}" is undefined. Try logging "Modulizer.methodObject" to see all methods.`);
} else {
this._methodObject[moduleName](options);
}
}
/**
* Executes all modules.
*/
executeAll() {
let self = this;
this._methodArray.forEach((moduleFunction) => {
moduleFunction(self._options);
});
}
}
module.exports = ExpressRouteDirectory;
module.exports = Modulizer;
{
"name": "express-route-directory",
"description": "A Node.js module to dynamically generate a route directory structure within Express apps.",
"version": "0.0.1",
"description": "This project simply re-directs to the new version 'Modulizer'.",
"version": "2.0.2",
"author": {

@@ -17,9 +17,10 @@ "name": "Adam Henson",

"keywords": [
"modules",
"directory",
"architecture",
"node",
"express",
"nodejs",
"routes",
"routing",
"router",
"directory",
"architecture"
"router"
],

@@ -31,5 +32,3 @@ "license": "MIT",

"url": "https://github.com/adamhenson/express-route-directory.git"
},
"dependencies": {
}
}
#express-route-directory
> A Node.js module to dynamically generate a route directory structure within Express apps.
## Please Read
##Documentation and tests coming soon...
This project has been moved and renamed "Modulizer".
You can find Modulizer on [NPM](https://www.npmjs.com/package/modulizer) and [Github](https://github.com/adamhenson/modulizer).
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