npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@felloh-org/lambda-wrapper

v1.11.196

Published

Lambda wrapper for all Felloh Serverless Projects

Downloads

1,180

Readme

Lambda Wrapper

release

A shared library for Felloh serverless projects that provides core functionality including dependency injection, logging, request handling, database entities, and response models for AWS Lambda functions.

Installation

npm install @felloh-org/lambda-wrapper
# or
yarn add @felloh-org/lambda-wrapper

Quick Start

import { LambdaWrapper, DEFINITIONS, ResponseModel } from '@felloh-org/lambda-wrapper';

const configuration = {
  SERVICE_NAME: 'my-service',
};

export const handler = LambdaWrapper(configuration, async (di, request) => {
  const logger = di.get(DEFINITIONS.LOGGER);
  const warehouse = di.get(DEFINITIONS.WAREHOUSE);

  logger.info('Processing request');

  // Your handler logic here

  return new ResponseModel({ message: 'Success' }, 200).generate();
});

Features

Lambda Wrapper

The core wrapper provides:

  • Dependency Injection - Access services via di.get(DEFINITIONS.SERVICE_NAME)
  • Automatic Error Handling - Catches and formats errors consistently
  • Request Parsing - Parses body, query params, path params, and headers
  • Logging & Metrics - Built-in logging with automatic metric collection
  • Warm-up Support - Handles serverless-plugin-warmup events automatically

Built-in Services

Access these via di.get(DEFINITIONS.SERVICE_NAME):

| Service | Definition | Description | |---------|------------|-------------| | Logger | DEFINITIONS.LOGGER | Structured logging with metric support | | Request | DEFINITIONS.REQUEST | Parsed request data (body, params, headers) | | Warehouse | DEFINITIONS.WAREHOUSE | TypeORM database connection manager | | Authentication | DEFINITIONS.AUTHENTICATION | JWT authentication and user context | | EventBridge | DEFINITIONS.EVENT_BRIDGE | AWS EventBridge event publishing | | Secrets | DEFINITIONS.SECRETS | AWS Secrets Manager integration | | HTTP | DEFINITIONS.HTTP | HTTP client for external requests | | Webhook | DEFINITIONS.WEBHOOK | Webhook dispatch service | | User | DEFINITIONS.USER | User service utilities | | AuditLogger | DEFINITIONS.AUDIT_LOGGER | Audit trail logging |

Response Model

All Lambda responses are standardised:

import { ResponseModel } from '@felloh-org/lambda-wrapper';

// Success response
return new ResponseModel({ users: [...] }, 200).generate();

// Error response
return new ResponseModel({}, 400)
  .setErrors([{ field: 'email', message: 'Invalid email' }])
  .generate();

Response format:

{
  "statusCode": 200,
  "headers": {
    "Content-Type": "application/json",
    "Access-Control-Allow-Origin": "*"
  },
  "body": {
    "data": { ... },
    "errors": [],
    "meta": {
      "code": 200,
      "reason": "OK",
      "message": "Success",
      "request_id": "uuid"
    }
  }
}

Database Entities (TypeORM)

The library includes TypeORM entities organised by domain:

| Domain | Description | |--------|-------------| | payment | Transactions, refunds, chargebacks, payment links, providers | | user | Users, organisations, roles, features, webhooks | | bank | Accounts, ledgers, settlements, disbursals | | agent-data | Bookings, components, suppliers | | acquirer | BIN data, batches, adjustments | | aisp | Open banking transactions and connections | | nuapay | Nuapay integration entities | | nuvei | Nuvei payment processor entities | | trust-payments | Trust Payments integration | | total-processing | Total Processing integration | | planet | Planet payment processor entities | | saltedge | Saltedge banking integration | | basis-theory | Tokenisation entities | | go-cardless | GoCardless Direct Debit | | marketing | Marketing contacts and ESUs |

EventBridge Events

Publish events to AWS EventBridge:

import { LambdaWrapper, DEFINITIONS, TransactionCustomerReceipt } from '@felloh-org/lambda-wrapper';

export const handler = LambdaWrapper(configuration, async (di, request) => {
  const eventBridge = di.get(DEFINITIONS.EVENT_BRIDGE);

  const event = new TransactionCustomerReceipt();
  event.setCustomerEmail('[email protected]');
  event.setOrgName('Acme Travel');
  event.setAmount(150000);
  event.setCurrencyMajorUnit('GBP');
  event.setId('txn_123');

  await eventBridge.send(event);
});

See Event Documentation for all available events.

Dependency Injection

Create custom services by extending DependencyAwareClass:

import { DependencyAwareClass, DEFINITIONS } from '@felloh-org/lambda-wrapper';

class MyCustomService extends DependencyAwareClass {
  async doSomething() {
    const logger = this.di.get(DEFINITIONS.LOGGER);
    const warehouse = this.di.get(DEFINITIONS.WAREHOUSE);

    // Your service logic
  }
}

// Register in configuration
const configuration = {
  DEPENDENCIES: {
    MY_SERVICE: MyCustomService,
  },
};

Development

Commands

# Build for production (webpack)
yarn build

# Build for TypeORM migrations (babel)
yarn build:orm

# Run linter
yarn lint

# Run tests with coverage
yarn test

# Run database migrations
yarn orm:migration:run

# Generate a new migration
yarn orm:migration:generate <name>

# Revert last migration
yarn orm:revert

# Create database schemas
yarn orm:schema:create

Environment Variables

| Variable | Description | |----------|-------------| | SERVICE_NAME | Service identifier for logging and events | | EVENT_BRIDGE_ARN | AWS EventBridge bus ARN | | DB_HOST | Database host | | DB_PORT | Database port | | DB_USERNAME | Database username | | DB_PASSWORD | Database password | | DB_DATABASE | Database name |

Project Structure

src/
├── config/          # Dependency definitions
├── dependency-injection/  # DI implementation
├── entity/          # TypeORM entities by domain
├── event/           # EventBridge event classes
├── migration/       # Database migrations by schema
├── model/           # Response and data models
├── service/         # Core services
├── util/            # Utility functions
└── wrapper/         # Lambda wrapper implementation

License

MIT