2.1.0 • Published 3 years ago

@heronlabs/env v2.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Env

License: MIT Build Status

This is module for access process environment

TypeScript GTS Jest NestJS NPM

How it works

Given key from environment retrieve the value.

Installation

npm install -g @heronlabs/env

Usage

require('dotenv').config();

import {
  BufferEnvPresenter,
  EnvBootstrap,
  Environment,
  NumberEnvPresenter,
  TextEnvPresenter,
} from '@heronlabs/env';

import {Module, Inject} from '@nestjs/common';

export class Configuration {
  public server = {
    port: this.numberEnvPresenter.getValueByKey('API_PORT'),
  };

  public jwt = {
    publicKey: this.bufferEnvPresenter.getValueByKey('JWT_PUBLIC_KEY_PATH'),
    algorithm: this.textEnvPresenter.getValueByKey('JWT_ALGORITHM'),
  };

  constructor(
    @Inject(NumberEnvPresenter) private numberEnvPresenter: Environment<number>,
    @Inject(BufferEnvPresenter) private bufferEnvPresenter: Environment<Buffer>,
    @Inject(TextEnvPresenter) private textEnvPresenter: Environment<string>
  ) {}
}

@Module({
  providers: [Configuration],
  imports: [EnvBootstrap],
})
export class ApiBootstrap {}

Built with

2.0.2

3 years ago

2.1.0

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.1.0

3 years ago

1.0.0

3 years ago