a full featured i/o framework for node.js
JavaScript
Pull request Compare This branch is 212 commits ahead of jsjohnst:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
lib
screenshots
test
.gitignore
README.md
config.json
package.json

README.md

 __    __    ______     ______    __  ___         __    ______   
|  |  |  |  /  __  \   /  __  \  |  |/  /        |  |  /  __  \  
|  |__|  | |  |  |  | |  |  |  | |  '  /         |  | |  |  |  | 
|   __   | |  |  |  | |  |  |  | |    <          |  | |  |  |  | 
|  |  |  | |  `--'  | |  `--'  | |  .  \    __   |  | |  `--'  | 
|__|  |__|  \______/   \______/  |__|\__\  (__)  |__|  \______/  

a full featured i/o framework for node.js

v0.5.2

hook.io creates a distributed node.js EventEmitter that works cross-process / cross-platform / cross-browser. Think of it like a real-time event bus that works anywhere JavaScript is supported.

You create custom i/o scenarios by picking and choosing from an extensive library of tiny, independent, autonomous "hooks" that seamlessly work together.

Features :

  • Build large, decoupled, distributed, and fault tolerant I/O heavy applications in node.js
  • Create hooks on ANY device that supports JavaScript ( cross-browser support via socket.io )
  • Throw any block of sync or async code on a new process with a callback
  • Easily scale any tcp based messaging infrastructure ( such as clustering socket.io chat rooms in memory )
  • Interprocess Message Publishing and Subscribing done through EventEmitter2 and dnode
  • Messaging API inherits and mimics Node's native EventEmitter API ( with the help of EventEmitter2 )
  • Spawning and Daemonizing of processes handled with Forever
  • Easily connect / disconnect hooks "hot" without affecting other services
  • Core library currently checking in at about ~450 lines of code

Available Hooks ( more coming soon )

Getting Start / Demo

 npm install hook.io-helloworld -g

Now run:

 hookio-helloworld

Spawn up as many as you want. The first one becomes an output ( server ), the rest will become inputs ( clients ). Each helloworld input will emit a hello on an interval. Now watch the i/o party!

Basic Hello World Syntax

http://github.com/hookio/helloworld

#!/usr/bin/env node

var Helloworld = require('hook.io-helloworld').Helloworld; 

var hello = new Helloworld({
  name: "the-helloworld-hook",
  debug: true
});

hello.start();

Basic HTTP post / receive Webhook server

http://github.com/marak/hook.io-webhook

#! /usr/bin/env node
var Webhook = require('../lib/webhook').Webhook;

var webhookServer = new Webhook({
  name: 'webhook-server',
  port: 9001,
  debug: true
});

webhookServer.on('hook::ready', function(){
  webhookServer.log(this.name, 'http server listening', "9001");
  webhookServer.on('*::request', function(event, data) {
    webhookServer.log(this.name, event, data);
  });
});

webhookServer.start();

Creating custom Hooks

Super Simple Hook Logger

Try connecting this to your Helloworld Hook. For a multi-transport logger that supports: File, Console, Redis, Mongo, and Loggly, use: http://github.com/hookio/logger

#!/usr/bin/env node

var Hook    = require('hook.io').Hook,
    colors  = require('colors');

var logger = new Hook({ 
  name: 'the-logger-hook'
});

console.log("Note: You can also just set 'debug' mode to true to get a console logger");

logger.start();

logger.on('*::*', function(event, data){
  console.log('custom log event fired' + event + ' ' + JSON.stringify(data))
});

Screencasts coming soon...

Tests

Currently all tests require some setup. Eventually they will be compatible with npat:

  $ cd /path/to/hook.io
  $ npm install forever
  $ [sudo] npm link
  $ cd /path/to/hook.io-helloworld
  $ [sudo] npm link
  $ [sudo] npm link hook.io
  $ cd /path/to/hook.io
  $ [sudo] npm link hook.io-helloworld
  $ vows --spec 

Core Hook.io Team

Marak Squires, Charlie Robbins, Jameson Lee

Contributors (through code and advice)

Substack, h1jinx, AvianFlu, Chapel, Dominic Tarr, Tim Smart, tmpvar, kadir pekel, perezd