Express Middleware to Intercept token and make stuff, like refresh it.
Install
yarn add token-interceptor
Usage
const express = const intercept = defaultconst app = app
API
intercept([options])
options
Type: Object
url
Endpoint where to forward token as Bearer
Type: String
handler
Asyncronous Function to process token
Type: Function
handler: async Promise
getToken
Get input token from req
Type: Function
Required: true
reqbodytoken
key
Key to search when catching token if no getToken
passed
After check token as Authorization Bearer, will check as query[key]
, cookies[key]
and body[key]
. That automatich checks will berun if no getToken
option is passed.
Type: String
Default: refreshToken
errorHandler
If passed has err
as argument, otherwise next(err)
console
Type: Function