presenter-env 1.0.0
Install from the command line:
Learn more about npm packages
$ npm install @heronlabs/presenter-env@1.0.0
Install via package.json:
"@heronlabs/presenter-env": "1.0.0"
About this version
This is module for access process environment
Given key from environment retrieve the value.
npm install @heronlabs/presenter-env
yarn add @heronlabs/presenter-env
require('dotenv').config();
import {
BufferEnvPresenter,
EnvBootstrap,
Environment,
NumberEnvPresenter,
TextEnvPresenter,
} from '@heronlabs/presenter-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 {}