mirror of
https://github.com/d0zingcat/nextjs-notion-starter-kit.git
synced 2026-05-13 23:16:47 +00:00
18 lines
309 B
TypeScript
18 lines
309 B
TypeScript
export function getEnv(
|
|
key: string,
|
|
defaultValue?: string,
|
|
env = process.env
|
|
): string {
|
|
const value = env[key]
|
|
|
|
if (value !== undefined) {
|
|
return value
|
|
}
|
|
|
|
if (defaultValue !== undefined) {
|
|
return defaultValue
|
|
}
|
|
|
|
throw new Error(`Config error: missing required env var "${key}"`)
|
|
}
|