elegant-tools
TypeScript icon, indicating that this package has built-in type declarations

1.0.21 • Public • Published

A simple toolset for Node.js / TypeScript AWS lambda development

** Context-aware logging It will follow async calls and add values added to context to every log entry

import { EventBridgeEvent } from "aws-lambda";
import { createHandler, getContext } from "elegant-tools";

export const handler = createHandler(async (event: EventBridgeEvent<string, any>) => {
  const { logger } = getContext();
  if (event["detail-type"] !== "supported-event-type") {
    logger.info(`Ignoring event: ${event["detail-type"]}`);
    return;
  }

  const input = SupportedEventSchema.parse(event.detail);
  logger.patchContext({
    correlationId: input.metadata["correlation-id"],
    ...
  });

  return await someDownstreamService(input);
});

Package Sidebar

Install

npm i elegant-tools

Weekly Downloads

0

Version

1.0.21

License

ISC

Unpacked Size

141 kB

Total Files

17

Last publish

Collaborators

  • beh01der