1.0.0-beta.6 • Published 3 years ago

type-dotenv v1.0.0-beta.6

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

type-dotenv

An extremely simple typed dotenv loader.

Usage

import { join } from 'path';
import { config, load, IsBoolean, IsString, IsNumber } from 'type-dotenv';

class Environment {
  @IsString()
  NODE_ENV!: string;

  @IsNumber()
  PORT: number = 1337;

  @IsString()
  URL: string = 'http://localhost:1337';

  @IsBoolean()
  ENABLE_PLAYGROUND: boolean = false;

  // by default, everything is required
  @IsString({ required: false })
  ANALYTICS_KEY?: string;
}

// Same opts as `dotenv` package.
config({
  path: join(process.cwd(), '.env.development')
});

export const env = load(Environment);

console.log(env instanceof Environment) // true
1.0.0-beta.6

3 years ago

1.0.0-beta.4

3 years ago

1.0.0-beta.5

3 years ago

1.0.0-beta.3

4 years ago

1.0.0-beta.2

4 years ago

1.0.0-beta.1

4 years ago