Skip to content
This repository has been archived by the owner on Aug 11, 2023. It is now read-only.

Collection of helpers useful in a work with AWS Lambda

Notifications You must be signed in to change notification settings

stanislaw-glogowski/apex-utils

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Apex Utils

Collection of helpers useful in a work with Node.js on AWS Lambda inspired by node-apex.

Installation

$ npm install apex-utils --save

Features

  • Build on promises
  • Throws uncaught errors to lambda callback
  • API Gateway handler creator
  • TypeScript ready
  • No external dependencies

Examples

import { createLambda } from "apex-utils";

interface IEvent {
  name: string;
}

export const handler = createLambda(({event, context}) => {
  const { name } = event as IEvent;
  if (name === "world") {
    throw "error"; // call callback with throwed error and null data
  }
  return `Hello ${name}!`; // call callback with null error and returned value
});

export const asyncHandler = createLambda(async ({event, context}) => {
  const name = await new Promise((resolve, reject) => {
    const { name } = event as IEvent;
    if (name === "world") {
      reject("error"); // call callback with rejected error and null data
    } else {
      resolve(name);
    }
  });
  return `Hello ${name}!`; // call callback with null error and returned value
});

More Examples

License

The MIT License

About

Collection of helpers useful in a work with AWS Lambda

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages