mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-13 06:21:21 -05:00
Validate env vars on boot up
This commit is contained in:
parent
86e55f229b
commit
7ba695f4e3
|
|
@ -12,6 +12,8 @@ const app = new App();
|
|||
|
||||
const PORT = 3001;
|
||||
|
||||
validateEnvVars();
|
||||
|
||||
passport.use(
|
||||
new DiscordStrategy(
|
||||
{
|
||||
|
|
@ -65,3 +67,22 @@ app
|
|||
.listen(PORT, () =>
|
||||
console.log(`Server ready at: https://localhost:${PORT}`)
|
||||
);
|
||||
|
||||
function validateEnvVars() {
|
||||
const logInEnvVars = [
|
||||
"DISCORD_CLIENT_ID",
|
||||
"DISCORD_CLIENT_SECRET",
|
||||
"DISCORD_CALLBACK_URL",
|
||||
].filter((envVar) => !process.env[envVar]);
|
||||
|
||||
if (logInEnvVars.length === 0) return;
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.warn(
|
||||
"Missing env vars for testing logging in:",
|
||||
logInEnvVars.join(", ")
|
||||
);
|
||||
} else {
|
||||
throw new Error("Missing env vars for logging in");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user