2.0.1 • Published 4 months ago

aws-lambda-response-helper v2.0.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

AWS Lambda Response Helper

Overview

Simple response library for use with AWS Lambda. Contains a collection of inbuilt response classes and an abstract Response base class that can be used to extend the library to suit implementers needs. Only param required by a Response object is the event, during instantiation the Response class uses this to log out information about the request for auditing purposes.

Example

import { APIGatewayProxyHandler, APIGatewayProxyEvent } from 'aws-lambda';
import { Ok, BadRequest, errorHandler } from 'aws-lambda-response-helper';

export const handler: APIGatewayProxyHandler = async (event: APIGatewayProxyEvent) => {
    try {
        if (!event.body) {
            throw new BadRequest('Body not provided');
        }

        // Do some stuff with the body
        // ...

        // Use env vars below to customise internal behaviour around token decoding
        process.env.ALR_TOKEN_HEADER_KEY = '<property in event.headers containing the auth token, default: Authorization>'
        process.env.ALR_TOKEN_USER_KEY = '<property in the auth token containing the username, default: email>'

        return Ok(event);
    } catch (err) {
        return errorHandler(err, event);
    }
}

Contributing

Contributions welcome! Please follow steps below

  1. Checkout a new branch from main
  2. Document changes in the CHANGELOG.md under a new version number (guide in the changelog)
  3. Up the version in package.json
  4. Submit a PR
2.0.1

4 months ago

1.1.9

9 months ago

2.0.0

6 months ago

1.1.8

1 year ago

1.1.7

1 year ago

1.1.6

1 year ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago