March 17th, 2011

MongoDB Session Store for Connect

Recently, several updates were made to Connect, which is a middleware framework for Node applications. One of the great features of Connect is its ability to manage sessions. However, the recent updates broke the old MongoDB session store, connect-mongodb.

It was failing with the error:

TypeError: Cannot set property data of #Object which has only a getter

It seemed like it wasn't going to be updated, so I decided to try my hand at writing my own Connect 1.0+ compatible MongoDB session store. It was a fun exercise and I learned a bunch about the internal workings of Connect while I was at it.

Here is the result: connect-mongo. It's also on npm.