koa-session-jwt
v0.1.1
Published
a middleware that stores session data in a jwt token
Downloads
16
Readme
koa-session-jwt
a middleware that stores session data in a jwt token
Install
npm i -S koa-session-jwt
or
yarn add koa-session-jwt
Usage
import session from "koa-session-jwt"
import Koa from 'koa'
const app = new Koa();
app.use(session("secret!"));
app.use(async (ctx, next)=>{
if(ctx.session.bar === "foo")
ctx.session.foo = "bar";
next()
})
Options
secret string required - the secret string used to sign the jwt
opts object optional - all the options available for jsonwebtoken plus cookie (default jwt-session) that is the name of the cookie used to store the jwt on clients