Files
ratrapage_T-WEB/front/src/libs/Env.ts
Clement 57a57c63ff
All checks were successful
Build Docker Image Front / run (push) Successful in 24s
Build Docker Image Back / run (push) Successful in 21s
feat: gestion-utilisateur (#1)
Reviewed-on: #1
Co-authored-by: Clement <c.boesmier@aptatio.com>
Co-committed-by: Clement <c.boesmier@aptatio.com>
2024-05-20 12:48:34 +02:00

18 lines
676 B
TypeScript

import type { ImportMetaEnv } from 'env'
/**
* Get the environment variable
*
* @param key the env variable key
* @param defaultValue a default value if applicable
* @returns the environment value or undefined if not found
*/
export function getEnv(key: keyof ImportMetaEnv, defaultValue: string): string
export function getEnv(key: keyof ImportMetaEnv, defaultValue?: string | undefined): string | undefined
export function getEnv(key: keyof ImportMetaEnv, defaultValue?: string | undefined): string | undefined {
// get the env variable through Astro > NodeJS > input
const res = import.meta.env[key] ?? process.env[key] ?? defaultValue
return res ?? undefined
}