import { Response } from "express" ; import { OutgoingHttpHeaders } from "http" ; import IResponse from "./IResponse" ; export default class ExpressResponseAdapter implements IResponse { public constructor ( private readonly res ) { } public setStatusCode ( code ) { this . res . status ( code ) ; return this ; } public getStatusCode ( ) { return this . res . statusCode ; } public setStatusMessage ( message ) { this . res . statusMessage = message ; return this ; } public getStatusMessage ( ) { return this . res . statusMessage ; } public setHeader ( field , value ? ) { if ( typeof value === "number" ) { value = `${ value }` ; } if ( typeof value === "boolean" ) { value = `${ value }` ; } if ( typeof value === "string" || value instanceof Array ) { this . res . setHeader ( field , value ) ; } return this ; } public getHeader ( field ) { return this . res . getHeader ( field ) ; } public getHeaders ( ) { return this . res . getHeaders ( ) ; } public headersSent ( ) { return this . res . headersSent ; } public setContentType ( value ) { this . res . setHeader ( "content-type" , value ) ; return this ; } public getBodyStream ( ) { return this . res ; } }