Simple Lambda & Cloud Function wrapper written in Typescript.
Install with yarn.
yarn add lambdur
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,
);
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;
}
}
}
This is a pure Typescript package, no bundling necessary.
yarn run build
yarn run watch
yarn run lint