/**
 * Extract access token from:
 *
 * Authorization: Bearer
 * access_token query parameter
 *
 * and store in req.token
 */ import { RequestHandler } from 'express' ; const extractToken = ( req , res , next ) => { let token = null ; if ( req . query && req . query . access_token ) { token = req . query . access_token as string ; } if ( req . headers && req . headers . authorization ) { const parts = req . headers . authorization . split ( ' ' ) ; if ( parts . length === 2 && parts [ 0 ] === 'Bearer' ) { token = parts [ 1 ] ; } } TODO req . token = token ; next ( ) ; } ; export default extractToken ;