It works in both frontend and Node.js backend projects. The goal is to help you write less boilerplate, keep things consistent, and reuse what already works — all in a modular way. Whether you’re building a plugin, a service, or a UI integration, this library helps you move faster and avoid surprises along the way.

When to Use

Use lib-commons-js whenever you need shared logic that’s been tested across Lerian’s ecosystem. It’s especially useful when you want to:
  • Integrate with Midaz.
  • Share data models across services.
  • Reduce boilerplate in TypeScript projects.

Key Features

  • Modular architecture: Import only the components you need to keep your project clean and focused.
  • TypeScript support: Written in TypeScript from the ground up for a better developer experience and type safety.
  • Core utilities: Ready-to-use helpers for logging, context handling, error management, and transaction processing.
  • Shared models: Centralized data models that ensure consistency across projects.
  • Business logic: Common rules and patterns used by multiple Midaz services, wrapped and ready to use.

Repository Structure

The repository is organized for clarity and modular usage:
  • commons/: Core modules and utilities.
  • Configuration files: Includes .eslintrc.js, .prettierrc, and tsconfig.json to enforce code quality.
  • Package management: Managed via package.json and package-lock.json.
  • Continuous integration: Automated releases set up with .github/ workflows and .releaserc.yml.

Getting Started

Requirements

You’ll need Node.js v23 or later to use this library.

1. Install the Library

npm install @lerian/lib-commons-js

2. Add the Library to Your Project

To use lib-commons-js, import the relevant subpackage in the file where you need it. The functions will be available through the named import:
import { transactions as lib } from '@lerian/lib-commons-js'

Contributing

We welcome contributions. If you’ve written logic that could benefit other services, let’s bring it into lib-commons-js. Make sure your code follows our standards and includes test coverage.

License

  • Apache 2.0 - refer to the LICENSE page for details.