1.0.2 • Published 2 years ago

jwtextract v1.0.2

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

jwtextract

fast extract your jwt from your authorization header

Usage

  1. Install with

    $ npm i jwtextract

    or

    $ yarn add jwtextract

HOW TO :

import jwtextract from 'jwtextract'
export const authenticateUser = async (req, res, next) => {
 
  // sent in the req and expect to get string jwt as return value
  const accessToken = jwtextract(req)
 
  if (!accessToken) {
     // response with some error
     return responseWithError(res, error(FORBIDDEN_MSG, FORBIDDEN))
  }
  else{
    // do your magic code...
  }
}