Skip to content

Instantly share code, notes, and snippets.

@kop7
Created August 12, 2020 18:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kop7/f453d6a691054ad72d02fd1df340cbc1 to your computer and use it in GitHub Desktop.
Save kop7/f453d6a691054ad72d02fd1df340cbc1 to your computer and use it in GitHub Desktop.
Config Service
import * as dotenv from 'dotenv';
import * as fs from 'fs';
export class ConfigService {
private readonly envConfig: { [key: string]: string };
constructor(filePath: string) {
this.envConfig = dotenv.parse(fs.readFileSync(filePath));
}
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