Skip to content

Commit

Permalink
DRY - Removed the need to also list an auth module name in index.js. …
Browse files Browse the repository at this point in the history
…Instead, we take advantage of directory conventions (i.e., modules live in ./lib/modules/ and filenames match the module names).
  • Loading branch information
bnoguchi committed Jun 7, 2011
1 parent 9dd7d2d commit fd96540
Show file tree
Hide file tree
Showing 18 changed files with 13 additions and 7 deletions.
10 changes: 8 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,14 @@ everyauth

everyauth.modules = {};
everyauth.enabled = {};
var includeModules = ['everymodule', 'password', 'ldap', 'oauth', 'twitter', 'linkedin', 'yahoo', 'readability', 'dropbox', 'oauth2', 'facebook', 'github', 'instagram', 'foursquare', 'google', 'openid', 'googlehybrid'];

// Grab all filenames in ./modules -- They correspond to the modules of the same name
// as the filename (minus '.js')
var fs = require('fs');
var files = fs.readdirSync(__dirname + '/lib/modules');
var includeModules = files.map( function (fname) {
return fname.substring(0, fname.length - 3);
});
for (var i = 0, l = includeModules.length; i < l; i++) {
var name = includeModules[i];

Expand All @@ -101,7 +107,7 @@ for (var i = 0, l = includeModules.length; i < l; i++) {
Object.defineProperty(everyauth, name, {
get: (function (name) {
return function () {
var mod = this.modules[name] || (this.modules[name] = require('./lib/' + name));
var mod = this.modules[name] || (this.modules[name] = require('./lib/modules/' + name));
// Make `everyauth` accessible from each auth strategy module
if (!mod.everyauth) mod.everyauth = this;
if (mod.shouldSetup)
Expand Down
File renamed without changes.
10 changes: 5 additions & 5 deletions lib/everymodule.js → lib/modules/everymodule.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
var url = require('url')
, Step = require('./step')
, StepSequence = require('./stepSequence')
, RouteTriggeredSequence = require('./routeTriggeredSequence')
, clone = require('./utils').clone
, Promise = require('./promise');
, Step = require('../step')
, StepSequence = require('../stepSequence')
, RouteTriggeredSequence = require('../routeTriggeredSequence')
, clone = require('../utils').clone
, Promise = require('../promise');

var routeDescPrefix = {
get: 'ROUTE (GET)'
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit fd96540

Please sign in to comment.