Serverless Middleware
Some helpers for writing API endpoints using AWS Lambda and Laconia.
Installation
yarn add @flexible-agency/serverless-middleware
Example usage
import { middleware, auth } from '@flexible-agency/serverless-middleware';
const dependencies = () => ({
});
export const app = async({ query, path, body }, { currentUser, /* dependences */ }) => {
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.