Skip to content

Latest commit

 

History

History
57 lines (41 loc) · 1.78 KB

README.md

File metadata and controls

57 lines (41 loc) · 1.78 KB

Lambda extension service

SDK to easily build Lambda extensions in NodeJs and typescript.

Inspired by Simplifying internal AWS Lambda APIs

Installation

pnpm add lambda-extension-service

or if using yarn

yarn add lambda-extension-service

or if using npm

npm install lambda-extension-service

Usage

import { EventTypes, ExtensionAPIService, TelemetryEventTypes } from "lambda-extension-service";

(async () => {
  const extensionApiService = new ExtensionAPIService({ extensionName: "my-extension" });
  await extensionApiService.register([EventTypes.Invoke, EventTypes.Shutdown]);
  extensionApiService.onTelemetryEvent((event) => 
      console.log("Telemetry event received: ", JSON.stringify(event))
  );
  await extensionApiService.registerTelemetry([
      TelemetryEventTypes.Function,
      TelemetryEventTypes.Platform,
      TelemetryEventTypes.Extension,
  ]);

  while (true) {
      const event = await extensionApiService.next();
      console.log("Next lambda event received: ", JSON.stringify(event));
  }
})().catch((err) => console.error(err));

A complete example can be found on Example repository

Documentation

To fully understand the lambda extensions, I recommend reading or watching: