import { Request } from "express" ; import IRequest , { HttpMethod } from "./IRequest" ; export default class ExpressRequestAdapter implements IRequest { public constructor ( private readonly req ) { } public getMethod ( ) { return this . req . method . toUpperCase ( ) as HttpMethod ; } public getUrl ( ) { return this . req . url ; } public getEndpoint ( ) { return `${ this . req . protocol }://${ this . getHeader ( "host" ) || this . req . hostname }` ; } public getPath ( ) { return this . req . path ; } public getBodyStream ( ) { return this . req ; } public getBody ( ) { return this . req . body ; } public setBody ( body ) { this . req . body = body ; return this ; } public getHeader ( field ) { return this . req . header ( field ) ; } public getHeaders ( ) { return this . req . headers ; } public getRawHeaders ( ) { return this . req . rawHeaders ; } public getQuery ( key ) { return this . req . query [ key ] ; } public getProtocol ( ) { return this . req . protocol ; } }