Socket
Book a DemoInstallSign in
Socket

@abinnovision/nestjs-configx

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@abinnovision/nestjs-configx

latest
Source
npmnpm
Version
2.0.1
Version published
Maintainers
1
Created
Source

@abinnovision/nestjs-configx

Type-safe configuration for NestJS using Standard Schema.

Goals

  • Type-safe configuration from process.env
  • Schema-agnostic via Standard Schema (Zod, ArkType, etc.)
  • Minimal NestJS integration (just a provider, no module)
  • Fail-fast validation at startup

Non-goals

  • Multiple config sources (at least not yet)
  • Async schema validation
  • Runtime config reloading
  • Secret management / encryption

Installation

yarn add @abinnovision/nestjs-configx

Usage

1. Define your config

import { configx } from "@abinnovision/nestjs-configx";
import { z } from "zod";

export class AppConfigx extends configx(
  z.object({
    PORT: z.string().default("3000").transform(Number),
    HOST: z.string().default("0.0.0.0"),
  }),
) {}

2. Register as provider

import { Module } from "@nestjs/common";
import { AppConfigx } from "./app.configx";

@Module({
  providers: [AppConfigx],
  exports: [AppConfigx],
})
export class AppModule {}

3. Inject and use

@Injectable()
export class AppService {
  constructor(private readonly config: AppConfigx) {}

  getPort() {
    return this.config.PORT; // number - fully typed
  }
}

Schema Libraries

Any Standard Schema compatible library works. Tested with:

ArkType Example

import { configx } from "@abinnovision/nestjs-configx";
import { type } from "arktype";

export class AppConfigx extends configx(
  type({
    PORT: "string.numeric.parse = '3000'",
    HOST: "string = '0.0.0.0'",
  }),
) {}

Error Handling

Invalid configuration throws InvalidConfigError at instantiation with details about which fields failed validation.

Keywords

nestjs

FAQs

Package last updated on 16 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts