Skip to content

Instantly share code, notes, and snippets.

@chaance
Last active March 12, 2021 19:39
Show Gist options
  • Save chaance/13148a897e0caa46f5a44849d0083236 to your computer and use it in GitHub Desktop.
Save chaance/13148a897e0caa46f5a44849d0083236 to your computer and use it in GitHub Desktop.
const PLAID_KEYS = ["CLIENT_ID", "PUBLIC_KEY", "SECRET_KEY"] as const;
const PREFIX = 'PLAID_'
const POST_FIX =
process.env.NODE_ENV === "development"
? "_DEV"
: process.env.NODE_ENV === "production"
? ""
: "_TEST";
export function getPlaidKey(keyId: typeof PLAID_KEYS[number]): string {
const name = PREFIX + keyId + POST_FIX;
const key = process.env[name];
if (key === undefined) {
throw new Error(`Missing ${name} environment variable`);
}
return key;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment