mirror of
https://github.com/linsa-io/linsa.git
synced 2026-04-26 10:18:34 +02:00
Move to TanStack Start from Next.js (#184)
This commit is contained in:
33
web/app/lib/utils/env.ts
Normal file
33
web/app/lib/utils/env.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
/**
|
||||
*
|
||||
* Utility function to get env variables.
|
||||
*
|
||||
* @param name env variable name
|
||||
* @param defaultVaue default value to return if the env variable is not set
|
||||
* @returns string
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export const getEnvVariable = (
|
||||
name: string,
|
||||
defaultVaue: string = "",
|
||||
): string => {
|
||||
// Node envs
|
||||
if (
|
||||
typeof process !== "undefined" &&
|
||||
process.env &&
|
||||
typeof process.env[name] === "string"
|
||||
) {
|
||||
return (process.env[name] as string) || defaultVaue
|
||||
}
|
||||
|
||||
if (
|
||||
typeof import.meta !== "undefined" &&
|
||||
import.meta.env &&
|
||||
typeof import.meta.env[name] === "string"
|
||||
) {
|
||||
return import.meta.env[name]
|
||||
}
|
||||
|
||||
return defaultVaue
|
||||
}
|
||||
Reference in New Issue
Block a user