1.1.0 • Published 5 years ago

lambdur v1.1.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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
1.1.0

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago

0.2.3

5 years ago

0.2.2

5 years ago

0.2.1

5 years ago

0.2.0

5 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

0.0.0

6 years ago