Skip to content

constant

@tsed/di

Usage

typescript
import { constant } from "@tsed/di";

See /packages/di/src/common/fn/constant.ts.

Overview

ts
function constant<Type>(expression: string): Type | undefined;
export function constant<Type>(expression: string, defaultValue: Type | undefined): Type;
  • expression (string): Dot-notation path to the configuration value (e.g., "logger.level")

  • defaultValue (``): default value if the expression is not found

Description

Get a constant value from the injector configuration settings.

Retrieves a configuration value using dot notation path syntax. Useful for accessing environment variables, configuration constants, or settings.

Usage

typescript
import {constant} from "@tsed/di";

const apiKey = constant<string>("api.key");
const port = constant<number>("server.port", 3000);
const debug = constant<boolean>("logger.debug", false);

Released under the MIT License.