Skip to content

Commit

Permalink
add one more token for load balancing
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBurger committed Dec 13, 2023
1 parent 6d53806 commit f4e4925
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ GITHUB_TOKEN_1=
GITHUB_TOKEN_2=
GITHUB_TOKEN_3=
GITHUB_TOKEN_4=
GITHUB_TOKEN_5=

# The domain of the website
VITE_HOST=http://localhost:8080
Expand Down
1 change: 1 addition & 0 deletions src/helpers/domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ const parseBackendCredentials = () => {
GITHUB_TOKEN_2: z.string(),
GITHUB_TOKEN_3: z.string(),
GITHUB_TOKEN_4: z.string(),
GITHUB_TOKEN_5: z.string(),
SENTRY_DSN: z.string(),
})
.parse(process.env);
Expand Down
6 changes: 5 additions & 1 deletion src/server/github-token.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { backendCredentials } from "../helpers/domain.js";

const TOKENS = 4;
const TOKENS = 5;

export const getRandomGithubToken = (): string => {
const index = Math.ceil(Math.random() * TOKENS);
Expand All @@ -20,5 +20,9 @@ export const getRandomGithubToken = (): string => {
return backendCredentials().GITHUB_TOKEN_4;
}

if (index === 5) {
return backendCredentials().GITHUB_TOKEN_5;
}

throw new Error("GitHub token not found");
};

0 comments on commit f4e4925

Please sign in to comment.