Skip to content

Commit 0d7e105

Browse files
committed
chore: remove token usage
1 parent f89c303 commit 0d7e105

File tree

2 files changed

+3
-14
lines changed

2 files changed

+3
-14
lines changed

src/app/generator/repo-tree-generator.tsx

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,6 @@ export default function RepoProjectStructure() {
6262
return
6363
}
6464

65-
const token = repoType === 'github' ? process.env.NEXT_PUBLIC_GITHUB_TOKEN : process.env.NEXT_PUBLIC_GITLAB_TOKEN;
66-
if (!token) {
67-
setValidation({ message: `${repoType === 'github' ? 'GitHub' : 'GitLab'} token is not set. Please set the appropriate environment variable.`, isError: true })
68-
return
69-
}
70-
7165
setLoading(true)
7266
try {
7367
const tree = await fetchProjectStructure(url, repoType)

src/lib/repo-tree-utils.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ interface GitLabTreeItem {
1313
type: 'tree' | 'blob';
1414
}
1515

16+
// Validate GitHub and GitLab URLs
1617
export const validateGitHubUrl = (url: string): boolean => {
1718
const githubUrlPattern = /^https?:\/\/github\.com\/[\w-]+\/[\w.-]+\/?$/;
1819
return githubUrlPattern.test(url);
@@ -24,15 +25,14 @@ export const validateGitLabUrl = (url: string): boolean => {
2425
};
2526

2627
const getOctokit = () => {
27-
const token = process.env.NEXT_PUBLIC_GITHUB_TOKEN;
2828
return new Octokit({
29-
auth: token,
3029
request: {
3130
fetch: fetch,
3231
},
3332
});
3433
};
3534

35+
// Fetch project structure from GitHub or GitLab
3636
export const fetchProjectStructure = async (repoUrl: string, repoType: 'github' | 'gitlab'): Promise<TreeItem[]> => {
3737
if (repoType === 'github') {
3838
return fetchGitHubProjectStructure(repoUrl);
@@ -81,16 +81,10 @@ const fetchGitHubProjectStructure = async (repoUrl: string): Promise<TreeItem[]>
8181

8282
const fetchGitLabProjectStructure = async (repoUrl: string): Promise<TreeItem[]> => {
8383
const projectId = encodeURIComponent(repoUrl.split('gitlab.com/')[1]);
84-
const token = process.env.NEXT_PUBLIC_GITLAB_TOKEN;
85-
86-
if (!token) {
87-
throw new Error('Missing GitLab token.');
88-
}
8984

9085
try {
9186
const response = await axios.get<GitLabTreeItem[]>(`https://gitlab.com/api/v4/projects/${projectId}/repository/tree`, {
9287
params: { recursive: true, per_page: 100 },
93-
headers: { 'PRIVATE-TOKEN': token },
9488
});
9589

9690
return response.data.map((item: GitLabTreeItem) => ({
@@ -106,6 +100,7 @@ const fetchGitLabProjectStructure = async (repoUrl: string): Promise<TreeItem[]>
106100
}
107101
};
108102

103+
// Generate and build project structure
109104
export const generateStructure = (tree: TreeItem[]): DirectoryMap => {
110105
const structureMap: DirectoryMap = new Map();
111106
tree.forEach((item: TreeItem) => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy