Skip to content

8eecf0d2/lambdur

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

☁️ Lambda wrapper utility

Resources

Stars

Watchers

Forks

Packages

No packages published