import express from 'express' ; import { BaseResult } from './BaseResult' ; import { OutgoingHttpHeaders } from 'http' ; export type RenderResultCallback = ( error : Error | null , html : string | null , req : express . Request , res : express . Response , next : express . NextFunction ) => void ; export class RenderResult < L extends { } > extends BaseResult { constructor ( public readonly view , public readonly locals ? , public readonly callback ? , public readonly status = 200 , public readonly headers ? ) { super ( ) ; } async execute ( req , res , next ) { if ( this . headers != null ) { res . set ( this . headers ) ; } if ( this . callback != null ) { const callback = this . callback ; return res . status ( this . status ) . render ( this . view , this . locals , ( error , html ) => callback ( error , html , req , res , next ) ) ; } return res . status ( this . status ) . render ( this . view , this . locals ) ; } }