Permalink
Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
54 lines (34 sloc) 1.35 KB

snap

session middleware for the truly lazy

sets up all the connect-style middleware you need for session and user management.

use it with wham!

installation

$ npm install snap

example usage

with express:

var http = require('http')
var app = require('express')()
var snap = require('snap')
app.use(snap({secret: 'OH_SNAP'}))
app.use(function (req, res) {
  res.send('sessions!')
})
http.createServer(app).listen(1234)

with wham:

var wham = require('wham')('Example')
var snap = require('snap')
wham(snap({secret: 'OH_SNAP'}))
wham('log output', '/').get(function () {
  return 'sessions'!
})
wham.bam(1234)

parameters

snap takes a parameters object.

required

  • parameters.secret: a string used for seeding the session cookie

optional

  • parameters.store: a connect.session-compatible SessionStore. Defaults to connect-mongo

  • parameters.sessionDuration: number in milliseconds of inactivity that session cookie should persist. Defaults to 30 days.

  • parameters.cookie: A connect.session cookie object. Overrides parameters.sessionDuration.

license

MIT. (c) 2013 jden jason@denizac.org. See LICENSE.md