Socket
Socket
Sign inDemoInstall

functioneer-aws

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

functioneer-aws

AWS lambda helpers for functioneer.


Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

Functioneer-AWS

Helper functions for Functioneer - for use with AWS Lambda functions.

Installation

Run npm install i functioneer-aws and import to your project.

Usage

Declare a function:

import {Functioneer} from "functioneer";
const func = new Functioneer();
//Declare a function to add two numbers
func.registerFunction("add", "Adds two numbers", (a: number, b: number) => {
    return a + b;
})
.addField("a", "number", "The first number to add")
.addField("b", "number", "The second number to add");

Use the lambda handler for a path:

import { getLamdaHandler } from "./lib/functioneer-aws";
import { APIGatewayProxyEvent, APIGatewayProxyResult } from "aws-lambda";

export const lambdaHandler: (event: APIGatewayProxyEvent) => Promise<APIGatewayProxyResult> = getLamdaHandler(func,"BODY");

Exposed method

getLambdaHandler(functioneerInstance,dataSource,functionName?)

arguementtype
functioneerInstanceFunctioneerAn instance of Functioneer
dataSourcestringWhere to get the function arguements from ("BODY" or "PARAMS" or "QUERY")
functionNamestring?The function to be called. If null then select the function name from the data source

Dynamic function selection

As mentioned before you can either hardcode the function to run or parse it through the dataSource:

const func = new Functioneer();
func.registerFunction("add", "Adds two numbers", (a: number, b: number) => { return a + b; }).
addField("a", "number", "The first number to add").
addField("b", "number", "The second number to add");


// This will run the add function
export const lambdaHandler: (event: APIGatewayProxyEvent) => Promise<APIGatewayProxyResult> = getLamdaHandler(func,"BODY", "add");

// This will run any function specified in body.functionName
export const lambdaHandler: (event: APIGatewayProxyEvent) => Promise<APIGatewayProxyResult> = getLamdaHandler(func,"BODY");

Data sources

The following data sources are supported:

Data sourcevalue
Request body"BODY"JSON data from request body
URL parameters"PARAMS"URL parameters
Query string"QUERY"Query string parameters

Building and testing

You can build the project by running npm run build. Tests are run by running npm run test

License

Functioneer-aws is licensed under MIT license

FAQs

Package last updated on 04 Mar 2024

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