Skip to content

Instantly share code, notes, and snippets.

@jcblw
Created December 18, 2013 21:07
Show Gist options
  • Save jcblw/8029837 to your computer and use it in GitHub Desktop.
Save jcblw/8029837 to your computer and use it in GitHub Desktop.
commonjs module patterns
var _modules = require('./modules'),
Counter = _modules.Counter,
Entity = _modules.Entity,
app = {};
require( './routes' )( app, function ( err ) {
console.log( typeof app.routes );
} );
function Counter ( ) {
console.log('This the Counter');
}
function Entity ( ) {
console.log('This the Entity');
}
module.exports.Counter = Counter;
module.exports.Entity = Entity;
module.exports = function ( app, next ) {
app.routes = {
'/about' : function ( ) {
console.log('this is the /about');
}
}
next( );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment