qoq-jwt

0.0.6 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i qoq-jwt

Weekly Downloads

2

Version

0.0.6

License

MIT

Unpacked Size

5.8 kB

Total Files

8

Last publish

Collaborators

  • fwh1990