2.2.0 • Published 12 months ago

@includable/serverless-middleware v2.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
12 months ago

Serverless Middleware

Some helpers for writing API endpoints using AWS Lambda.


Installation

yarn add @includable/serverless-middleware

Example usage

import { middleware, auth } from "@includable/serverless-middleware";

const dependencies = {
  // dependencies for the dependency injector
};

export const app = async (
  { query, path, body },
  { currentUser /* dependences */ },
) => {
  // if `auth` is included in the second param of `middleware`, currentUser
  // will be an object in the form of `{ id, groups, email, ... }`

  // your business logic goes here

  return {
    success: true,
    text: "Hello, world!",
  };
};

export const handler = middleware(app, [auth]).register(dependencies);

Options

Warmup support

Out of the box this middleware setup supports the serverless-plugin-warmup serverless plugin.

Simply install the serverless plugin, no other changes to your code necessary. The middleware will automatically prevent code execution on warmup requests.


2.2.0

12 months ago

2.1.0

1 year ago

1.6.0

1 year ago

2.0.0

1 year ago