From f64cbebe8db5ea85fe19e607fad52b9356d967d6 Mon Sep 17 00:00:00 2001 From: administrator Date: Thu, 1 May 2014 09:08:57 -0700 Subject: [PATCH 1/3] Fix for exception error when null options are passed Also updated package.json to be platform independent --- lib/index.coffee | 5 ++--- package.json | 8 ++++---- scripts/prepublish.js | 4 ++++ 3 files changed, 10 insertions(+), 7 deletions(-) create mode 100644 scripts/prepublish.js diff --git a/lib/index.coffee b/lib/index.coffee index eecfe2c..8e85217 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -17,11 +17,10 @@ session = express.session delete express.session sessionConfig = new Object express.session = (options) -> - options ?= new Object + options ?= '' options.key ?= 'connect.sid' options.store ?= new session.MemoryStore options.cookie ?= new Object - sessionConfig = options return session options for key, value of session express.session[key] = value @@ -35,7 +34,7 @@ express.application.https = (options) -> return this express.application.io = (options) -> - options ?= new Object + options ?= '' defaultOptions = log:false _.extend options, defaultOptions @io = io.listen @server, options diff --git a/package.json b/package.json index 22d21ee..ba3358e 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,7 @@ "keywords": ["realtime", "web", "framework", "express.io", "express", "socket.io", "badass"], "homepage": "http://express-io.org", "author": "Brad Carleton ", - "repository": "git://github.com/techpines/express.io", + "repository": "git://github.com/killerbobjr/express.io", "contributors": [{ "name": "Brad Carleton", "email": "brad@techpines.com", @@ -35,13 +35,13 @@ "mocha": "*", "chai": "*", "socket.io-client": "*", - "jade": "*" + "jade": "*", + "shelljs-nodecli": "*" }, "main": "switch.js", "scripts": { "test": "./node_modules/mocha/bin/mocha test/test.coffee", "compile": "./node_modules/coffee-script/bin/coffee -o compiled/ -c lib/", - "prepublish": "echo $(pwd) > /tmp/.pwd; ./node_modules/coffee-script/bin/coffee -o compiled/ -c lib/;", - "postpublish": "rm -rf $(cat /tmp/.pwd)/compiled" + "prepublish": "node ./scripts/prepublish.js" } } diff --git a/scripts/prepublish.js b/scripts/prepublish.js new file mode 100644 index 0000000..0c9c695 --- /dev/null +++ b/scripts/prepublish.js @@ -0,0 +1,4 @@ +var shell = require('shelljs-nodecli/node_modules/shelljs'); +var cli = require('shelljs-nodecli'); +shell.mkdir('-p', 'compiled'); +cli.exec('coffee', '-o compiled/', '-c lib'); From 3af6aca87ad8dd65344c77b5c4b0d34af30de994 Mon Sep 17 00:00:00 2001 From: administrator Date: Sun, 4 May 2014 12:51:06 -0700 Subject: [PATCH 2/3] Reverted null option fix for socket.io options A null options for express.session still needs to be a string though --- lib/index.coffee | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/index.coffee b/lib/index.coffee index 8e85217..2d0de59 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -34,7 +34,7 @@ express.application.https = (options) -> return this express.application.io = (options) -> - options ?= '' + options ?= new Object defaultOptions = log:false _.extend options, defaultOptions @io = io.listen @server, options From a233391854b5b80ffc3a65fa6d57e102d8c52e07 Mon Sep 17 00:00:00 2001 From: administrator Date: Sun, 4 May 2014 14:48:53 -0700 Subject: [PATCH 3/3] Replaces the simplistic session null options initializer This fix constructs a complete session options object if one doesn't exist, including a default cookie object as well. The previous fix submitted was a bit too simplistic and made assumptions about the way session options are processed within expressjs. A fully constructed options object should avoid any problems with future changes in expressjs as well. --- lib/index.coffee | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lib/index.coffee b/lib/index.coffee index 2d0de59..114386c 100644 --- a/lib/index.coffee +++ b/lib/index.coffee @@ -16,12 +16,19 @@ express.io.routeForward = middleware.routeForward session = express.session delete express.session sessionConfig = new Object + express.session = (options) -> - options ?= '' - options.key ?= 'connect.sid' - options.store ?= new session.MemoryStore - options.cookie ?= new Object - return session options + if options is null + options = + key: "connect.sid" + store: session.MemoryStore + cookie: + path: "/" + httpOnly: true + secure: false + maxAge: {} + session options + for key, value of session express.session[key] = value