@vyriy/handler

Composable AWS Lambda handler chains and wrappers for Vyriy projects.

Purpose

Use this package when a Vyriy project needs a small focused module for handler behavior.

Vyriy packages are intentionally small. The goal is to keep the public API explicit, easy to test, and easy to compose with the rest of the Vyriy ecosystem.

Install

With npm:

npm install @vyriy/handler

With Yarn:

yarn add @vyriy/handler

Usage

import { api, sqs, compose, withError, withLogger, withTimeout } from '@vyriy/handler';

export const httpHandler = api(async () => ({
  statusCode: 200,
  body: JSON.stringify({ ok: true }),
}));

export const queueHandler = sqs(async (event) => {
  for (const record of event.Records) {
    console.info(record.body);
  }
});

export const customHandler = compose(withError(), withLogger(), withTimeout())(async () => ({ ok: true }));

Public API

The package is expected to expose the following main surface:

  • api
  • streamApi
  • sqs
  • sns
  • s3
  • ses
  • dynamodb
  • schedule
  • eventBridge
  • compose
  • withError
  • withLogger
  • withChaos
  • withTimeout
  • withContext

Parameters and options

  • api(callback) — Wraps an API Gateway style Lambda callback.
  • streamApi(callback) — Wraps a response-streaming Lambda callback.
  • sqs/sns/s3/ses/dynamodb(callback) — Wraps event source callbacks.
  • schedule(callback) — Wraps scheduled EventBridge events.
  • eventBridge(callback) — Wraps custom EventBridge events.
  • compose(...wrappers) — Builds a custom handler pipeline.
  • withTimeout(options) — Protects a handler from running longer than expected.
  • withLogger(options) — Adds consistent logging around handler execution.

Examples

Minimal usage

import * as module from '@vyriy/handler';

console.info(module);

Use inside a Vyriy package

// packages/example/index.ts
export { default as example } from '@vyriy/handler';

Keep the boundary explicit

// Prefer importing from the package root unless a documented subpath is required.
import {} from /* named export */ '@vyriy/handler';

Notes

  • Keep configuration close to the package that owns it.
  • Prefer explicit options over hidden global state.
  • Keep examples small enough to copy into tests or Storybook docs.
  • When adding a new public export, document it in this README and add a focused test.

Related packages

  • @vyriy/config for environment-driven options.
  • @vyriy/script for readable operational flows.
  • @vyriy/handler and @vyriy/server when the package participates in runtime handling.