Laconia

Laconia

  • Getting Started
  • API
  • Help

›API Reference

Introduction

  • Getting Started
  • Motivation
  • Core Concepts
  • Philosophy
  • Examples
  • FAQ
  • Support Me

Laconia vs. Other

  • Claudia
  • Express, Koa, Hapi, etc.
  • Middy
  • Serverless, SAM, Apex, etc.

Guides

  • Injecting Dependencies
  • Unit Testing
  • Adapting Events
  • Creating API Endpoints
  • Retrieving Secrets
  • Retrieving Config
  • Warming Up
  • Invoking Other Lambdas
  • Long Running Tasks
  • Creating Middleware

API Reference

  • API Reference: Intro
  • core
  • event
  • adapter
  • adapter-api
  • invoker
  • config
  • batch
  • middleware-lambda-warmer
  • middleware-serverless-plugin-warmup
Edit

invoker

envVarInstances()

Scans environment variables set in the current Lambda and automatically creates instances of invoker.

Example:

/**
 * Lambda Environment variables:
 * - LACONIA_INVOKER_CALL_CAPTURE_CARD_PAYMENT_LAMBDA: capture-card-payment-lambda-name
 */

const invoker = require("@laconia/invoker");
const laconia = require("@laconia/core");

const app = async (input, { captureCardPaymentLambda }) => {
  /* logic */
};

exports.handler = laconia(app).register(invoker.envVarInstances());

Environment variable convention

Key: LACONIA_INVOKER_[VARIABLE_NAME]

Value: Full AWS Lambda name to be invoked

requestResponse(payload)

Invokes other Lambda synchronously, with invocation type RequestResponse. Error will be thrown if the invoked Lambda returns an error.

  • payload
    • The payload used for the Lambda invocation. Payload will be automatically JSON stringified

Example:

const app = async ({ fooInvoker }) => {
  await fooInvoker.requestResponse({ foo: "bar" });
};

fireAndForget(payload)

Invokes other Lambda asynchronously, with invocation type Event.

  • payload
    • The payload used for the Lambda invocation. Payload will be automatically JSON stringified

Example:

const app = async ({ fooInvoker }) => {
  await fooInvoker.fireAndForget({ foo: "bar" });
};
← adapter-apiconfig →
  • envVarInstances()
    • Environment variable convention
  • requestResponse(payload)
  • fireAndForget(payload)
Laconia
Docs
Getting StartedCore ConceptsAPI Reference
Community
Stack OverflowChat
More
TwitterGitHubStar
Copyright © 2022 Wisen Tanasa
Logo designed by Suzie Nam