Necessary Pigeonholing Mechanism

npm

Ready to take your JavaScript development to the next level? Meet npm Enterprise - the ultimate in enterprise JavaScript.Learn more »

remiddy

0.0.8 • Public • Published

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

Keywords

none

install

npm i remiddy

Downloadsweekly downloads

35

version

0.0.8

license

MIT

last publish

collaborators

  • avatar
Report a vulnerability