api-lambdas.js
function toLambdaProxyResponse(statusCode, headers, body, defaultHeaders) {
  const proxyResponse = {statusCode: statusCode};

  const headersWithDefaults = headers && defaultHeaders ? merge(defaultHeaders, copy(headers)) :
    headers || (defaultHeaders && copy(defaultHeaders));
  if (headersWithDefaults) {
    proxyResponse.headers = headersWithDefaults;
  }

  proxyResponse.body = isString(body) ? body : stringify(body);

  return proxyResponse;
}
function toLambdaProxyResponse(statusCode, headers, body, defaultHeaders) {
  const proxyResponse = {statusCode: statusCode};

  const headersWithDefaults = headers && defaultHeaders ? merge(defaultHeaders, copy(headers)) :
    headers || (defaultHeaders && copy(defaultHeaders));
  if (headersWithDefaults) {
    proxyResponse.headers = headersWithDefaults;
  }

  proxyResponse.body = isString(body) ? body : stringify(body);

  return proxyResponse;
}
function toLambdaProxyResponse ( statusCode , headers , body , defaultHeaders ) { const proxyResponse = { statusCode : statusCode } ; const headersWithDefaults = headers && defaultHeaders ? merge ( defaultHeaders , copy ( headers ) ) : headers || ( defaultHeaders && copy ( defaultHeaders ) ) ; if ( headersWithDefaults ) { proxyResponse . headers = headersWithDefaults ; } proxyResponse . body = isString ( body ) ? body : stringify ( body ) ; return proxyResponse ; }
Builds & returns a Lambda Proxy integration compatible response.
@param {number|string} statusCode - the HTTP status code to return
@param {Object|undefined} [headers] - optional response headers to use
@param {Object|string|undefined} [body] - an optional response body to use
@param {Object|undefined} [defaultHeaders] - optional default custom headers to be included in the Lambda Proxy response
@return {{statusCode: (number|string), headers: (Object|undefined), body: (string|undefined)}} a Lambda Proxy response
Builds & returns a Lambda Proxy integration compatible response .