Skip to content

Instantly share code, notes, and snippets.

@adeel
Created August 23, 2011 06:30
Show Gist options
  • Save adeel/1164481 to your computer and use it in GitHub Desktop.
Save adeel/1164481 to your computer and use it in GitHub Desktop.
Example: Heroku + Node.js + Express.js + connect-mongodb
var mongo = require('mongodb'),
mongoStore = require('connect-mongodb');
var mongo_config = {
host: "staff.mongohq.com",
port: 10004,
dbname: "appXXX",
username: "username",
password: "password"};
var app = module.exports = express.createServer();
app.configure(function() {
// ...
app.use(express.session({
secret: "...",
store: new mongoStore({
server_config: new mongo.Server(mongo_config.host, mongo_config.port,
{auto_reconnect: true, native_parser: true}),
dbname: mongo_config.dbname,
username: mongo_config.username,
password: mongo_config.password}),
cookie: {maxAge: 604800000},
}));
// ...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment