├── screenshots └── .gitkeep ├── test ├── memleaks │ └── config.json ├── fixtures │ ├── pingPongModule.js │ ├── browserComments.js │ └── HelloWorld.js ├── spawn │ ├── basic-spawn-optional.js │ └── bad-spawn-test.js ├── messaging │ ├── local │ │ ├── emit-test.js │ │ └── callback-test.js │ └── remote │ │ ├── emit-child-test.js │ │ ├── emit-parent-test.js │ │ ├── callback-child-test.js │ │ ├── callback-parent-test.js │ │ ├── callback-parent-hookname-test.js │ │ └── callback-child-hookname-test.js ├── siblings │ ├── ping-pong-test.js │ ├── message-test.js │ └── multiple-messages-test.js ├── registry │ ├── simple-test.js │ ├── complex-test.js │ └── disconnection-test.js ├── discovery │ └── basic-init-test.js └── logging │ ├── transports-test.js │ └── exception-handlers-test.js ├── lib ├── hookio │ ├── scaffold │ │ ├── config.json │ │ ├── ReadMe.md │ │ ├── bin │ │ │ ├── generate │ │ │ └── scaffold │ │ ├── lib │ │ │ └── scaffold.js │ │ ├── package.json │ │ └── LICENSE │ ├── discovery.js │ ├── commands │ │ ├── list.js │ │ ├── search.js │ │ └── init.js │ ├── transports │ │ └── couchdb.js │ ├── cli.js │ ├── eventMap.js │ ├── npm-api.js │ ├── scaffold.js │ ├── config.js │ └── query.js └── hookio.js ├── vendor ├── dnode-protocol │ ├── .npmignore │ ├── node_modules │ │ ├── traverse │ │ │ ├── .npmignore │ │ │ ├── examples │ │ │ │ ├── negative.js │ │ │ │ ├── scrub.js │ │ │ │ ├── leaves.js │ │ │ │ ├── json.js │ │ │ │ └── stringify.js │ │ │ ├── main.js │ │ │ ├── test │ │ │ │ ├── obj.js │ │ │ │ ├── instance.js │ │ │ │ ├── leaves.js │ │ │ │ ├── negative.js │ │ │ │ ├── keys.js │ │ │ │ ├── date.js │ │ │ │ ├── subexpr.js │ │ │ │ ├── stop.js │ │ │ │ ├── super_deep.js │ │ │ │ ├── stringify.js │ │ │ │ ├── interface.js │ │ │ │ ├── siblings.js │ │ │ │ ├── json.js │ │ │ │ ├── lib │ │ │ │ │ └── deep_equal.js │ │ │ │ └── circular.js │ │ │ ├── package.json │ │ │ └── LICENSE │ │ └── jsonify │ │ │ ├── index.js │ │ │ ├── test │ │ │ ├── stringify.js │ │ │ └── parse.js │ │ │ ├── package.json │ │ │ └── README.markdown │ ├── package.json │ └── test │ │ ├── store.js │ │ ├── args.js │ │ ├── proto.js │ │ ├── fn.js │ │ └── scrub.js ├── dnode │ ├── .npmignore │ ├── examples │ │ ├── chat │ │ │ ├── INSTALL.txt │ │ │ ├── package.json │ │ │ ├── index.html │ │ │ ├── chat.css │ │ │ ├── server.js │ │ │ └── entry.js │ │ ├── simple │ │ │ ├── server.js │ │ │ └── client.js │ │ ├── web-connect │ │ │ ├── server.js │ │ │ └── index.html │ │ ├── web-express │ │ │ ├── server.js │ │ │ └── index.html │ │ ├── perf │ │ │ ├── client.js │ │ │ └── emitter.js │ │ ├── bidirectional │ │ │ ├── server.js │ │ │ └── client.js │ │ ├── web-http │ │ │ ├── index.html │ │ │ └── server.js │ │ ├── web-browserify │ │ │ ├── server.js │ │ │ └── index.html │ │ ├── https │ │ │ ├── index.html │ │ │ └── server.js │ │ ├── auth │ │ │ ├── quotes.json │ │ │ ├── client.js │ │ │ └── server.js │ │ ├── saturate │ │ │ ├── saturate.js │ │ │ └── index.html │ │ └── nested.js │ ├── LICENSE │ ├── test │ │ ├── _id.js │ │ ├── keys │ │ │ ├── agent2-key.pem │ │ │ ├── agent1-key.pem │ │ │ ├── agent1-csr.pem │ │ │ ├── agent2-csr.pem │ │ │ ├── agent2-cert.pem │ │ │ └── agent1-cert.pem │ │ ├── refs.js │ │ ├── unix.js │ │ ├── unicode.js │ │ ├── stream.js │ │ ├── single.js │ │ ├── circular.js │ │ ├── self-referential.js │ │ ├── obj.js │ │ ├── double.js │ │ ├── recon.js │ │ ├── simple.js │ │ ├── bidirectional.js │ │ ├── null.js │ │ ├── middleware.js │ │ ├── gc.js │ │ ├── nested.js │ │ ├── emit.js │ │ ├── broadcast.js │ │ ├── bundle.js │ │ └── error.js │ ├── bin │ │ └── bundle.js │ ├── package.json │ ├── browser │ │ └── index.js │ └── lib │ │ └── stream_socketio.js └── EventEmitter2 │ ├── index.js │ ├── package.json │ └── test │ ├── perf │ └── benchmark.js │ ├── wildcardEvents │ ├── k1.js │ └── options.js │ └── simple │ └── ttl.js ├── .gitignore ├── .travis.yml ├── bin ├── hookio └── forever-shim ├── config.json ├── examples ├── constructors │ ├── bad-options-conflict.js │ ├── child-hooks │ │ ├── hook-single-child.js │ │ ├── hook-many-child-spawn.js │ │ └── hook-custom-child-spawn.js │ ├── hook-redis-config.js │ └── eventMap │ │ └── event-map-hook.js ├── pummel │ ├── listener.js │ ├── master.js │ └── emitter.js ├── spawn │ ├── missing-hook-spawn.js │ ├── single-hook-spawn.js │ ├── many-hook-spawn.js │ ├── simple-hook-spawn.js │ ├── type-hook-spawn.js │ └── custom-hook-spawn.js ├── authentication │ ├── auth-server-noauth-client.js │ └── basic-connection-auth.js ├── discovery │ ├── local-auto-discover.js │ └── find-free-ports.js ├── npm │ ├── local-npm-install.js │ └── remote-npm-install.js ├── messaging │ ├── local │ │ ├── hook-emit.js │ │ └── hook-callback.js │ ├── remote │ │ ├── hook-emit-child-onany.js │ │ ├── hook-emit-parent-onany.js │ │ ├── hook-emit-sender-info.js │ │ ├── hook-emit-child.js │ │ ├── hook-callback-parent.js │ │ ├── hook-emit-parent.js │ │ ├── hook-callback-child.js │ │ ├── hook-callback-parent-hookname.js │ │ └── hook-callback-child-hookname.js │ └── siblings │ │ ├── hook-multiple-messages.js │ │ └── hook-emit-sibling-onany.js ├── disconnect │ ├── hook-server.js │ └── hook-client.js ├── kill │ ├── simple-hook-kill.js │ └── spawn-hook-kill.js ├── stop │ ├── simple-start-stop-start.js │ └── simple-spawn-stop-start.js ├── transports │ └── couchdb-event-transport.js └── query │ └── hook-query.js └── package.json /screenshots/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /test/memleaks/config.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /lib/hookio/scaffold/config.json: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /vendor/dnode-protocol/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /lib/hookio/scaffold/ReadMe.md: -------------------------------------------------------------------------------- 1 | # Unreleased, please come back later. -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /vendor/dnode/.npmignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .git/* 3 | *.swp 4 | *.swo 5 | -------------------------------------------------------------------------------- /vendor/EventEmitter2/index.js: -------------------------------------------------------------------------------- 1 | module.exports = require('./lib/eventemitter2'); 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.swp 3 | tags 4 | node_modules/ 5 | node_modules/* 6 | npm-debug.log 7 | test/config.json -------------------------------------------------------------------------------- /vendor/dnode/examples/chat/INSTALL.txt: -------------------------------------------------------------------------------- 1 | Do this first: 2 | 3 | mkdir node_modules 4 | npm install jquery-browserify 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - 0.6 4 | - 0.7 5 | 6 | notifications: 7 | email: 8 | - travis@nodejitsu.com 9 | -------------------------------------------------------------------------------- /test/fixtures/pingPongModule.js: -------------------------------------------------------------------------------- 1 | var pingPong = exports; 2 | 3 | pingPong.ping = function (msg) { 4 | console.log(msg); 5 | return msg; 6 | }; -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/jsonify/index.js: -------------------------------------------------------------------------------- 1 | exports.parse = require('./lib/parse'); 2 | exports.stringify = require('./lib/stringify'); 3 | -------------------------------------------------------------------------------- /bin/hookio: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var Hook = require('../lib/hookio').Hook; 4 | 5 | var hook = new Hook( { 6 | name: 'the-hook' 7 | }); 8 | 9 | hook.start(); -------------------------------------------------------------------------------- /config.json: -------------------------------------------------------------------------------- 1 | { 2 | "test": { 3 | "foo": "hello config" 4 | }, 5 | 6 | "logger" : { 7 | "transports" : { 8 | "console" : {} 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /vendor/dnode/examples/simple/server.js: -------------------------------------------------------------------------------- 1 | var dnode = require('dnode'); 2 | 3 | var server = dnode({ 4 | zing : function (n, cb) { cb(n * 100) } 5 | }); 6 | server.listen(7070); 7 | -------------------------------------------------------------------------------- /vendor/dnode/examples/chat/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "dependencies" : { 3 | "jquery-browserify" : "*", 4 | "browserify" : "1.0.x", 5 | "express" : "0.7.x" 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /vendor/dnode/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2010 James Halliday (mail@substack.net) 2 | 3 | This project is free software released under the MIT license: 4 | http://www.opensource.org/licenses/mit-license.php 5 | -------------------------------------------------------------------------------- /lib/hookio/scaffold/bin/generate: -------------------------------------------------------------------------------- 1 | var introspect = require('../lib/introspect'); 2 | 3 | // 4 | // Remark: This will generate a new hook called "testh" in the /generate/ folder 5 | // 6 | introspect.generate('testh'); -------------------------------------------------------------------------------- /lib/hookio/scaffold/bin/scaffold: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var Scaffold = require('../lib/scaffold').Scaffold; 4 | 5 | var scaffold = new Scaffold({ 6 | name: 'the-scaffold' 7 | }); 8 | 9 | scaffold.start(); -------------------------------------------------------------------------------- /vendor/dnode/examples/simple/client.js: -------------------------------------------------------------------------------- 1 | var dnode = require('dnode'); 2 | 3 | dnode.connect(7070, function (remote, conn) { 4 | remote.zing(33, function (n) { 5 | console.log('n = ' + n); 6 | conn.end(); 7 | }); 8 | }); 9 | -------------------------------------------------------------------------------- /examples/constructors/bad-options-conflict.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | var Hook = require('../../lib/hookio').Hook; 4 | 5 | var hook = new Hook( { 6 | name: 'the-hook', 7 | debug: true, 8 | emit: false 9 | }); 10 | 11 | 12 | hook.start(); 13 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/examples/negative.js: -------------------------------------------------------------------------------- 1 | var traverse = require('traverse'); 2 | var obj = [ 5, 6, -3, [ 7, 8, -2, 1 ], { f : 10, g : -13 } ]; 3 | 4 | traverse(obj).forEach(function (x) { 5 | if (x < 0) this.update(x + 128); 6 | }); 7 | 8 | console.dir(obj); 9 | -------------------------------------------------------------------------------- /examples/constructors/child-hooks/hook-single-child.js: -------------------------------------------------------------------------------- 1 | 2 | var Hook = require('../../../lib/hookio').Hook; 3 | 4 | var hook = new Hook({ 5 | name: "hook", 6 | hooks: ["helloworld"] 7 | }); 8 | 9 | hook.on('hook::ready', function () { 10 | console.log('hook ready'); 11 | }); 12 | 13 | hook.start(); 14 | -------------------------------------------------------------------------------- /lib/hookio/discovery.js: -------------------------------------------------------------------------------- 1 | var hookio = require('./hook'), 2 | async = require('async'), 3 | path = require('path'), 4 | portfinder = require('portfinder'), 5 | discovery = exports; 6 | 7 | discovery.ports = {}; 8 | 9 | discovery.ports.find = portfinder.getPort; 10 | 11 | 12 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/main.js: -------------------------------------------------------------------------------- 1 | // scrub out circular references 2 | var traverse = require('./index.js'); 3 | 4 | var obj = { a : 1, b : 2, c : [ 3, 4 ] }; 5 | obj.c.push(obj); 6 | 7 | var scrubbed = traverse(obj).map(function (x) { 8 | if (this.circular) this.remove() 9 | }); 10 | console.dir(scrubbed); 11 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/examples/scrub.js: -------------------------------------------------------------------------------- 1 | // scrub out circular references 2 | var traverse = require('traverse'); 3 | 4 | var obj = { a : 1, b : 2, c : [ 3, 4 ] }; 5 | obj.c.push(obj); 6 | 7 | var scrubbed = traverse(obj).map(function (x) { 8 | if (this.circular) this.remove() 9 | }); 10 | console.dir(scrubbed); 11 | -------------------------------------------------------------------------------- /examples/constructors/child-hooks/hook-many-child-spawn.js: -------------------------------------------------------------------------------- 1 | 2 | var Hook = require('../../../lib/hookio').Hook; 3 | 4 | var hook = new Hook({ 5 | name: "hook", 6 | hooks: ["helloworld", "helloworld", "helloworld", "helloworld"] 7 | }); 8 | 9 | hook.on('hook::ready', function () { 10 | console.log('hook ready'); 11 | }); 12 | 13 | hook.start(); 14 | -------------------------------------------------------------------------------- /examples/pummel/listener.js: -------------------------------------------------------------------------------- 1 | var Hook = require('../../lib/hookio').Hook; 2 | var util = require('util'); 3 | 4 | var Slave = exports.Slave = function (options) { 5 | self = this; 6 | Hook.call(this, options); 7 | this.on('hook::ready', function () { 8 | this.on('*::someEvent', function (msg) { 9 | }) 10 | }); 11 | } 12 | 13 | util.inherits(Slave, Hook); -------------------------------------------------------------------------------- /examples/spawn/missing-hook-spawn.js: -------------------------------------------------------------------------------- 1 | var hookio = require('../../lib/hookio'); 2 | 3 | var master = hookio.createHook({ 4 | "name": "master-hook", 5 | "hooks": [ 6 | { "type" : "request" }, 7 | { "type" : "none-exist" }, 8 | 9 | ] 10 | }); 11 | 12 | master.on('spawn::error', function(err){ 13 | console.log(err) 14 | }); 15 | 16 | master.listen(); 17 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/examples/leaves.js: -------------------------------------------------------------------------------- 1 | var traverse = require('traverse'); 2 | 3 | var obj = { 4 | a : [1,2,3], 5 | b : 4, 6 | c : [5,6], 7 | d : { e : [7,8], f : 9 }, 8 | }; 9 | 10 | var leaves = traverse(obj).reduce(function (acc, x) { 11 | if (this.isLeaf) acc.push(x); 12 | return acc; 13 | }, []); 14 | 15 | console.dir(leaves); 16 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-connect/server.js: -------------------------------------------------------------------------------- 1 | var connect = require('connect'); 2 | var dnode = require('dnode'); 3 | 4 | var server = connect.createServer(); 5 | server.use(connect.static(__dirname)); 6 | 7 | dnode(function (client) { 8 | this.cat = function (cb) { 9 | cb('meow '); 10 | }; 11 | }).listen(server); 12 | 13 | server.listen(6857); 14 | console.log('http://localhost:6857/'); 15 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-express/server.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var server = express.createServer(); 3 | var dnode = require('dnode'); 4 | 5 | server.use(express.static(__dirname)); 6 | 7 | dnode(function (client) { 8 | this.cat = function (cb) { 9 | cb('meow'); 10 | }; 11 | }).listen(server); 12 | 13 | server.listen(6857); 14 | console.log('http://localhost:6857/'); 15 | -------------------------------------------------------------------------------- /vendor/dnode/examples/perf/client.js: -------------------------------------------------------------------------------- 1 | var frames = 0, last = 0; 2 | setInterval(function () { 3 | if (last) { 4 | var fps = frames / (Date.now() - last) * 1000; 5 | console.log('fps: ' + fps); 6 | } 7 | 8 | last = Date.now(); 9 | frames = 0; 10 | }, 1000); 11 | 12 | var dnode = require('dnode'); 13 | dnode({ 14 | emit : function (i) { frames ++ } 15 | }).connect(7575); 16 | -------------------------------------------------------------------------------- /test/fixtures/browserComments.js: -------------------------------------------------------------------------------- 1 | /* 2 | hook.io - http://hook.io 3 | (C) 2011 Nodejitsu Inc. 4 | MIT LICENCE 5 | THIS FILE WAS AUTOGENERATED ON {{newDate}} 6 | BUILD ID: {{newDateUnix}} 7 | 8 | WARNING: THIS FILE WAS AUTOGENERATED BY THE HOOKIO BROWSERIFY SCRIPT 9 | MODIFYING THIS FILE IS FINE, BUT YOU REALLY SHOULD BE MODIFYING 10 | THE LIBRARY DIRECTLY AND REGENERATING IT USING "bin/browserify" 11 | 12 | */ -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/jsonify/test/stringify.js: -------------------------------------------------------------------------------- 1 | var test = require('tap').test; 2 | var json = require('../'); 3 | var garbage = require('garbage'); 4 | 5 | test('stringify', function (t) { 6 | for (var i = 0; i < 50; i++) { 7 | var obj = garbage(50); 8 | t.equal( 9 | json.stringify(obj), 10 | JSON.stringify(obj) 11 | ); 12 | } 13 | 14 | t.end(); 15 | }); 16 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/jsonify/test/parse.js: -------------------------------------------------------------------------------- 1 | var test = require('tap').test; 2 | var json = require('../'); 3 | var garbage = require('garbage'); 4 | 5 | test('parse', function (t) { 6 | for (var i = 0; i < 50; i++) { 7 | var s = JSON.stringify(garbage(50)); 8 | 9 | t.deepEqual( 10 | json.parse(s), 11 | JSON.parse(s) 12 | ); 13 | } 14 | 15 | t.end(); 16 | }); 17 | -------------------------------------------------------------------------------- /lib/hookio.js: -------------------------------------------------------------------------------- 1 | /* 2 | * hookio.js: Top-level include for the hookio module. 3 | * 4 | * (C) 2011 Nodejitsu Inc. 5 | * MIT LICENCE 6 | * 7 | */ 8 | 9 | var hookio = exports; 10 | 11 | // 12 | // Export the core `hookio` components. 13 | // 14 | hookio.cli = require('./hookio/cli'); 15 | hookio.Hook = require('./hookio/hook').Hook; 16 | 17 | hookio.createHook = function (options) { 18 | var hook = new hookio.Hook(options); 19 | return hook; 20 | }; -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/test/obj.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var Traverse = require('../'); 3 | 4 | exports['traverse an object with nested functions'] = function () { 5 | var to = setTimeout(function () { 6 | assert.fail('never ran'); 7 | }, 1000); 8 | 9 | function Cons (x) { 10 | clearTimeout(to); 11 | assert.equal(x, 10); 12 | }; 13 | Traverse(new Cons(10)); 14 | }; 15 | 16 | -------------------------------------------------------------------------------- /vendor/dnode/examples/bidirectional/server.js: -------------------------------------------------------------------------------- 1 | var dnode = require('dnode'); 2 | 3 | dnode(function (client) { 4 | // Poll the client's own temperature() in celsius and convert that value to 5 | // fahrenheit in the supplied callback 6 | this.clientTempF = function (cb) { 7 | client.temperature(function (degC) { 8 | var degF = Math.round(degC * 9 / 5 + 32); 9 | cb(degF); 10 | }); 11 | }; 12 | }).listen(6060); 13 | -------------------------------------------------------------------------------- /examples/authentication/auth-server-noauth-client.js: -------------------------------------------------------------------------------- 1 | var hookio = require('../../lib/hookio'); 2 | 3 | hookio.createHook({ 4 | authorize: customAuth 5 | }).listen(); 6 | 7 | 8 | hookio.createHook().connect(); 9 | 10 | 11 | function customAuth(user, password, cb) { 12 | console.log('running custom auth') 13 | if (user == 'marak' && pass == 'test') { 14 | console.log(user, ' succeeded!'); 15 | } 16 | else { 17 | console.log(user, ' failed!'); 18 | cb(null); 19 | } 20 | } -------------------------------------------------------------------------------- /vendor/dnode/examples/web-http/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 13 | 14 | 15 | The cat says ?. 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/examples/json.js: -------------------------------------------------------------------------------- 1 | var traverse = require('traverse'); 2 | 3 | var id = 54; 4 | var callbacks = {}; 5 | var obj = { moo : function () {}, foo : [2,3,4, function () {}] }; 6 | 7 | var scrubbed = traverse(obj).map(function (x) { 8 | if (typeof x === 'function') { 9 | callbacks[id] = { id : id, f : x, path : this.path }; 10 | this.update('[Function]'); 11 | id++; 12 | } 13 | }); 14 | 15 | console.dir(scrubbed); 16 | console.dir(callbacks); 17 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-connect/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | The cat says ?. 16 | 17 | 18 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-express/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 13 | 14 | 15 | The cat says ?. 16 | 17 | 18 | -------------------------------------------------------------------------------- /examples/discovery/local-auto-discover.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | var Hook = require('../../lib/hookio').Hook; 6 | 7 | 8 | var hook1 = new Hook({ 9 | name: "server-hook", 10 | debug: true 11 | }); 12 | 13 | var hook2 = new Hook({ 14 | name: "callback-hook", 15 | debug: true 16 | }); 17 | 18 | 19 | hook1.on('hook::ready', function () { 20 | console.log('hook1 is ready'); 21 | hook2.on('hook::ready', function () { 22 | console.log('hook2 is ready'); 23 | }); 24 | hook2.start(); 25 | }); 26 | 27 | hook1.start(); -------------------------------------------------------------------------------- /examples/discovery/find-free-ports.js: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | */ 4 | 5 | var Hook = require('../../lib/hookio').Hook; 6 | 7 | 8 | var hook = new Hook({ 9 | name: "server-hook", 10 | debug: true 11 | }); 12 | 13 | 14 | // Default options 15 | hook.findPort(function(err, result){ 16 | console.log(err, result); 17 | }) 18 | 19 | // Specific port start 20 | hook.findPort({ port: 9000 },function(err, result){ 21 | console.log(err, result); 22 | }) 23 | 24 | // Specific range 25 | // TODO: Patcy node-portfinder to support max ranges of ports 26 | -------------------------------------------------------------------------------- /examples/npm/local-npm-install.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Creates a hook, then installs the `helloworld` hook from npm 3 | */ 4 | 5 | var Hook = require('../../lib/hookio').Hook; 6 | 7 | var myHello = new Hook({ name: "the-hook", debug: true }); 8 | 9 | myHello.on('hook::ready', function () { 10 | myHello.npm.install('hook.io-helloworld', function (err, result) { 11 | if (err) { 12 | return myHello.emit('npm::install::error', err); 13 | } 14 | myHello.emit('npm::installed', result); 15 | }); 16 | }); 17 | 18 | myHello.start(); 19 | -------------------------------------------------------------------------------- /vendor/dnode/test/_id.js: -------------------------------------------------------------------------------- 1 | var dnode = require('../'); 2 | var test = require('tap').test; 3 | 4 | test('_id', function (t) { 5 | t.plan(1); 6 | var port = Math.floor(Math.random() * 40000 + 10000); 7 | 8 | var server = dnode({ _id : 1337 }).listen(port); 9 | 10 | server.on('ready', function () { 11 | dnode.connect(port, function (remote, conn) { 12 | t.equal(remote._id, 1337); 13 | conn.end(); 14 | server.close(); 15 | t.end(); 16 | }); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /examples/spawn/single-hook-spawn.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Creates a helloworld hook, then spawns up a single helloworld child 3 | */ 4 | 5 | var Helloworld = require('hook.io-helloworld').Helloworld; 6 | 7 | var myHello = new Helloworld({ name: "helloworld" }); 8 | 9 | myHello.on('hook::ready', function () { 10 | 11 | // 12 | // This will spawn up one "helloworld" hook with auto-configuration 13 | // see: custom-hook-spawn.js for customized spawn settings 14 | // 15 | // 16 | myHello.spawn('helloworld'); 17 | 18 | }); 19 | 20 | myHello.start(); -------------------------------------------------------------------------------- /vendor/dnode/test/keys/agent2-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIBOgIBAAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf+6fVgdpVhYg5 3 | QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAQJBAMT6Bf34+UHKY1ObpsbH 4 | 9u2jsVblFq1rWvs8GPMY6oertzvwm3DpuSUp7PTgOB1nLTLYtCERbQ4ovtN8tn3p 5 | OHUCIQDzIEGsoCr5vlxXvy2zJwu+fxYuhTZWMVuo1397L0VyhwIhANQh+yzqUgaf 6 | WRtSB4T2W7ADtJI35ET61jKBty3CqJY3AiAIwju7dVW3A5WeD6Qc1SZGKZvp9yCb 7 | AFI2BfVwwaY11wIgXF3PeGcvACMyMWsuSv7aPXHfliswAbkWuzcwA4TW01ECIGWa 8 | cgsDvVFxmfM5NPSuT/UDTa6R5BFISB5ea0N0AR3I 9 | -----END RSA PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-browserify/server.js: -------------------------------------------------------------------------------- 1 | var connect = require('connect'); 2 | var browserify = require('browserify'); 3 | var dnode = require('dnode'); 4 | 5 | var server = connect.createServer(); 6 | 7 | server.use(connect.static(__dirname)); 8 | 9 | server.use(browserify({ 10 | require : 'dnode', 11 | mount : '/browserify.js' 12 | })); 13 | 14 | dnode(function (client) { 15 | this.cat = function (cb) { 16 | cb('meow'); 17 | }; 18 | }).listen(server); 19 | 20 | server.listen(6857); 21 | console.log('http://localhost:6857/'); 22 | -------------------------------------------------------------------------------- /vendor/dnode/test/keys/agent1-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | MIIBOwIBAAJBAJ86QKnKF2cVic/1hSuwV8A9t45URMhtdce4JMnbXh75+j61QWwe 3 | cn7unG5PMN/wK+tPAHMjEPbx45C0Ch+3IxECAwEAAQJBAI2cU1IuR+4IO87WPyAB 4 | 76kruoo87AeNQkjjvuQ/00+b/6IS45mcEP5Kw0NukbqBhIw2di9uQ9J51DJ/ZfQr 5 | +YECIQDUHaN3ZjIdJ7/w8Yq9Zzz+3kY2F/xEz6e4ftOFW8bY2QIhAMAref+WYckC 6 | oECgOLAvAxB1lI4j7oCbAaawfxKdnPj5AiEAi95rXx09aGpAsBGmSdScrPdG1v6j 7 | 83/2ebrvoZ1uFqkCIB0AssnrRVjUB6GZTNTyU3ERfdkx/RX1zvr8WkFR/lXpAiB7 8 | cUZ1i8ZkZrPrdVgw2cb28UJM7qZHQnXcMHTXFFvxeQ== 9 | -----END RSA PRIVATE KEY----- 10 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/test/instance.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var Traverse = require('../'); 3 | var EventEmitter = require('events').EventEmitter; 4 | 5 | exports['check instanceof on node elems'] = function () { 6 | 7 | var counts = { emitter : 0 }; 8 | 9 | Traverse([ new EventEmitter, 3, 4, { ev : new EventEmitter }]) 10 | .forEach(function (node) { 11 | if (node instanceof EventEmitter) counts.emitter ++; 12 | }) 13 | ; 14 | 15 | assert.equal(counts.emitter, 2); 16 | }; 17 | 18 | -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/test/leaves.js: -------------------------------------------------------------------------------- 1 | var assert = require('assert'); 2 | var Traverse = require('../'); 3 | 4 | exports['leaves test'] = function () { 5 | var acc = []; 6 | Traverse({ 7 | a : [1,2,3], 8 | b : 4, 9 | c : [5,6], 10 | d : { e : [7,8], f : 9 } 11 | }).forEach(function (x) { 12 | if (this.isLeaf) acc.push(x); 13 | }); 14 | 15 | assert.equal( 16 | acc.join(' '), 17 | '1 2 3 4 5 6 7 8 9', 18 | 'Traversal in the right(?) order' 19 | ); 20 | }; 21 | 22 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-browserify/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 15 | 16 | 17 | The cat says ?. 18 | 19 | 20 | -------------------------------------------------------------------------------- /examples/constructors/child-hooks/hook-custom-child-spawn.js: -------------------------------------------------------------------------------- 1 | var Hook = require('../../../lib/hookio').Hook; 2 | 3 | var hook = new Hook({ 4 | name: "hook", 5 | hooks: [ 6 | { 7 | type: 'helloworld', 8 | name: 'b', 9 | foo: "bar" 10 | }, 11 | { 12 | type: 'helloworld', 13 | name: 'c', 14 | beep: "boop" 15 | }, 16 | { 17 | type: 'helloworld', 18 | name: 'd' 19 | } 20 | ] 21 | }); 22 | 23 | hook.on('hook::ready', function () { 24 | console.log('hook ready'); 25 | }); 26 | 27 | hook.start(); 28 | -------------------------------------------------------------------------------- /examples/spawn/many-hook-spawn.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Creates a helloworld hook, then spawns three helloworld children 3 | */ 4 | 5 | var Helloworld = require('hook.io-helloworld').Helloworld; 6 | 7 | var myHello = new Helloworld({ name: "helloworld" }); 8 | 9 | myHello.on('hook::ready', function () { 10 | 11 | // 12 | // This will spawn up three more "helloworld" hooks with auto-configuration 13 | // see: custom-hook-spawn.js for customized spawn settings 14 | // 15 | // 16 | myHello.spawn(['helloworld', 'helloworld', 'helloworld']); 17 | 18 | }); 19 | 20 | myHello.start(); -------------------------------------------------------------------------------- /examples/spawn/simple-hook-spawn.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Creates a helloworld hook, then spawns three helloworld children 3 | */ 4 | 5 | var Helloworld = require('hook.io-helloworld').Helloworld; 6 | 7 | var myHello = new Helloworld({ name: "helloworld" }); 8 | 9 | myHello.on('hook::ready', function () { 10 | 11 | // 12 | // This will spawn up three more "helloworld" hooks with auto-configuration 13 | // see: custom-hook-spawn.js for customized spawn settings 14 | // 15 | // 16 | myHello.spawn(['helloworld', 'helloworld', 'helloworld']); 17 | 18 | }); 19 | 20 | myHello.start(); -------------------------------------------------------------------------------- /vendor/dnode-protocol/node_modules/traverse/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name" : "traverse", 3 | "version" : "0.5.2", 4 | "description" : "Traverse and transform objects by visiting every node on a recursive walk", 5 | "author" : "James Halliday", 6 | "license" : "MIT/X11", 7 | "main" : "./index", 8 | "repository" : { 9 | "type" : "git", 10 | "url" : "http://github.com/substack/js-traverse.git" 11 | }, 12 | "devDependencies" : { 13 | "expresso" : "0.7.x" 14 | }, 15 | "scripts" : { 16 | "test" : "expresso" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /examples/messaging/local/hook-emit.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple example for basic Hook.emit syntax 3 | */ 4 | 5 | var Hook = require('../../../lib/hookio').Hook; 6 | 7 | 8 | var hook1 = new Hook({ 9 | name: "server-hook", 10 | debug: true 11 | }); 12 | 13 | hook1.on('hello', function (data, callback) { 14 | console.log('calling result back ', data); 15 | callback(null, data); 16 | }) 17 | 18 | hook1.on('hook::ready', function () { 19 | hook1.on('hello::result', function (data) { 20 | console.log('got back ', data); 21 | }); 22 | hook1.emit('hello', 'world'); 23 | }); 24 | 25 | hook1.start(); -------------------------------------------------------------------------------- /examples/npm/remote-npm-install.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Creates `hook1` and `hook2`. `hook1` then remotely installs a NPM package on `hook2` 3 | */ 4 | 5 | var Hook = require('../../lib/hookio').Hook; 6 | 7 | var hook1 = new Hook({ 8 | name: "hook1", 9 | debug: true 10 | }); 11 | 12 | hook1.on('hook::ready', function () { 13 | 14 | var hook2 = new Hook({ 15 | name: "hook2", 16 | debug: true 17 | }); 18 | 19 | hook2.start(); 20 | 21 | hook2.on('hook::ready', function () { 22 | hook1.emit('install', 'hook.io-helloworld'); 23 | }); 24 | 25 | }); 26 | 27 | hook1.start(); 28 | -------------------------------------------------------------------------------- /vendor/dnode/examples/web-http/server.js: -------------------------------------------------------------------------------- 1 | var http = require('http'); 2 | var fs = require('fs'); 3 | var dnode = require('dnode'); 4 | 5 | var index = fs.readFileSync(__dirname + '/index.html'); 6 | 7 | var server = http.createServer(function (req, res) { 8 | if (req.url === '/') { 9 | res.writeHead(200, { 'Content-Type' : 'text/html' }); 10 | res.end(index); 11 | } 12 | }); 13 | 14 | dnode(function (client) { 15 | this.cat = function (cb) { 16 | cb('meow'); 17 | }; 18 | }).listen(server); 19 | 20 | server.listen(6857); 21 | console.log('http://localhost:6857/'); 22 | -------------------------------------------------------------------------------- /vendor/dnode/test/keys/agent1-csr.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH 3 | EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD 4 | EwZhZ2VudDExIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ 5 | KoZIhvcNAQEBBQADSwAwSAJBAJ86QKnKF2cVic/1hSuwV8A9t45URMhtdce4JMnb 6 | Xh75+j61QWwecn7unG5PMN/wK+tPAHMjEPbx45C0Ch+3IxECAwEAAaAlMCMGCSqG 7 | SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB 8 | AF+AfG64hNyYHum46m6i7RgnUBrJSOynGjs23TekV4he3QdMSAAPPqbll8W14+y3 9 | vOo7/yQ2v2uTqxCjakUNPPs= 10 | -----END CERTIFICATE REQUEST----- 11 | -------------------------------------------------------------------------------- /vendor/dnode/test/keys/agent2-csr.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE REQUEST----- 2 | MIIBXTCCAQcCAQAwfTELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAkNBMQswCQYDVQQH 3 | EwJTRjEPMA0GA1UEChMGSm95ZW50MRAwDgYDVQQLEwdOb2RlLmpzMQ8wDQYDVQQD 4 | EwZhZ2VudDIxIDAeBgkqhkiG9w0BCQEWEXJ5QHRpbnljbG91ZHMub3JnMFwwDQYJ 5 | KoZIhvcNAQEBBQADSwAwSAJBAMl2/Ba0XSm4ayi4C0rJ+tYtQu8O31VVXezkLJlf 6 | +6fVgdpVhYg5QlihlPUoiM/wOsDWQ1ALnNhPlcLaQk+etQECAwEAAaAlMCMGCSqG 7 | SIb3DQEJBzEWExRBIGNoYWxsZW5nZSBwYXNzd29yZDANBgkqhkiG9w0BAQUFAANB 8 | AJnll2pt5l0pzskQSpjjLVTlFDFmJr/AZ3UK8v0WxBjYjCe5Jx4YehkChpxIyDUm 9 | U3J9q9MDUf0+Y2+EGkssFfk= 10 | -----END CERTIFICATE REQUEST----- 11 | -------------------------------------------------------------------------------- /vendor/dnode/examples/perf/emitter.js: -------------------------------------------------------------------------------- 1 | var dnode = require('dnode'); 2 | var EventEmitter = require('events').EventEmitter; 3 | 4 | var clients = {}; 5 | setInterval(function () { 6 | Object.keys(clients).forEach(function (id) { 7 | var i = Math.floor(Math.random() * Math.pow(2,32)); 8 | clients[id].emit(i); 9 | }); 10 | }, 1000 / 50); // 50 fps 11 | 12 | dnode(function (client, conn) { 13 | conn.on('ready', function () { 14 | clients[conn.id] = client; 15 | }); 16 | 17 | conn.on('end', function () { 18 | delete clients[conn.id]; 19 | }); 20 | }).listen(7575); 21 | -------------------------------------------------------------------------------- /vendor/dnode/test/refs.js: -------------------------------------------------------------------------------- 1 | var dnode = require('../'); 2 | var test = require('tap').test; 3 | 4 | test('refs', function (t) { 5 | t.plan(2); 6 | var port = Math.floor(Math.random() * 40000 + 10000); 7 | 8 | var server = dnode({ 9 | a : 1, 10 | b : 2, 11 | }).listen(port); 12 | 13 | server.on('ready', function () { 14 | dnode.connect(port, function (remote, conn) { 15 | conn.end(); 16 | server.close(); 17 | t.equal(remote.a, 1); 18 | t.equal(remote.b, 2); 19 | t.end(); 20 | }); 21 | }); 22 | }); 23 | -------------------------------------------------------------------------------- /examples/constructors/hook-redis-config.js: -------------------------------------------------------------------------------- 1 | 2 | var Hook = require('../../lib/hookio').Hook; 3 | 4 | var hook = new Hook({ 5 | redis: { 6 | host: 'localhost', 7 | port: 6379, 8 | db: 0, 9 | namespace: 'hookio' 10 | } 11 | }); 12 | 13 | /* 14 | We have the following redis keys in our redis db 15 | * hookio:name -> 'myhook' 16 | * hookio:type -> 'hook' 17 | 18 | It is equivalent to 19 | 20 | var hook = new Hook({ 21 | name: 'myhook', 22 | type: 'hook' 23 | }); 24 | */ 25 | 26 | hook.on('hook::ready', function () { 27 | console.log('hook ready'); 28 | }); 29 | 30 | hook.start(); 31 | -------------------------------------------------------------------------------- /lib/hookio/scaffold/lib/scaffold.js: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | hook.io hook for creating hook.io hooks 4 | 5 | ( the scaffold generates new hooks by inspecting itself ) 6 | 7 | */ 8 | 9 | 10 | var Hook = require('hook.io').Hook, 11 | util = require('util'); 12 | 13 | var Scaffold = exports.Scaffold = function(options){ 14 | Hook.call(this, options); 15 | var self = this; 16 | }; 17 | 18 | // Scaffold inherits from Hook 19 | util.inherits(Scaffold, Hook); 20 | 21 | Scaffold.prototype.doSomething = function(options, callback){ 22 | 23 | }; 24 | 25 | Scaffold.prototype.doSomethingElse = function(options, callback){ 26 | 27 | }; -------------------------------------------------------------------------------- /examples/spawn/type-hook-spawn.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Hook type spawning 3 | */ 4 | 5 | var Helloworld = require('hook.io-helloworld').Helloworld; 6 | 7 | 8 | var myHello = new Helloworld({ 9 | name: "a", 10 | debug: true 11 | }); 12 | 13 | myHello.on('hook::ready', function () { 14 | 15 | myHello.spawn([ 16 | { 17 | type: 'helloworld', 18 | name: 'b', 19 | foo: "bar" 20 | }, 21 | { 22 | type: 'helloworld', 23 | name: 'c', 24 | beep: "boop" 25 | }, 26 | { 27 | type: 'helloworld', 28 | name: 'd' 29 | } 30 | ]); 31 | 32 | }); 33 | 34 | myHello.start(); -------------------------------------------------------------------------------- /examples/pummel/master.js: -------------------------------------------------------------------------------- 1 | var Hook = require('../../lib/hookio').Hook; 2 | //var profiler = require('v8-profiler'); 3 | 4 | var hook = new Hook( { 5 | name: 'MemLeakMaster', 6 | silent: true, 7 | local:true, 8 | oneway:true 9 | }); 10 | 11 | hook.on('hook::ready', function () { 12 | hook.spawn([ 13 | { 14 | src: '../emitter.js', 15 | name:'emitter', 16 | silent: true, 17 | oneway: true 18 | }, 19 | { src: '../listener.js',name:'listener', silent:true, oneway:true}, 20 | { src: '../listener.js',name:'listener', silent:true, oneway:true} 21 | ]); 22 | }); 23 | 24 | hook.start(); 25 | -------------------------------------------------------------------------------- /lib/hookio/scaffold/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "author": "Marak SquirestimesTen(10) == ?
16 |My name is ?.
17 | -------------------------------------------------------------------------------- /vendor/dnode/examples/chat/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |