0.0.8 • Published 6 years ago

remiddy v0.0.8

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

remiddy

Build Status codecov Known Vulnerabilities

Middleware for Remiddy. Inspired by the example middleware and projects like Recompose.

Better documentation is coming soon...

Middleware

General

  • withEnvironmentVariable
  • withSSM

API

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
0.0.8

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago