iron-functions-wrapper

1.0.6 • Public • Published

iron-functions-wrapper

Sample wrapper for node iron functions turn this:

const fs = require('fs');

module.exports = function(fn) {
  let body;

  try {
    body = JSON.parse(fs.readFileSync('/dev/stdin').toString())
  } catch(error) {
    console.error(error);
    body = {}
  }

  console.log(JSON.stringify(body))
};

into this:

const handler = require('iron-functions-wrapper');

handler(async function(body){
  if (body.someProp) {
    return {
      success: true,
    }
  }

  return {
    error: 'someProp is required'
  }
});

Package Sidebar

Install

npm i iron-functions-wrapper

Weekly Downloads

8

Version

1.0.6

License

MIT

Unpacked Size

1.66 kB

Total Files

3

Last publish

Collaborators

  • worotyns