New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

@unifig/adapter-env

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unifig/adapter-env

Environmental variables adapter for unifig

latest
Source
npmnpm
Version
1.1.3
Version published
Weekly downloads
9
-40%
Maintainers
1
Weekly downloads
 
Created
Source

Env variables & files adapter for Unifig

Table of Contents

Installation

npm i @unifig/adapter-env
# or
yarn add @unifig/adapter-env

Quick Start

# .env
PORT=3000
export class DbSettings {
  @From('DB_URL')
  @IsString()
  url: string;

  @From('DB_PASSWORD')
  @IsString()
  password: string;
}

export class AppSettings {
  @From('PORT')
  @IsInt()
  port: number;

  @Nested(() => DbSettings)
  @IsDefined()
  db: DbSettings;
}
import { Config } from '@unifig/core';
import { EnvConfigAdapter } from '@unifig/adapter-env';

function bootstrap() {
  Config.registerSync({
    template: Settings,
    adapter: new EnvConfigAdapter(),
  });

  const { port } = Config.getValues(AppSettings);
  console.log(port); // output: 3000
}

bootstrap();

Options

PropertyWhat it doesRequired
envFilesPathsPath to optional environment files to be loaded in given order. Values from them will be overwritten by process envs.×
ignoreEnvVarsIf "true", environment variables will not be loaded.×
expandVariablesSee https://www.npmjs.com/package/dotenv-expand.×

License

This project is licensed under the MIT License - see the LICENSE file for details.

Keywords

unifig

FAQs

Package last updated on 02 Oct 2024

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