Skip to content

Instantly share code, notes, and snippets.

@artcommacode
Last active December 11, 2015 21:38
Show Gist options
  • Save artcommacode/4663649 to your computer and use it in GitHub Desktop.
Save artcommacode/4663649 to your computer and use it in GitHub Desktop.
// FIRST WAY
//routes.js
module.exports = function (app, client, config) {
var Index = require('../controllers/index')
, index = new Index(app, client, config);
app.get('/', index.index);
};
//index.js
module.exports = function (app, client, config) {
this.index = function(req, res, next) {
res.json('index');
};
};
// SECOND WAY
//routes.js
module.exports = function (app, client, config) {
var index = new require('../controllers/index')(app, client, config);
app.get('/', index.index);
};
//index.js
module.exports = function (app, client, config) {
var index = function index(req, res, next) {
res.json('index');
};
return {
index: index
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment