Nodular Pudding Multiverse

    @studiohyperdrive/env
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    Env

    Environment utility for NodeJS.

    Table of contents

    Getting Started

    Install the package

    # NPM
    npm install --save @studiohyperdrive/env
    
    # Yarn
    yarn add --save @studiohyperdrive/env

    Usage

    import Env from '@studiohyperdrive/env';

    get

    Fetches an environment variable as a string.

    get(key: string, allowNull = false): string

    Usage:

      const variable = Env.get('PARAM_NAME');
      const nullableVariable = Env.get('PARAM_NAME', true);

    getAsBoolean

    Casts the fetched environment variable to a boolean.

    getAsBoolean(key: string): number

    Usage:

      const variable = Env.getAsBoolean('PARAM_NAME');

    getAsNumber

    Casts the fetched environment variable to a number.

    getAsNumber(key: string): number

    Usage:

      const variable = Env.getAsNumber('PARAM_NAME');

    getAsArray

    Casts the fetched environment variable to an Array.

    getAsArray(key: string, separator = ','): number

    Usage:

      const variable = Env.getAsArray('PARAM_NAME', ';');

    getAsObject

    Casts the fetched environment variable to an object using JSON.parse.

    getAsObject(key: string): number

    Usage:

      const variable = Env.getAsObject('PARAM_NAME');

    validateEnv

    Validate process.env against a Joi Schema.

    validateEnv(schema: Joi.Schema, options: Joi.ValidationOptions): ValidationResult

    Usage:

      const validationResult = Env.validateEnv(schema, options);

    validateEnvAsync

    Validate process.env against a Joi Schema in an asynchronous fashion.

    validateEnvAsync(schema: Joi.Schema, options: Joi.ValidationOptions): ValidationResult

    Usage:

      const validationResult = await Env.validateEnvAsync(schema, options);

    Keywords

    none

    Install

    npm i @studiohyperdrive/env

    DownloadsWeekly Downloads

    92

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    22.6 kB

    Total Files

    16

    Last publish

    Collaborators

    • spammelies
    • shd-developer
    • bavo-vanderghote-shd
    • ian-emsens-shd
    • jeroenvalcke
    • tom-odb
    • brilniels
    • thomasbormans
    • sanderh
    • laurenspeeters
    • ex03495
    • rednas
    • denisvalcke
    • ibenvandeveire