# @homeofthings/nestjs-utils

> HomeOfThings - NestJs Utils: various utilities and common types

Latest version **2.1.5** (published 2026-10-24) · MIT license · 0 weekly downloads

## Install

```sh
npm install @homeofthings/nestjs-utils
pnpm add @homeofthings/nestjs-utils
yarn add @homeofthings/nestjs-utils
bun add @homeofthings/nestjs-utils
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; no vulnerabilities; has provenance; recently updated; high maintenance score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.1.5 |
| Published | 2026-10-24 |
| First published | 2021-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=22.22.2 |
| Dependencies | 2 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 6 |
| Author | Guenter Sandner |
| Maintainers | gms1 |
| Keywords | nestjs, nest, node |

## Links

- npm: https://www.npmjs.com/package/@homeofthings/nestjs-utils
- Repository: https://github.com/gms1/HomeOfThings
- Issues: https://github.com/gms1/HomeOfThings/issues
- npm.io page: https://npm.io/package/@homeofthings/nestjs-utils

## Dependencies (2)

- [tslib](https://npm.io/package/tslib.md) ^2.8.1
- [@homeofthings/node-utils](https://npm.io/package/@homeofthings/node-utils.md) ~1.0.8

## Alternatives

- [@expo/fingerprint](https://npm.io/package/@expo/fingerprint.md) — 6.2M weekly downloads
- [@azure/monitor-opentelemetry-exporter](https://npm.io/package/@azure/monitor-opentelemetry-exporter.md) — 850.0K weekly downloads
- [@azure/monitor-opentelemetry](https://npm.io/package/@azure/monitor-opentelemetry.md) — 624.0K weekly downloads
- [@posthog/ai](https://npm.io/package/@posthog/ai.md) — 423.3K weekly downloads
- [fakefilter](https://npm.io/package/fakefilter.md) — 63.9K weekly downloads

## Recent versions

- 2.1.5 (latest) — 2026-10-24
- 2.1.4 — 2026-10-17
- 2.1.3 — 2026-08-16
- 2.1.2 — 2026-06-07
- 2.1.1 — 2026-03-19
- 2.1.0 — 2025-04-26
- 2.0.4 — 2024-12-22
- 2.0.3 — 2024-10-26
- 2.0.2 — 2024-01-05
- 2.0.1 — 2023-12-19
- 2.0.0 — 2023-11-19
- 1.0.6 — 2022-06-23
- 1.0.5 — 2022-04-18
- 1.0.4 — 2021-09-14
- 1.0.3 — 2021-09-01
- … 1 more at https://npm.io/package/@homeofthings/nestjs-utils/versions

## README

[![npm version](https://badge.fury.io/js/%40homeofthings%2Fnestjs-utils.svg)](https://badge.fury.io/js/%40homeofthings%2Fnestjs-utils)
[![Build Workflow](https://github.com/gms1/HomeOfThings/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/gms1/HomeOfThings/actions/workflows/build.yml)
[![Coverage Status](https://codecov.io/gh/gms1/HomeOfThings/branch/master/graph/badge.svg?flag=nestjs-utils)](https://app.codecov.io/gh/gms1/HomeOfThings/tree/master/packages%2Fnode%2F%40homeofthings%2Fnestjs-utils)
[![DeepScan grade](https://deepscan.io/api/teams/439/projects/987/branches/1954/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=439&pid=987&bid=1954)
[![Known Vulnerabilities](https://snyk.io/test/github/gms1/HomeOfThings/badge.svg)](https://snyk.io/test/github/gms1/HomeOfThings)

[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](http://makeapullrequest.com)
[![License](https://img.shields.io/npm/l/@homeofthings/nestjs-utils.svg?style=flat-square)](https://github.com/gms1/HomeOfThings/blob/master/packages/node/@homeofthings/nestjs-utils/LICENSE)

# HomeOfThings - common utilities for NestJs

[HomeOfThings](https://github.com/gms1/HomeOfThings)

## installation

```bash
npm install @homeofthings/nestjs-utils
```

## Dynamic Modules

## quick start

```Typescript
export const MY_MODULE_OPTIONS_TOKEN = 'MY_MODULE_OPTIONS_TOKEN';
export interface MyModuleOptions {
  ....
}

@Module({
  providers: [MyService],
  exports: [MyService],
})
export class MyModule extends createDynamicRootModule<MyModule, MyModuleOptions>(MY_MODULE_OPTIONS_TOKEN) {
}
```

> NOTE: additional module properties for 'imports', 'exports', 'providers' or 'controllers' can be passed as second parameter to this function

<!-- -->

> NOTE: of course the module can also be global scoped by the @Global() decorator

- use it synchronously:

```Typescript
const myModuleOptions: MyModuleOptions = {
  ...
}

@Module({
  imports: [MyModule.forRoot(MyModule, myModuleOptions)],
})
export class AppModule {}
```

- use it asynchonously:

```Typescript
const myAsyncModuleOptions: AsyncModuleOptions<MyModuleOptions> = {
  ...
}

@Module({
  imports: [MyModule.forRootAsync(MyModule, myAsyncModuleOptions)],
})
export class AppModule {}
```

> NOTE: forRoot/forRootAsync throws if the module is already registered.
> You can call register/registerAsync if you really want to register it more than once

- import it in any child module:

```Typescript
@Module({
  imports: [MyModule.forChild()],
})
export class ChildModule {}
```

> NOTE: no need to do this if the module is global scoped

### examples

- providing single option using either `forRoot` or `forRootAsync`

[@homeofthings/nestjs-logger](https://github.com/gms1/HomeOfThings/tree/master/projects/node/libs/nestjs-logger/)

- providing multiple options using eihter `register` or `registerAsync` (e.g. providing multiple connections)

[@homeofthings/nestjs-sqlite3](https://github.com/gms1/HomeOfThings/tree/master/projects/node/libs/nestjs-sqlite3/)

## more utilities

- `class LruCache<T>` - LRU cache
- `class AsyncContext<T>` - asynchronouse contest based on `AsyncLocalStorage`

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