/** * An http response object. * * @export * @class Response */ export class Response { /** * The response headers. * * @type {{ [name: string]: string }} * @memberof Response */ headers: { [name: string]: string }; /** * The status code of the response. * * @type {number} * @memberof Response */ code: number; /** * The body of the response. * * @type {object} * @memberof Response */ body: object; /** * Creates an instance of Response. * @param {number} [code=200] * @param {object} [body={}] * @memberof Response */ constructor(code: number=200, body: object={}) { this.headers = { 'Content-Type': 'application/json' }; this.code = code; this.body = body; } /** * Returns an object suitable for a serverless response. * * @returns any * @memberof Response */ toLambdaResponse() { return { headers: this.headers, statusCode: this.code, body: JSON.stringify(this.body) } } }