0.1.3 • Published 1 year ago

env-plus v0.1.3

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

env-plus

This is work in progress. Api changes frequently

Getting started

Run your favourite package manager

npm install env-plus
# yarn add env-plus
# pnpm install env-plus

Make sure you have these properties in typescript config

"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"strictPropertyInitialization": false

Create .env file with example variables

MESSAGE="hello there"
PORT="3000"
LOGGER="true"

Create your first env schema

import * as dotenv from 'dotenv'
dotenv.config()

import { EnvSchema, EnvProperty, EnvManager } from 'env-plus'

@EnvSchema()
export class MyEnvSchema {
  @EnvProperty('MESSAGE')
  message: string

  @EnvProperty('PORT')
  port: number

  @EnvProperty('LOGGER')
  logger: boolean
}

const env = EnvManager.getPlainInstance(MyEnvSchema)

console.log(env)

Returns an object with parsed values

{
  message: 'hello there',
  port: 3000,
  logger: true
}
0.1.3

1 year ago

0.1.2

1 year ago

0.1.1-alpha

1 year ago

0.1.0-alpha

1 year ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago