Skip to content

Instantly share code, notes, and snippets.

@anatoliychakkaev
Last active December 10, 2015 03:08
Show Gist options
  • Save anatoliychakkaev/4372889 to your computer and use it in GitHub Desktop.
Save anatoliychakkaev/4372889 to your computer and use it in GitHub Desktop.
Another way of controllers describing
var Application = module.exports = function Application(init) {
init.before(function protectFromForgery(c) {
c.protectFromForgery('74be5145ccc6b731ee2d6f08990cc4f43c2bc800');
});
};
Application.prototype.someAction = function (c) {
c.send('hello');
};
var Application = require('./application');
var Driver = module.exports = function Driver(init) {
Application.call(this, init);
init.before(function think(c) {
console.log('thinking');
c.next();
}, {only: 'accelerate'});
};
require('util').inherits(Driver, Application);
Driver.prototype.accelerate = function (c) {
c.send('accelerate');
};
Driver.prototype.brake = function (c) {
c.send('brake');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment