Skip to content

Commit

Permalink
Merge pull request #18 from EOX-A/session-handling/config
Browse files Browse the repository at this point in the history
Feat: Config method that returns GH token, username and repo
  • Loading branch information
silvester-pari authored Oct 21, 2024
2 parents 9cd5e1a + 2f485e0 commit 4d13549
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 @@ -7,12 +7,13 @@ import {
checkStatus,
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 4d13549

Please sign in to comment.