import { RequestHandler } from "express" ; import { isString } from "lodash" ; import IRequestWithAuthToken from "../common/IRequestWithAuthToken" ; export default function extractAuthToken ( ) { return ( req , _res , next ) => { req . authToken = null ; const authorizationHeader = req . headers . authorization ; if ( isString ( authorizationHeader ) && /^Bearer /i . test ( authorizationHeader ) ) { req . authToken = authorizationHeader . slice ( "Bearer " . length ) ; } next ( ) ; } ; }