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

express-controllers

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-controllers - npm Package Compare versions

Comparing version 0.2.0 to 1.0.0

.npmignore

49

index.js
/*!
* Express - Controllers
* Copyright(c) 2011 Nicholas Penree <drudge@conceited.net>
* Express Controllers
* Copyright(c) 2011-2014 Nicholas Penree <nick@penree.com>
* MIT Licensed

@@ -12,7 +12,8 @@ */

var express = require('express')
, resource = require('express-resource')
, readdir = require('fs').readdirSync
, join = require('path').join
, extname = require('path').extname
var express = require('express');
var resource = require('express-resource'); // Monkey patch express
var readdir = require('fs').readdirSync;
var path = require('path');
var join = path.join;
var extname = require('path').extname;

@@ -22,4 +23,4 @@ /**

*
* This method will create an express resource for all files in your `controllers path`
* setting, defaulting to `'/../../controllers/'`.
* This method will create an express resource for all modules in the
* `controllers path` setting, defaulting to `$CWD/controllers'`.
* @param {Object} Express app

@@ -29,22 +30,18 @@ * @return {Resource}

*/
module.exports =
express.HTTPServer.prototype.controllers =
express.HTTPSServer.prototype.controllers = function(app){
var loaded = []
, self = app || this
, controllerPath = self.set('controllers path') || __dirname + '/../../controllers';
readdir(controllerPath).forEach(function(file){
if (file.match(/^.*.js$/ig)){
var controller = file.replace(extname(file), '');
loaded.push(controller);
if (typeof self.resource !== 'undefined'){
loaded[controller] = self.resource(controller, require(join(controllerPath, controller)));
express.application.controllers = function(app) {
var self = app || this;
var defaultPath = path.resolve(join(process.cwd(), 'controllers'));
var controllerPath = self.get('controllers path') || defaultPath;
var onController = function(name) {
if (name.match(/^.*.js$/ig)) {
var controller = name.replace(extname(name), '');
if (typeof self.resource !== 'undefined') {
self.resource(controller, require(join(controllerPath, controller)));
}
}
});
return loaded;
};
readdir(controllerPath).forEach(onController);
return self;
};
{ "name": "express-controllers"
, "description": "MVC routing for express"
, "version": "0.2.0"
, "author": "Nicholas Penree <drudge@conceited.net>"
, "description": "Dead simple MVC routing for express"
, "version": "1.0.0"
, "author": "Nicholas Penree <nick@penree.com>"
, "repository" : {

@@ -10,12 +10,11 @@ "type": "git"

, "contributors": []
, "dependencies": {
"express-resource": ">=0.2.1"
, "dependencies": {
"express-resource": "~1.0.0"
}
, "devDependencies": {
"connect": "1.4.x"
, "express": "2.3.x"
"express": "4.x.x"
}
, "keywords": ["express", "rest", "resource", "mvc", "controller"]
, "main": "index"
, "engines": { "node": ">= 0.2.0" }
, "engines": { "node": ">= 0.8.0" }
}

Sorry, the diff of this file is not supported yet

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