import { Request , Response , NextFunction } from 'express' ; import log from './logger' ; export default ( ) => ( err , req , res , next ) => { if ( err && err . code == "EBADCSRFTOKEN" ) { log . info ( 'auth.invalid_csrf_token' ) ; res . status ( 401 ) . json ( { msg : 'Invalid CSRF Token - refresh the page!' } ) ; } else if ( err ) { next ( err ) ; } else { next ( ) ; } } ;