diff options
Diffstat (limited to 'src/lib/env.ts')
-rw-r--r-- | src/lib/env.ts | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/lib/env.ts b/src/lib/env.ts new file mode 100644 index 0000000..2f0a632 --- /dev/null +++ b/src/lib/env.ts @@ -0,0 +1,25 @@ +let skyblockStatsApiKey: string | undefined +let discordClientId: string | undefined + +export default function env(platform?: Readonly<App.Platform>) { + try { + skyblockStatsApiKey = process.env.SKYBLOCK_STATS_API_KEY + } catch { + skyblockStatsApiKey = platform?.env.SKYBLOCK_STATS_API_KEY + } + if (!skyblockStatsApiKey) + console.warn('SKYBLOCK_STATS_API_KEY is not set as an environment variable. This is required for logging in with Discord to work. It should be the same as the `key` environment variable in skyblock-api.') + + try { + discordClientId = process.env.DISCORD_CLIENT_ID + } catch { + discordClientId = platform?.env.DISCORD_CLIENT_ID + } + if (!discordClientId) + console.warn('DISCORD_CLIENT_ID is not set as an environment variable. This is required for logging in with Discord to work.') + + return { + SKYBLOCK_STATS_API_KEY: skyblockStatsApiKey, + DISCORD_CLIENT_ID: discordClientId, + } +}
\ No newline at end of file |