api-lambdas.js
function succeedLambdaCallback(callback, response, event, context) {
  return Promises.try(() => {
    const handler = context && context.handler;
    if (handler && handler.useLambdaProxy) {
      const statusCode = response && isNotBlank(response.statusCode) ? response.statusCode : 200;
      const body = (response && response.body) || response || {};
      const proxyResponse = toLambdaProxyResponse(statusCode, response && response.headers, body, handler.defaultHeaders);
      return executePreSuccessCallback(proxyResponse, event, context)
        .then(() => callback(null, proxyResponse))
        .catch(err => {
          console.error(`Unexpected failure after executePreSuccessCallback`, err);
          return callback(null, proxyResponse);
        });
    } else {
      return executePreSuccessCallback(response, event, context)
        .then(() => callback(null, response))
        .catch(err => {
          console.error(`Unexpected failure after executePreSuccessCallback`, err);
          return callback(null, response);
        });
    }
  }).catch(err => {
    console.error(`Unexpected failure during succeedLambdaCallback`, err);
    return callback(null, response);
  });
}
function succeedLambdaCallback(callback, response, event, context) {
  return Promises.try(() => {
    const handler = context && context.handler;
    if (handler && handler.useLambdaProxy) {
      const statusCode = response && isNotBlank(response.statusCode) ? response.statusCode : 200;
      const body = (response && response.body) || response || {};
      const proxyResponse = toLambdaProxyResponse(statusCode, response && response.headers, body, handler.defaultHeaders);
      return executePreSuccessCallback(proxyResponse, event, context)
        .then(() => callback(null, proxyResponse))
        .catch(err => {
          console.error(`Unexpected failure after executePreSuccessCallback`, err);
          return callback(null, proxyResponse);
        });
    } else {
      return executePreSuccessCallback(response, event, context)
        .then(() => callback(null, response))
        .catch(err => {
          console.error(`Unexpected failure after executePreSuccessCallback`, err);
          return callback(null, response);
        });
    }
  }).catch(err => {
    console.error(`Unexpected failure during succeedLambdaCallback`, err);
    return callback(null, response);
  });
}
function succeedLambdaCallback ( callback , response , event , context ) { return Promises . try ( ( ) => { const handler = context && context . handler ; if ( handler && handler . useLambdaProxy ) { const statusCode = response && isNotBlank ( response . statusCode ) ? response . statusCode : 200 ; const body = ( response && response . body ) || response || { } ; const proxyResponse = toLambdaProxyResponse ( statusCode , response && response . headers , body , handler . defaultHeaders ) ; return executePreSuccessCallback ( proxyResponse , event , context ) . then ( ( ) => callback ( null , proxyResponse ) ) . catch ( err => { console . error ( ` ` , err ) ; return callback ( null , proxyResponse ) ; } ) ; } else { return executePreSuccessCallback ( response , event , context ) . then ( ( ) => callback ( null , response ) ) . catch ( err => { console . error ( ` ` , err ) ; return callback ( null , response ) ; } ) ; } } ) . catch ( err => { console . error ( ` ` , err ) ; return callback ( null , response ) ; } ) ; }
Succeeds the given callback of an API Gateway exposed AWS Lambda, by invoking the given callback with the given
response.
@param {Function} callback - the callback function passed as the last argument to your Lambda function on invocation.
@param {Object} response - a normal or Lambda Proxy integration response to be returned
@param {AWSEvent} event - the AWS event passed to your handler
@param {StandardHandlerContext} context - the context to use
Succeeds the given callback of an API Gateway exposed AWS Lambda by invoking the given callback with the given response .