Skip to content

Commit

Permalink
properly configured acequia to work with an express instance to serve…
Browse files Browse the repository at this point in the history
… up the REST interface
  • Loading branch information
prgsmall committed Jul 6, 2012
1 parent e1446dc commit 62d6369
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/acequia.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -38,7 +37,7 @@ function AcequiaServer(options) {
wsPort: 9091,
tcpPort: 9092,
timeout: 600000,
webapp: null,
express_app: null,
enableDiscovery: true
}, options || {});

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 62d6369

Please sign in to comment.