@aws-lambda-powertools/commons

A shared utility package for Powertools for AWS Lambda (TypeScript) libraries


Keywords
aws, lambda, powertools, serverless, nodejs, aws-lambda, aws-sdk, instrumentation, typescript
License
MIT-0
Install
npm install @aws-lambda-powertools/commons@0.7.1

Documentation

Powertools for AWS Lambda (TypeScript)

NodeSupport GitHub Release Quality Gate Status Security Rating OpenSSF Scorecard Join our Discord

Powertools for AWS Lambda (TypeScript) is a developer toolkit to implement Serverless best practices and increase developer velocity.

You can use the library in both TypeScript and JavaScript code bases.

Also available in Python, Java, and .NET.

Documentation | npmjs.com | Roadmap | Examples

Features

Find the complete project's documentation here.

  • Tracer - Utilities to trace Lambda function handlers, and both synchronous and asynchronous functions
  • Logger - Structured logging made easier, and a middleware to enrich log items with key details of the Lambda context
  • Metrics - Custom Metrics created asynchronously via CloudWatch Embedded Metric Format (EMF)
  • Parameters - High-level functions to retrieve one or more parameters from AWS SSM Parameter Store, AWS Secrets Manager, AWS AppConfig, and Amazon DynamoDB
  • Idempotency - Class method decorator, Middy middleware, and function wrapper to make your Lambda functions idempotent and prevent duplicate execution based on payload content
  • Batch Processing - Utility to handle partial failures when processing batches from Amazon SQS, Amazon Kinesis Data Streams, and Amazon DynamoDB Streams.
  • JMESPath Functions - Built-in JMESPath functions to easily deserialize common encoded JSON payloads in Lambda functions.
  • Parser (Zod) - Utility that provides data validation and parsing using Zod, a TypeScript-first schema declaration and validation library.

Install

You can use Powertools for AWS Lambda (TypeScript) by installing it with your favorite dependency management, or via Lambda Layers. All features are available as individual packages, so you can install only the ones you need, for example:

  • Logger: npm install @aws-lambda-powertools/logger
  • Metrics: npm install @aws-lambda-powertools/metrics
  • Tracer: npm install @aws-lambda-powertools/tracer
  • Parameters: npm install @aws-lambda-powertools/parameters @aws-sdk/client-ssm see documentation for other providers
  • Idempotency: npm install @aws-lambda-powertools/idempotency @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodb
  • Batch: npm install @aws-lambda-powertools/batch
  • JMESPath Functions: npm install @aws-lambda-powertools/jmespath
  • Parser: npm install @aws-lambda-powertools/parser zod@~3

Examples

You can find examples of how to use Powertools for AWS Lambda (TypeScript) in the examples directory. The directory contains code snippets around certain features as well as an is a simple REST API application that can be deployed via either AWS CDK or AWS SAM.

Community-contributed examples:

How to support Powertools for AWS Lambda (TypeScript)?

Becoming a reference customer

Knowing which companies are using this library is important to help prioritize the project internally. If your company is using Powertools for AWS Lambda (TypeScript), you can request to have your name and logo added to the README file by raising a Support Powertools for AWS Lambda (TypeScript) (become a reference) issue.

The following companies, among others, use Powertools:

Sharing your work

Share what you did with Powertools for AWS Lambda (TypeScript) 💞💞. Blog post, workshops, presentation, sample apps and others. Check out what the community has already shared about Powertools for AWS Lambda (TypeScript) here.

Using Lambda Layer

This helps us understand who uses Powertools for AWS Lambda (Typescript) in a non-intrusive way, and helps us gain future investments for other Powertools for AWS Lambda languages. When using Layers, you can add Powertools for AWS Lambda as a dev dependency to not impact the development process.

Credits

Connect

Security disclosures

If you think you’ve found a potential security issue, please do not post it in the Issues. Instead, please follow the instructions here or email AWS security directly.

License

This library is licensed under the MIT-0 License. See the LICENSE file.