remiddy
v0.0.8
Published
[![Build Status](https://travis-ci.org/i-am-kenny/remiddy.svg?branch=master)](https://travis-ci.org/i-am-kenny/remiddy) [![codecov](https://codecov.io/gh/i-am-kenny/remiddy/branch/master/graph/badge.svg)](https://codecov.io/gh/i-am-kenny/remiddy) [![Known
Downloads
3
Readme
remiddy
Middleware for Remiddy. Inspired by the example middleware and projects like Recompose.
Better documentation is coming soon...
Middleware
General
- withEnvironmentVariable
- withSSM
API
- withAwsRegion
- withDefaultHttpEvent
- withFunctionVersion
- withHttpResponseHeader
- withJoiValidation
- withRequestId
- withResponseTime
- withWarmupHeader
Kinesis
- withKinesisRecordFilter
- withKinesisRecordMap
- withKinesisStreamRecordCount
DynamoDb Stream
- withDynamoDbDeleteRecordFilter
- withDynamoDbInsertRecordFilter
- withDynamoDbRecordFilter
- withDynamoDbUpdateRecordFilter
- withDynamodbUpsertRecordFilter
- withUnmarshalledDynamoDbRecords
Examples
withAwsRegion
Adds the context.invokedFunctionArn
to the response headers as x-aws-region
.
middy(...).use(withAwsRegion());
middy(...).use(withAwsRegion('x-aws-region')); // optionally rename the header
withDefaultHttpEvent
Defaults queryStringParameters
and pathParameters
to {}
if undefined
or null
;
middy(...).use(withDefaultHttpEvent());
withFunctionVersion
Adds the Lambda function version to the response headers as x-aws-function-version
.
middy(...).use(withFunctionVersion());
middy(...).use(withFunctionVersion('x-aws-function-version')); // optionally rename the header
withHttpResponseHeader
Adds custom HTTP repsonse headers.
middy(...).use(withResponseHeader({
'Access-Control-Allow-Origin': '*'
}));
middy(...).use(withResponseHeader((handler) => ({
'x-custom-header': handler.event.value
})));
withJoiValidation
Allows validation (and conversion) of any event
property; such as event.body
, pathParameters
, etc...
middy(...).use(withJoiValidation({
queryStringParameters: {
name: Joi.string().required(),
year: Joi.number().required()
}
});
withRequestId
Adds the context.awsRequestId
to the response headers as x-aws-request-id
.
middy(...).use(withRequestId());
middy(...).use(withRequestId('x-aws-request-id')); // optionally rename the header
withResponseTime
Adds "response-time" (ms) to the response headers as x-aws-response-time
. Does not include the coldstart time, and is likely not accurate.
middy(...).use(withResponseTime());
middy(...).use(withResponseTime('x-aws-response-time')); // optionally rename the header
withWarmupHeader
Allows x-aws-warmup
to be passed via request headers to immediately end execution with a 204
status.
middy(...).use(withWarmupHeader());
middy(...).use(withWarmupHeader('x-aws-warmup')); // optionally rename the header