Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@unifig/env

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@unifig/env

Environmental variables adapter for unifig

  • 0.2.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Env variables & files adapter for Unifig

Table of contents

Installation

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

Quick Start

# .env
PORT=3000
export class Settings {
  @From('PORT')
  @IsInt()
  port: number;
}
import { Config } from '@unifig/core';
import { EnvConfigAdapter } from '@unifig/env';

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

  console.log(Config.get(Settings).port); // output: 3000
}

bootstrap();

Properties Mapping

Environment variables are mapped to 1D dictionary.

# .env
PORT=3000
DB_HOST=localhost
DB_PORT=4588
// adapter output
{
  PORT: 3000,
  DB_HOST: 'localhost',
  DB_PORT: 4588
}

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

FAQs

Package last updated on 17 Oct 2022

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc