diff --git a/config.js b/config.js new file mode 100644 index 0000000..d6c19fd --- /dev/null +++ b/config.js @@ -0,0 +1,15 @@ +// config.js +const config = { + githubOwner: import.meta.env.VUE_APP_GITHUB_OWNER || "", + githubRepo: import.meta.env.VUE_APP_GITHUB_REPO || "", + githubAuthToken: async () => { + async function getGithubAuthToken() { + // Fetch GitHub Token through API or through event listeners or through other functions + return ""; // return the token here + } + + return import.meta.env.VUE_APP_GITHUB_TOKEN || (await getGithubAuthToken()); + }, +}; + +export default config; diff --git a/src/api/index.js b/src/api/index.js index 1773362..bb26a91 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -6,12 +6,13 @@ import { checkStatusFromRefHead, sessionReviewStatus, } from "@/api/session"; +import config from "@/../config.js"; -const githubConfig = { - auth: import.meta.env.VUE_APP_GITHUB_TOKEN, - username: import.meta.env.VUE_APP_GITHUB_OWNER, - repo: import.meta.env.VUE_APP_GITHUB_REPO, -}; +const auth = await config.githubAuthToken(); +const username = config.githubOwner; +const repo = config.githubRepo; + +const githubConfig = { auth, username, repo }; const octokit = new Octokit({ auth: githubConfig.auth });