UNPKG

@corejam/base

Version:

A scaffolding for building progressive GraphQL powered jamstack applications

37 lines 1.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const http_1 = require("http"); /** * Currently only a proxy class incase we are inside * a lambda function and need to parse headers. * * Otherwise it just calls super.setHeader and this can be ignored */ class Response extends http_1.ServerResponse { /** * Assign the GraphQL Context so we can use it later on * @param context */ constructor(req, context) { super(req); if (context && process.env.AWS_EXECUTION_ENV && process.env.AWS_EXECUTION_ENV.includes("AWS_Lambda_")) { this.context = Object.assign(Object.assign({}, context), { headers: [] }); } } /** * If we are inside a lambda we want to "abuse" the context object * to write headers in so we can later parse them back out to the lambda event * structure * * @param name * @param value */ setHeader(name, value) { super.setHeader(name, value); if (this.context) { this.context.headers.push({ name, value }); } } } exports.default = Response; //# sourceMappingURL=Response.js.map