JSPM

middy-invocation

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2215
  • Score
    100M100P100Q118401F
  • License MIT

Middy AWS Lambda invocation middleware

Package Exports

  • middy-invocation
  • middy-invocation/src/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (middy-invocation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

middy-invocation

Middy middleware for accessing current AWS Lambda invocation event and context from anywhere without need to passing event and context as arguments through your code.

Installation

To install the middleware, you can use NPM:

npm install --save middy-invocation

Note: Requires @middy/core version 2.0.0+

Usage

  • Register middy-invocation middleware in your handler:
const middy = require('@middy/core');
const invocation = require('middy-invocation');

const handler = async(event, context) => {
  // Do something meaningful

  return {
    statusCode: 200,
  }
}

module.exports.handler = middy(handler).use(invocation());
  • Access event and context from anywhere/module/file:
const { event, context } = require('middy-invocation');

const evt = event();
const ctx = context();
const awsRequestId = ctx.awsRequestId; // or context().awsRequestId;
const remainingTimeInMillis = ctx.getRemainingTimeInMillis(); // or context().getRemainingTimeInMillis();

Contributing

Everyone is very welcome to contribute to this repository. Feel free to raise issues or to submit Pull Requests.

License

Licensed under MIT License.