Last active
April 9, 2025 13:50
-
-
Save joewright/e7bb33901bb912448d120c2b8c6425fc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| declare var process: { | |
| env: {} | |
| } | |
| class EnvironmentConfig { | |
| name: string | |
| required_variable: string | |
| optional_variable: string | undefined | |
| constructor(env: any) { | |
| this.name = env.NODE_ENV || 'development' | |
| this.required_variable = env.REQUIRED_VARIABLE || undefined | |
| if (!this.required_variable) { | |
| throw new Error('REQUIRED_VARIABLE is not set') | |
| } | |
| this.optional_variable = env.OPTIONAL_VARIABLE | |
| } | |
| } | |
| export const ENV = new EnvironmentConfig(process.env) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { ENV } from './environment' | |
| console.log(ENV.name); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment