Skip to content

Instantly share code, notes, and snippets.

@ixahmedxi
Created June 21, 2019 04:58
Show Gist options
  • Save ixahmedxi/9eadb24c868dd40cdfe7f00b243914e2 to your computer and use it in GitHub Desktop.
Save ixahmedxi/9eadb24c868dd40cdfe7f00b243914e2 to your computer and use it in GitHub Desktop.
import * as dotenv from 'dotenv'
import * as fs from 'fs'
export class ConfigService {
private readonly envConfig: { [key: string]: string }
constructor(mode: 'development' | 'production') {
this.envConfig = dotenv.parse(fs.readFileSync(`${mode}.env`))
}
get(key: string): string {
return this.envConfig[key]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment