sm

@sr-net/session-middleware

Koa session middleware for stratroulette.net

Showing:

Popularity

Downloads/wk

1

Maintenance

No Maintenance Data Available

Package

Dependencies

6

Size (min+gzip)

9.2KB

License

AGPL-3.0

Type Definitions

Built-In

Tree-Shakeable

No?

Categories

Readme

session-middleware

npm TravisCI Coveralls David

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

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100