import { RequestEndMiddleware } from '../../filter' ; import { DataUtility } from '../../utility' ; import { Response } from '../../types' ; import { HttpStatusCode } from '../../constants' ; /**
 * Formats result as JSON response
 */ export class ResponseEndMiddleware extends RequestEndMiddleware { invoke ( request , response , next , result ) { if ( DataUtility . isUndefined ( result ) ) { response . status ( HttpStatusCode . noContent ) . end ( ) ; } else { response . status ( HttpStatusCode . oK ) . json ( result ) ; } } }