@sr-net/session-middleware
v1.5.0
Published
Koa session middleware for stratroulette.net
Downloads
5
Readme
session-middleware
Usage
The middleware needs a sr-net/auth
service to use. Clone and run it locally before using this middleware.
import { Session } from '@sr-net/session-middleware'
app.use(
Session({
url: 'http://localhost:3100', // Url to running auth service
domain: 'stratroulette.net', // Domain server is running on
})
)
app.use(ctx => {
ctx.session.id // Session ID
ctx.session.maxAge // Session lifetime
ctx.session.user // Session's User, if logged in
ctx.session.isLoggedIn // Alias for !!ctx.session.user
ctx.session.identifier // User UUID if logged in, otherwise Session ID
ctx.session.foo = 'baz' // Set any variable and it will be saved to the Auth service
})
Testing
yarn test