back to git connect-mongo, non-callback mongostore

This commit is contained in:
Tyler Renelle 2012-12-31 12:39:28 -05:00
parent 4b8e1c82a0
commit 04154ae08a
2 changed files with 34 additions and 38 deletions

View file

@ -11,7 +11,7 @@
"derby-auth": "git://github.com/lefnire/derby-auth#master", "derby-auth": "git://github.com/lefnire/derby-auth#master",
"forever-monitor": "*", "forever-monitor": "*",
"connect-mongo": "*", "connect-mongo": "git://github.com/kcbanner/connect-mongo#master",
"passport-facebook": "*", "passport-facebook": "*",
"express": "*", "express": "*",
"gzippo": "*", "gzippo": "*",

View file

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