Skip to content

media-service-dev/environment

Repository files navigation

@mscs/environment

A library to load and interact with the environment.

Installation

$ yarn add @mscs/environment

Usage

Short example:

import { EnvironmentLoader, ProcessEnvironment } from "@mscs/environment";

async function runtime(){
    const environment = new ProcessEnvironment();
    const environmentLoader = new EnvironmentLoader(environment);

    await environmentLoader.loadEnvironment(__dirname + '/../.env');

    if(environment.has('FOO')){
        const foo = environment.get("FOO");
        // ...
    }
}

runtime()
    .catch(console.error);

This example expect that you are in a root file of the src directory in your project.

Documentation

Currently, you have to build the documentation on your own.

$ git clone git@github.com:media-service-dev/environment.git
$ cd environment
$ yarn
$ yarn run docs

Important note

The parser for .env-files and the environment file loading order logic was ported from Symfony.

Since Symfony is, for good reason, a registered trademark, please take note that we are in no way associated with the Symfony brand or the SensioLabs organization. Therefore, we don't represent or speak for any of them.

About

A library to load .env files and interact with the environment

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •