0.0.2 • Published 3 years ago

aws-lambda-utils v0.0.2

Weekly downloads
7
License
ISC
Repository
github
Last release
3 years ago

AWS Lambda utilities

Build status

Goal

The goal of this package is to provide some of the always needed utility code to AWS Lambdas

Lambda results utility functions

The goal is to provide shortcuts to AWS Lambda return objects.

The following functions are available :

  • ok (status code 200)
  • created (status code 201)
  • accepted (status code 202)
  • noContent (status code 204)
  • badRequest (status code 400)
  • unauthenticated (status code 401)
  • unauthorized (status code 403)
  • notFound (status code 404)
  • serverError (status code 500)

Example

const lambdaResult = ok({ test: 'value' });
// Generates this object, recognizable by AWS API Gateway
// {
//   statusCode: 200,
//   headers: {
//     "Access-Control-Allow-Origin": "*",
//     "Access-Control-Allow-Credentials": true
//   },
//   body: "{\"test\":\"value\"}"
// }

Disable CORS Headers

const lambdaResult = ok({ test: 'value' }, false);