lambdur
TypeScript icon, indicating that this package has built-in type declarations

1.1.0 • Public • Published

Lambdur

Simple Lambda & Cloud Function wrapper written in Typescript.

Get Started

Install with yarn.

yarn add lambdur

Usage

Import and chain your handlers.

import { Lambdur } from "lambdur";
import { ExampleMiddleware } from "./middleware";
 
const ExampleHttpHandler = () => ({
  statusCode: 200,
  body: "foo"
});
 
export const handler = Lambdur.chain(
  Lambdur.Handler.Type.HTTP,
  ExampleMiddleware,
  ExampleHttpHandler,
);

Types

Lambdur provides types for specific types for AWS CRON, HTTP, SNS and SQS request and response properties.

import { Lambdur } from "lambdur";
 
const ExampleHttpHandler: Lambdur.Handler<ExampleHttpHandler.Request, ExampleHttpHandler.Response> = async (request, context, callback) => {
 
  await new Promise(r => setTimeout(() => r(), 1000));
 
  return {
    statusCode: 200,
    body: {
      greeting: `Hello ${request.body.name}`,
      ts: new Date().getTime(),
    },
  }
}
 
export const handler = Lambdur.chain(ExampleHttpHandler);
 
export namespace ExampleHttpHandler {
  export interface Request extends Lambdur.Handler.Request.HTTP {
    body: {
      name: string;
    }
  }
  export interface Response extends Lambdur.Handler.Response {
    body: {
      greeting: string;
      ts: number;
    }
  }
}

Development

This is a pure Typescript package, no bundling necessary.

NPM Scripts

Buid script
yarn run build
Watch script
yarn run watch
Lint script
yarn run lint

Readme

Keywords

none

Package Sidebar

Install

npm i lambdur

Weekly Downloads

212

Version

1.1.0

License

ISC

Unpacked Size

22.5 kB

Total Files

14

Last publish

Collaborators

  • 8eecf0d2