Nostradamus Prophecy Machine

    @middy/event-normalizer
    TypeScript icon, indicating that this package has built-in type declarations

    3.0.0-alpha.5 • Public • Published

    Middy AWS event parse and normalization middleware

    Middy logo

    AWS event parsing and normalization middleware for the middy framework, the stylish Node.js middleware engine for AWS Lambda

    Middleware for iterating through an AWS event records, parsing and normalizing nested events.

    AWS Events Transformations:

    Event Source Included Comments
    API Gateway (REST) No See middleware prefixed with http-
    API Gateway (HTTP) No See middleware prefixed with http-
    API Gateway (WS) No #602
    CloudTrail No Normalization not required
    CloudWatch Logs No Normalization not required
    Cognito No Normalization not required
    DynamoDB Yes Unmarshall Keys, OldImage, and NewImage
    EC2 No Normalization not required
    Elastic LB No See middleware prefixed with http-
    EventBridge No Normalization not required
    IoT No Normalization not required
    Kinesis Stream Yes Base64 decode and JSON parse
    Kinesis Firehose Yes Base64 decode and JSON parse
    RDS No Normalization not required
    S3 Yes URI decode key name
    Secrets Manager No Normalization not required
    SES No Normalization not required
    SNS Yes JSON parse
    SQS Yes JSON parse

    Test Events Some events send test events after set, you will need to handle these.

    // S3 Test Event
    {
      Service: 'Amazon S3',
      Event: 's3:TestEvent',
      Time: '2020-01-01T00:00:00.000Z',
      Bucket: 'bucket-name',
      RequestId: '***********',
      HostId: '***/***/***='
    }

    Install

    To install this middleware you can use NPM:

    npm install --save @middy/event-normalizer

    Sample usage

    import middy from '@middy/core'
    import eventNormalizer from '@middy/event-normalizer'
    
    const lambdaHandler = (event, context) => {
      const { Records } = event
      for(const record of Records) {
        // ...
      }
    }
    
    const handler = middy(lambdaHandler).use(eventNormalizer())

    Middy documentation and examples

    For more documentation and examples, refers to the main Middy monorepo on GitHub or Middy official website.

    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. Copyright (c) 2017-2022 Luciano Mammino, will Farrell, and the Middy team.

    FOSSA Status

    Install

    npm i @middy/event-normalizer

    DownloadsWeekly Downloads

    1,054

    Version

    3.0.0-alpha.5

    License

    MIT

    Unpacked Size

    8.55 kB

    Total Files

    5

    Last publish

    Collaborators

    • lmammino
    • middyjs
    • willfarrell