0.4.6 • Published 1 year ago
lambdaf v0.4.6
lambdaf
Best practice for building AWS Lambda functions.
Get started
npm i --save lambdaf
Example
// Set up your request.
// This type must contain `body`, `queryStringParameters`, `pathParameters`
// to use `apiGatewayProxyLambda`.
type Request = {
body: {
name: string;
};
queryStringParameters: {};
pathParameters: {};
};
// Set up your response.
// This type must contain `statusCode`, `body`
// to use `apiGatewayProxyLambda`.
type Response = {
statusCode: 200;
body: {
message: string;
};
};
// Simply create a AWS Lambda handler with your usecase and context.
const handler = apiGatewayProxyLambda<Request, Response>(({ body }) => {
return response(200, body: {
message: `Hello, ${body.name}!`,
});
});
// Set up an event for testing.
const event = {
body: JSON.stringify({
name: "Jinsu",
}),
};
// Execute the handler for testing.
const result = await handler(event as any, {} as any, () => null);
// The body in the result should contain a message
// that says `Hello, Jinsu!`.
expect(result?.body).toBe(
JSON.stringify({
message: "Hello, Jinsu!",
}),
);
0.4.6
1 year ago
0.4.5
1 year ago
0.4.4
1 year ago
0.4.1
1 year ago
0.4.0
1 year ago
0.4.3
1 year ago
0.4.2
1 year ago
0.3.9
1 year ago
0.3.8
1 year ago
0.3.7
1 year ago
0.3.6
1 year ago
0.3.5
1 year ago
0.3.4
1 year ago
0.3.3
1 year ago
0.3.2
1 year ago
0.3.1
1 year ago
0.3.0
1 year ago
0.2.5
1 year ago
0.2.4
1 year ago
0.2.3
1 year ago
0.2.2
1 year ago
0.2.1
1 year ago
0.2.0
1 year ago
0.1.2
1 year ago
0.1.1
1 year ago
0.1.0
1 year ago