Skip to content

Commit

Permalink
take callback
Browse files Browse the repository at this point in the history
  • Loading branch information
junosuarez committed Mar 13, 2013
1 parent 971d4ed commit 91172a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions index.js
Expand Up @@ -29,21 +29,22 @@ var defaultOpts = {
// @param pipeline - an object with a `.use` method which takes a connect-style middleware function
// @param params - an object with properties as parameters (see)
// @returns void
module.exports = function snap(pipeline, params) {
module.exports = function snap(pipeline, params, cb) {
if (typeof params !== 'object') throw new Error('Missing required parameter: params must be an object')
if (!params.secret) throw new Error('Missing required parameter: secret')
withDefaults(params)
if (!params.store || !params.connectionString) throw new Error('Session Store not available. Provide your own with the `store` parameter or run `$ npm install`.')

bounce.call(params, params.store, function (err, store) {
if (err) throw err;
if (err) cb ? cb(err) : throw err;

pipeline.use(muddle(
connect.cookieParser(),
connect.session({secret: params.secret, store: store, cookie: params.sessionCookie || {maxAge: params.sessionDuration}}),
passport.initialize(),
passport.session()
))
process.nextTick(function () { cb() })
})
}

Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "snap",
"version": "0.1.0",
"version": "0.2.0",
"description": "session middleware for the truly lazy using mongodb",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 91172a6

Please sign in to comment.