From 62d6369019c2d63d8a801af34b1d319c62e08856 Mon Sep 17 00:00:00 2001 From: "Peter R. G. Small" Date: Fri, 6 Jul 2012 15:52:31 -0600 Subject: [PATCH] properly configured acequia to work with an express instance to serve up the REST interface --- lib/acequia.js | 23 +++++++++++------------ package.json | 1 + 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/acequia.js b/lib/acequia.js index dc0d6af..572a2ab 100644 --- a/lib/acequia.js +++ b/lib/acequia.js @@ -11,7 +11,6 @@ var http = require("http"), tuio = require("./tuio"), Buffer = require('buffer').Buffer, express = require("express"), - genclient = require("./genclient"), datastore = require("./datastore"), objCallback = require("./utils").objCallback, uid = require("./utils").uid; @@ -38,7 +37,7 @@ function AcequiaServer(options) { wsPort: 9091, tcpPort: 9092, timeout: 600000, - webapp: null, + express_app: null, enableDiscovery: true }, options || {}); @@ -257,22 +256,21 @@ AcequiaServer.prototype.createWSServer = function () { if (!clientCode) { // Generate the client code - clientCode = genclient.generateClientCode(); + clientCode = require("./genclient").generateClientCode(); } - if (!this.options.webapp) { - this.options.webapp = express.createServer(); - io = require('socket.io').listen(httpServer); - } - - app = this.options.webapp; - + if (!this.options.express_app) { + this.options.express_app = express.createServer(); + } + app = this.options.express_app; + app.configure(function(){ - app.use(express["static"](__dirname + '/../public')); + app.use(express["static"](__dirname + '/../test')); app.use(express.methodOverride()); app.use(express.bodyParser()); app.use(app.router); }); + app.listen(this.options.wsPort); app.get('/', function (req, res) { @@ -310,7 +308,8 @@ AcequiaServer.prototype.createWSServer = function () { app.on("listening", function (data) { logger.debug(" WS Server is listening on [%s:%s]", this.address().address, this.address().port); }); - + + io = require('socket.io').listen(app); io.configure(function () { io.enable('browser client minification'); // send minified client diff --git a/package.json b/package.json index 245d928..9dfa9d8 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,7 @@ , "engines": { "node": ">=0.6" } , "dependencies" : { "log4js" : ">=0.4.1" + , "express": "2.5.8" , "socket.io": ">=0.9.6" , "socket.io-client":">=0.9.6" , "uglify-js": ">=1.2.5"