Socket
Socket
Sign inDemoInstall

apex-utils

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

apex-utils

Collection of helpers useful in a work with AWS Lambda


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

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

FAQs

Package last updated on 05 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc