import { HapiRequest , HapiResponseToolkit } from "../types" ; export default { plugin : { name : "error-pages" , register : ( server ) => { server . ext ( "onPreResponse" , ( request , h ) => { const response = request . response ; if ( "isBoom" in response && response . isBoom ) { const statusCode = response . output . statusCode ; if ( statusCode === 404 ) { return h . view ( "404" ) . code ( statusCode ) ; } request . log ( "error" , { statusCode : statusCode , data : response . data , message : response . message , } ) ; return h . view ( "500" ) . code ( statusCode ) ; } return h . continue ; } ) ; } , } , } ;