-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
75 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,7 @@ yarn-error.log* | |
# local env files | ||
.env*.local | ||
|
||
.env.prod | ||
.env.production | ||
|
||
# vercel | ||
.vercel | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
export interface Environment { | ||
discordClientId: string; | ||
discordClientPublicKey: string; | ||
discordToken: string; | ||
discordGuildId: string; | ||
authorizedRoleIds: string[]; | ||
reviewChannelId: string; | ||
} | ||
|
||
let environment: Environment | null = null; | ||
|
||
export function getEnvironment(): Environment { | ||
if (environment) { | ||
return environment; | ||
} | ||
|
||
if (!process.env.DISCORD_CLIENT_ID) { | ||
throw new Error("DISCORD_CLIENT_ID env var not configured"); | ||
} | ||
const discordClientId = process.env.DISCORD_CLIENT_ID; | ||
|
||
if (!process.env.DISCORD_CLIENT_PUBLIC_KEY) { | ||
throw new Error("DISCORD_CLIENT_PUBLIC_KEY env var not configured"); | ||
} | ||
const discordClientPublicKey = process.env.DISCORD_CLIENT_PUBLIC_KEY; | ||
|
||
if (!process.env.DISCORD_TOKEN) { | ||
throw new Error(`DISCORD_TOKEN env var not configured`); | ||
} | ||
const discordToken = process.env.DISCORD_TOKEN; | ||
|
||
if (!process.env.DISCORD_GUILD_ID) { | ||
throw new Error("DISCORD_GUILD_ID env var not configured"); | ||
} | ||
const discordGuildId = process.env.DISCORD_GUILD_ID; | ||
|
||
if (!process.env.DISCORD_MODERATION_ACCESS_ROLES) { | ||
throw new Error("DISCORD_MODERATION_ACCESS_ROLES env var not configured"); | ||
} | ||
const authorizedRoleIds = | ||
process.env.DISCORD_MODERATION_ACCESS_ROLES.split(","); | ||
|
||
if (!process.env.REVIEW_CHANNEL_ID) { | ||
throw new Error("REVIEW_CHANNEL_ID env var not configured"); | ||
} | ||
const reviewChannelId = process.env.REVIEW_CHANNEL_ID; | ||
|
||
environment = { | ||
discordClientId, | ||
discordClientPublicKey, | ||
discordToken, | ||
discordGuildId, | ||
authorizedRoleIds, | ||
reviewChannelId, | ||
}; | ||
|
||
return environment; | ||
} |