try latest connect-mongo with a mongostore initialization callback in

attempt to avoid the 'arbiterOnly' error
This commit is contained in:
Tyler Renelle 2012-12-28 10:06:15 -05:00
parent 9db1d7c17e
commit 9d80ffcf3c
2 changed files with 39 additions and 35 deletions

View file

@ -10,7 +10,7 @@
"derby-ui-boot": "git://github.com/codeparty/derby-ui-boot#master",
"derby-auth": "git://github.com/lefnire/derby-auth#master",
"connect-mongo": ">=0.1.9",
"connect-mongo": "git://github.com/kcbanner/connect-mongo#master",
"passport-facebook": "*",
"express": "*",
"gzippo": "*",

View file

@ -51,41 +51,45 @@ options =
allowPurl: true
schema: require('../app/schema').newUserObject()
expressApp
.use(express.favicon())
# Gzip static files and serve from memory
.use(gzippo.staticGzip publicPath, maxAge: ONE_YEAR)
# Gzip dynamically rendered content
.use(express.compress())
# use async callback for initializing app, to make sure we're connected to the database before initting app
# this avoids 'arbiterOnly' error (see http://goo.gl/Vs6lW)
mongo_store = new MongoStore {url: process.env.NODE_DB_URI}, ->
# Uncomment to add form data parsing support
.use(express.bodyParser())
.use(express.methodOverride())
expressApp
.use(express.favicon())
# Gzip static files and serve from memory
.use(gzippo.staticGzip publicPath, maxAge: ONE_YEAR)
# Gzip dynamically rendered content
.use(express.compress())
# Uncomment and supply secret to add Derby session handling
# Derby session middleware creates req.session and socket.io sessions
.use(express.cookieParser())
.use(store.sessionMiddleware
secret: process.env.SESSION_SECRET || 'YOUR SECRET HERE'
cookie: {maxAge: ONE_YEAR}
store: new MongoStore(url: process.env.NODE_DB_URI)
)
# Adds req.getModel method
.use(store.modelMiddleware())
# Middelware can be inserted after the modelMiddleware and before
# the app router to pass server accessible data to a model
.use(priv.middleware)
.use(habitrpgMiddleware)
.use(auth(store, strategies, options))
# Creates an express middleware from the app's routes
.use(app.router())
.use(expressApp.router)
.use(serverError root)
# Uncomment to add form data parsing support
.use(express.bodyParser())
.use(express.methodOverride())
priv.routes(expressApp)
require('./serverRoutes')(expressApp, root, derby)
# Uncomment and supply secret to add Derby session handling
# Derby session middleware creates req.session and socket.io sessions
.use(express.cookieParser())
.use(store.sessionMiddleware
secret: process.env.SESSION_SECRET || 'YOUR SECRET HERE'
cookie: {maxAge: ONE_YEAR}
store: mongo_store
)
# Errors
expressApp.all '*', (req) ->
throw "404: #{req.url}"
# Adds req.getModel method
.use(store.modelMiddleware())
# Middelware can be inserted after the modelMiddleware and before
# the app router to pass server accessible data to a model
.use(priv.middleware)
.use(habitrpgMiddleware)
.use(auth(store, strategies, options))
# Creates an express middleware from the app's routes
.use(app.router())
.use(expressApp.router)
.use(serverError root)
priv.routes(expressApp)
require('./serverRoutes')(expressApp, root, derby)
# Errors
expressApp.all '*', (req) ->
throw "404: #{req.url}"