Skip to content

Commit

Permalink
Change binary API
Browse files Browse the repository at this point in the history
  • Loading branch information
pvorb committed Feb 27, 2012
1 parent 8558b94 commit a50c410
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 8 additions & 8 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ module.exports = function(version) {
if (version !== 'http' && version !== 'https')
throw new Error(version + ' not supported.');

var util = require('util'),
http = require(version),
url = require('url'),
api = {};
var util = require('util');
var http = require(version);
var url = require('url');
var api = {};

// API Server inherits EventEmitter
function Server () {
Expand All @@ -21,8 +21,8 @@ function Server () {
// Listen for any request and map the request to it's own event.
// 'regularRequest' is emitted, when there are no listeners for the event.
this.addListener('request', function(req, resp) {
var method,
path;
var method;
var path;

req.urlParsed = url.parse(req.url, true, true);
path = req.urlParsed.pathname;
Expand All @@ -34,8 +34,8 @@ function Server () {
if (method = this.methods[req.method])
// for each listener of method
for (var listener in method) {
var match,
p = method[listener].pattern;
var match;
var p = method[listener].pattern;

// match it
if ((match = p.exec(req.url)) != null) {
Expand Down
9 changes: 7 additions & 2 deletions bin/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@ confdir(process.cwd(), 'conf', function (err, confdir) {

var modConf = JSON.parse(data);

console.log('Starting module '+mod+'.');
// hook module into app
module(app, log, modConf, conf);
console.log('Module '+mod+' up and running.');
module(app, log, modConf, conf, function (err) {
if (err)
return die(err);

console.log('Module '+mod+' up and running.');
});
});
});

Expand Down

0 comments on commit a50c410

Please sign in to comment.