0.0.6 • Published 3 years ago

qoq-jwt v0.0.6

Weekly downloads
6
License
MIT
Repository
github
Last release
3 years ago

qoq-jwt

qoq middleware for validating JSON Web Tokens based on koa-jwt.

License npm

Installation

yarn add qoq-jwt

Usage

import { WebSlotManager } from 'qoq';
import { JWT } from 'qoq-jwt';

export const webSlots = WebSlotManager.use(new JWT({ secret: 'shared-secret' }));

You can run the jwt slot under certain conditions:

import { WebSlotManager, WebRouter } from 'qoq';
import { JWT } from 'qoq-jwt';

export const webSlots = WebSlotManager.use(
  new JWT({
    secret: 'shared-secret',
    unless: {
      path: [/^\/public/],
    },
  }),
);

const router = new WebRouter({
  prefix: '/',
  slots: webSlots,
});

router.get('/public').action((ctx, next) => {
  ctx.send('unprotected\n');
});

router.get('/api').action((ctx, next) => {
  ctx.send('protected\n');
});

Options

@see koa-jwt

0.0.3

3 years ago

0.0.5

3 years ago

0.0.4

3 years ago

0.0.6

3 years ago

0.0.2

3 years ago

0.0.1

3 years ago