https://github.com/nRFCloud/lambda-helpers/pkgs/npm/lambda-helpers
Helper functions for AWS Lambda functions used in nRF Cloud.
The package is published to the GitHub Packages registry. Releases are also published to npm.
To install it, point the @nrfcloud scope to it in your project's .npmrc and
authenticate
with a token that has the read:packages scope:
@nrfcloud:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
npm i (--save-prod|--save-dev) @nrfcloud/lambda-helpersimport { MetricUnit } from "@aws-lambda-powertools/metrics";
import { logMetrics } from "@aws-lambda-powertools/metrics/middleware";
import middy from "@middy/core";
import { metricsForComponent } from "@nrfcloud/lambda-helpers";
const { track, metrics } = metricsForComponent("my-function", "my-service");
export const handler = middy()
.use(logMetrics(metrics))
.handler(async () => {
track("some:metric", MetricUnit.Count, 1);
});This repo runs TypeScript 6 and 7 side by side, so that eslint works.