Skip to content

Commit

Permalink
feat: added config to fetch github cred through config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
srijitcoder committed Oct 21, 2024
1 parent 71152e3 commit 2f485e0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
15 changes: 15 additions & 0 deletions config.js
Original file line number Diff line number Diff line change
@@ -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;
11 changes: 6 additions & 5 deletions src/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });

Expand Down

0 comments on commit 2f485e0

Please sign in to comment.