.env file loader written in typescript
$ npm install --save @webacad/envor with yarn
$ yarn add @webacad/envimport{loadEnv}from'@webacad/env';constenv=loadEnv('path/to/.env');By default all values are returned as strings. This can be changed by providing schema where you can define returned types.
import{loadEnv}from'@webacad/env';constenv=loadEnv('path/to/.env',{NODE_ENV: {type: 'string',required: true,},SERVER_PORT: {type: 'number',},SOURCE_MAPS: {type: 'boolean',default: true,},});Options:
type:"string","number"or"boolean"(default:"string")required:boolean(default:false)default:anyorfunction