Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@effect-aws/lambda

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect-aws/lambda

Clean way to write AWS Lambda handlers using [Effect](https://www.effect.website/).

  • 1.2.0
  • latest
  • npm
  • Socket score

Version published
Weekly downloads
51K
increased by102.06%
Maintainers
1
Weekly downloads
 
Created
Source

@effect-aws/lambda

Clean way to write AWS Lambda handlers using Effect.

It provides a makeLambda function that takes an EffectHandler and returns a native promise Lambda handler function.

The implementation supports defining global runtime layer with graceful shutdown. So all finalizers defined by acquireRelease will be called on lambda downscaling.

Installation

npm install --save @effect-aws/lambda

Usage

Without dependencies:

import type { SNSEvent } from "aws-lambda";
import { Effect } from "effect";
import { EffectHandler, makeLambda } from "@effect-aws/lambda";

// Define your effect handler
const myEffectHandler: EffectHandler<SNSEvent, never> = (event, context) => {
  // Your effect logic here
  return Effect.succeed("Hello, World!");
};

// Create the Lambda handler
export const handler = makeLambda(myEffectHandler);

With dependencies:

import { EffectHandler, makeLambda } from "@effect-aws/lambda";
import * as Logger from "@effect-aws/powertools-logger";
import type { SNSEvent } from "aws-lambda";
import { Context, Effect, Layer } from "effect";

interface FooService {
  bar: () => Effect.Effect<never, never, void>;
}
const FooService = Context.Tag<FooService>();
const FooServiceLive = Layer.succeed(
  FooService,
  FooService.of({ bar: () => Logger.logInfo("Not implemented") }),
);

// Define your effect handler with dependencies
const myEffectHandler: EffectHandler<SNSEvent, FooService> = (event, context) =>
  Effect.gen(function* (_) {
    yield* _(Logger.logInfo("Received event", { event, context }));
    const service = yield* _(FooService);
    return yield* _(service.bar());
  });

// Create the global layer
const LambdaLive = Layer.provideMerge(
  FooServiceLive,
  Logger.DefaultPowerToolsLoggerLayer,
);

// Create the Lambda handler
export const handler = makeLambda(myEffectHandler, LambdaLive);

FAQs

Package last updated on 16 Apr 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc