Skip to content

Instantly share code, notes, and snippets.

View anatoliychakkaev's full-sized avatar

Anatoliy Chakkaev anatoliychakkaev

View GitHub Profile
@anatoliychakkaev
anatoliychakkaev / driver.js
Last active December 10, 2015 03:08
Commonjs-style controller for 1602/kontroller
var Driver = module.exports = require('kontroller').BaseController.constructClass();
Driver.init = function (c) {
c.extendWith(require('./application'));
};
Driver.before(function think(c) {
this.allok = true;
c.next();
}, {only: 'accelerate'});
@anatoliychakkaev
anatoliychakkaev / application.js
Last active December 10, 2015 03:08
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');
};
@anatoliychakkaev
anatoliychakkaev / README.md
Last active December 10, 2015 17:49
Experimental compound events + common controllers API.

About

This is example of using compound API with any express application. Every part of compound could be accessed via API. Directories structure is optional: you can do everything in single file using compount events API.

Insallation

npm install compound jugglingdb express

Running

var migrate = require('migrate')
, join = require('path').join
, fs = require('fs');
module.exports = function(compound) {
var app = compound.app;
var options = {args: []};
/**
* Migration template.
@anatoliychakkaev
anatoliychakkaev / shell.log
Created March 25, 2013 10:17
Generators working fine
~: ) cd /tmp
14:15:13 anatoliy@mac /tmp
~: ) compound init gen
create gen
create gen/app/
create gen/app/assets/
create gen/app/assets/coffeescripts/
create gen/app/assets/stylesheets/
create gen/app/models/
create gen/app/controllers/
@anatoliychakkaev
anatoliychakkaev / grab.js
Created April 1, 2013 22:34
Example of using streams
var fs = require('fs');
var express = require('express');
var spawn = require('child_process').spawn;
var icecast = require('icecast');
// URL to a known Icecast stream
var url = 'http://ice.somafm.com/spacestation';
// connect to the remote stream
icecast.get(url, function (res) {