0.0.1 • Published 3 years ago

@vissree_s/cfn-response-async v0.0.1

Weekly downloads
-
License
SEE LICENCE IN LI...
Repository
github
Last release
3 years ago

README

This package is an async version of cfn-response module.

The module includes a send method, which sends a Custom resource response object corresponding to the received request object and returns a promise, so that it can be used within Async nodejs handlers.

Sample usage

const response = require("cfn-response-async");

async function someAsyncLogicToRun() {
  return "All good!";
}

exports.handler = async (event, context) => {
  console.log(event);
  console.log(context);

  var res;

  try {
    const outputValue = await someAsyncLogicToRun();
    const responseData = {
      Value: outputValue,
    };

    res = await response.send(event, context, response.SUCCESS, responseData);
  } catch (error) {
    console.log(error);
    res = await response.send(event, context, response.FAILED);
  }

  console.log("Status code: " + res.statusCode);
  console.log("Status message: " + res.statusMessagee);
  return res.statusCode;
};