# @lomray/microservice-helpers

> Package contains helpers for easy build and test microservices based on NodeJS & inverted json.

Latest version **2.19.0** (published 2025-09-22) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @lomray/microservice-helpers
pnpm add @lomray/microservice-helpers
yarn add @lomray/microservice-helpers
bun add @lomray/microservice-helpers
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.19.0 |
| Published | 2025-09-22 |
| First published | 2022-05-23 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 26 |
| Unpacked size | 464.2 KB |
| Known vulnerabilities | 0 (+6 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mikhail Yarmaliuk |
| Maintainers | matthew_patell |
| Keywords | js, microservice, helpers, ijson |

## Links

- npm: https://www.npmjs.com/package/@lomray/microservice-helpers
- Repository: https://github.com/Lomray-Software/microservice-helpers
- Issues: https://github.com/Lomray-Software/microservice-helpers/issues
- npm.io page: https://npm.io/package/@lomray/microservice-helpers

## Dependencies (26)

- [pg](https://npm.io/package/pg.md) ^8.11.1
- [uuid](https://npm.io/package/uuid.md) ^9.0.1
- [klona](https://npm.io/package/klona.md) ^2.0.6
- [typeorm](https://npm.io/package/typeorm.md) 0.2.41
- [winston](https://npm.io/package/winston.md) ^3.11.0
- [traverse](https://npm.io/package/traverse.md) ^0.6.7
- [winston-loki](https://npm.io/package/winston-loki.md) ^6.0.8
- [class-validator](https://npm.io/package/class-validator.md) ^0.14.0
- [class-transformer](https://npm.io/package/class-transformer.md) ^0.5.1
- [@opentelemetry/api](https://npm.io/package/@opentelemetry/api.md) ^1.7.0
- [@opentelemetry/sdk-node](https://npm.io/package/@opentelemetry/sdk-node.md) ^0.45.1
- [@opentelemetry/resources](https://npm.io/package/@opentelemetry/resources.md) ^1.18.1
- [@lomray/typeorm-json-query](https://npm.io/package/@lomray/typeorm-json-query.md) ^2.7.0
- [class-validator-jsonschema](https://npm.io/package/class-validator-jsonschema.md) ^5.0.0
- [@lomray/microservices-types](https://npm.io/package/@lomray/microservices-types.md) ^1.15.0
- [@opentelemetry/host-metrics](https://npm.io/package/@opentelemetry/host-metrics.md) ^0.33.2
- [@opentelemetry/instrumentation](https://npm.io/package/@opentelemetry/instrumentation.md) ^0.45.1
- [@lomray/microservice-nodejs-lib](https://npm.io/package/@lomray/microservice-nodejs-lib.md) ^3.0.0
- [@lomray/microservices-client-api](https://npm.io/package/@lomray/microservices-client-api.md) ^2.28.0
- [@opentelemetry/instrumentation-pg](https://npm.io/package/@opentelemetry/instrumentation-pg.md) ^0.37.1
- [@opentelemetry/semantic-conventions](https://npm.io/package/@opentelemetry/semantic-conventions.md) ^1.18.1
- [@lomray/microservice-remote-middleware](https://npm.io/package/@lomray/microservice-remote-middleware.md) ^1.9.0
- [@opentelemetry/instrumentation-express](https://npm.io/package/@opentelemetry/instrumentation-express.md) ^0.33.3
- [@opentelemetry/instrumentation-winston](https://npm.io/package/@opentelemetry/instrumentation-winston.md) ^0.33.0
- [@opentelemetry/exporter-trace-otlp-http](https://npm.io/package/@opentelemetry/exporter-trace-otlp-http.md) ^0.45.1
- [@opentelemetry/exporter-metrics-otlp-http](https://npm.io/package/@opentelemetry/exporter-metrics-otlp-http.md) ^0.45.1

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.19.0 (latest) — 2025-09-22
- 2.18.0 — 2024-03-26
- 2.17.0 — 2024-03-04
- 2.16.0 — 2023-12-20
- 2.15.0 — 2023-12-20
- 2.14.0 — 2023-12-14
- 2.13.0 — 2023-12-13
- 2.12.0 — 2023-12-13
- 2.11.0 — 2023-12-12
- 2.10.1 — 2023-11-28
- 2.10.0 — 2023-10-18
- 2.9.2 — 2023-10-03
- 2.9.1 — 2023-10-03
- 2.9.0 — 2023-09-21
- 2.8.4 — 2023-07-31
- … 139 more at https://npm.io/package/@lomray/microservice-helpers/versions

## README

# NodeJS Microservices helpers for [microservices](https://github.com/Lomray-Software/microservices)

![npm](https://img.shields.io/npm/v/@lomray/microservice-helpers)
![GitHub](https://img.shields.io/github/license/Lomray-Software/microservice-helpers)

[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=alert_status)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=reliability_rating)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)
[![Security Rating](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=security_rating)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=vulnerabilities)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)
[![Lines of Code](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=ncloc)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Lomray-Software_microservice-helpers&metric=coverage)](https://sonarcloud.io/summary/new_code?id=Lomray-Software_microservice-helpers)

## COMMON ENVIRONMENTS:
- `NODE_ENV` - Can be `production` or `development` or `tests`. Default: `development`
- `ENVIRONMENT` - Extra environment name. Default: `prod`
- `MS_CONNECTION` - Invert json host and port (with protocol). Default: `http://127.0.0.1:8001`
- `MS_CONNECTION_SRV` - Invert json connection it is SRV record. Default: `false`
- `MS_NAME` - Microservice name. Default: `authentication`
- `MS_WORKERS` - Microservice queue workers count. Default: `5`
- `MS_ENABLE_REMOTE_MIDDLEWARE` - Enable remote middleware feature. Set `0` to disable. Default: `1` (enabled)
- `MS_REMOTE_CONFIG_ENABLE` - Enable remote config (get from configuration microservice). Set `0` to disable. Default: `1`
- `MS_CONFIG_NAME` - Configuration microservice name. Default: `configuration`
- `ENABLE_EVENTS` - Enable events if microservice support it. Default: `0`
- `MS_GRAFANA_LOKI_CONFIG` - Grafana loki config. Default: `null`
- `MS_ENABLE_GRAFANA_LOG` - Enable grafana loki log (config from configuration ms). Default: `0`
- `MS_OPENTELEMETRY_ENABLE` - Enable opentelemetry tracers. Default: `0`
- `MS_DISABLE_OPENTELEMETRY_TRACES` - Disable opentelemetry traces. Default: `0`
- `MS_DISABLE_OPENTELEMETRY_METRICS` - Disable opentelemetry metrics. Default: `0`
- `MS_OPENTELEMETRY_OTLP_URL` - Custom opentelemetry OTLP exporter URL. Default: `undefined`
- `MS_OPENTELEMETRY_OTLP_URL_SRV` - Custom opentelemetry OTLP URL it is SRV record. Default: `0`
- `MS_OPENTELEMETRY_DEBUG` - Enable debug log opentelemetry. Default: `0`
- `MS_CONSOLE_LOG_LEVEL` - Change console log level, [see all levels](https://github.com/winstonjs/winston#logging-levels). Default: `info`

## COMMON ENVIRONMENTS - DB SUPPORT:
- `DB_URL` - Database url connection string. Default: `undefined`. Please use URL or credentials.
- `DB_HOST` - Database host. Default: `127.0.0.1`
- `DB_PORT` - Database port. Default: `5432`
- `DB_USERNAME` - Database user name. Default: `postgres`
- `DB_PASSWORD` - Database password. Default: `example`
- `DB_DATABASE` - Database name. Default: `ms-microservice-name`
- `DB_FROM_CONFIG_MS` - Get DB credentials from configuration microservice. Set `0` to disable. Default: `1`

## COMMON ENVIRONMENTS - AWS SUPPORT:
- `AWS_ACCESS_KEY_ID` - AWS access key ID. Default: `undefined`
- `AWS_SECRET_ACCESS_KEY` - AWS secret access key. Default: `undefined`
- `AWS_REGION` - AWS region. Default: `undefined`
- `AWS_BUCKET_NAME` - AWS S3 bucket name. Default: `undefined`
- `AWS_BUCKET_ACL` - AWS S3 bucket ACL (e.g.: public-read). Default: `undefined`
- `AWS_FROM_CONFIG_MS` - Get AWS credentials from configuration microservice. Set `0` to disable. Default: `1`

## COMMON ENVIRONMENTS - FIREBASE SUPPORT:
- `FIREBASE_CREDENTIAL` - Firebase credential JSON string. Default: `{}`
- `FIREBASE_FROM_CONFIG_MS` - Get firebase credential from configuration microservice. Set `0` to disable. Default: `1`

## This package contains:
 - Entities
    - IJson Query filter
 - Mocks
    - Typeorm
    - Typeorm extension
 - Helpers
    - Launchers (with/without db)
    - Create DB connection
    - Get common microservices constants ([see list ENVIRONMENT](#common-environments))
    - Get entity columns (EntityColumns)
    - Redact secrets for console outputs
    - Resolve SRV records
    - Tracer
 - Services
    - API Client (make requests to another microservices)
    - CRUD
    - Log
    - Microservice metadata
    - Remote config
    - Firebase SDK
 - Class validator: extra validators
 - Test helpers
 - Instrumentations for collect metrics

See [microservices](https://github.com/Lomray-Software/microservices) for example of usage.

---
_Source: https://npm.io/package/@lomray/microservice-helpers · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
