trek-jwt

0.4.0 • Public • Published

trek-jwt

JSON Web Tokens Middleware for Trek.js

Installation

$ npm install trek-jwt --save

Examples

'use strict'
 
const Engine = require('trek-engine')
const jwt = require('..')
 
async function start () {
  const app = new Engine()
  const secret = 'Trek Engine'
 
  app.use(jwt({ secret }))
 
  app.use(({ req, res }) => {
    res.body = req.body
  })
 
  app.on('error', (err, ctx) => {
    console.log(err)
  })
 
  app.run(3000)
}
 
start().catch(err => console.log(err))

API

const defaults = {
  key: 'user',
  secret: undefined,
  skip: false,
  tokenLookup: 'header:Authorization',
  authScheme: 'Bearer',
  verifyOptions: undefined,
  passthrough: false
}

Badges

Build Status codecov


fundon.me  ·  GitHub @fundon  ·  Twitter @_fundon

/trek-jwt/

    Package Sidebar

    Install

    npm i trek-jwt

    Weekly Downloads

    2

    Version

    0.4.0

    License

    MIT

    Last publish

    Collaborators

    • fundon