Skip to content

Instantly share code, notes, and snippets.

@flippyhead
Created January 20, 2011 18:36
Show Gist options
  • Save flippyhead/788348 to your computer and use it in GitHub Desktop.
Save flippyhead/788348 to your computer and use it in GitHub Desktop.
SessionsController = function() {
function SessionsController() {
this.x = 1;
}
SessionsController.prototype.init = function(req, res, next) {
return console.log(this);
};
return SessionsController;
}();
// In my express app:
sessionsController = new SessionsController()
sessionsController.init() // console.log --> {x: 1}
// App Routes
app.all '/', sessionsController.init // on request, console.log --> { route: '', handle: [Function: router] }, where is X?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment