Skip to content

Commit 6f49eba

Browse files
committed
fix: removing org subs check temp
1 parent fb03b1f commit 6f49eba

File tree

3 files changed

+93
-96
lines changed

3 files changed

+93
-96
lines changed

functions/issue-scraper.ts

Lines changed: 88 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -7,113 +7,112 @@ import plainTextPlugin from "markdown-it-plain-text";
77
import { validatePOST } from "./validators";
88

99
interface MarkdownItWithPlainText extends markdownit {
10-
plainText: string;
11-
}
12-
10+
plainText: string;
11+
}
12+
1313
interface IssueMetadata {
14-
nodeId: string;
15-
number: number;
16-
title: string;
17-
body: string;
18-
state: string;
19-
repositoryName: string;
20-
repositoryId: number;
21-
assignees: string[];
22-
authorId: number;
23-
createdAt: string;
24-
closedAt: string | null;
25-
stateReason: string | null;
26-
updatedAt: string;
27-
}
28-
29-
interface IssueNode {
14+
nodeId: string;
15+
number: number;
16+
title: string;
17+
body: string;
18+
state: string;
19+
repositoryName: string;
20+
repositoryId: number;
21+
assignees: string[];
22+
authorId: number;
23+
createdAt: string;
24+
closedAt: string | null;
25+
stateReason: string | null;
26+
updatedAt: string;
27+
}
28+
29+
interface IssueNode {
30+
id: string;
31+
number: number;
32+
title: string;
33+
body: string;
34+
state: string;
35+
stateReason: string | null;
36+
createdAt: string;
37+
updatedAt: string;
38+
closedAt: string | null;
39+
author: {
40+
login: string;
41+
} | null;
42+
assignees: {
43+
nodes: Array<{
44+
login: string;
45+
}>;
46+
};
47+
repository: {
3048
id: string;
31-
number: number;
32-
title: string;
33-
body: string;
34-
state: string;
35-
stateReason: string | null;
36-
createdAt: string;
37-
updatedAt: string;
38-
closedAt: string | null;
39-
author: {
49+
name: string;
50+
owner: {
4051
login: string;
41-
} | null;
42-
assignees: {
43-
nodes: Array<{
44-
login: string;
45-
}>;
4652
};
47-
repository: {
48-
id: string;
49-
name: string;
50-
owner: {
51-
login: string;
52-
};
53-
};
54-
}
55-
56-
interface GraphQlSearchResponse {
57-
search: {
58-
pageInfo: {
59-
hasNextPage: boolean;
60-
endCursor: string | null;
61-
};
62-
nodes: Array<IssueNode>;
53+
};
54+
}
55+
56+
interface GraphQlSearchResponse {
57+
search: {
58+
pageInfo: {
59+
hasNextPage: boolean;
60+
endCursor: string | null;
6361
};
64-
}
62+
nodes: Array<IssueNode>;
63+
};
64+
}
6565

6666
export const corsHeaders = {
67-
"Access-Control-Allow-Origin": "*",
68-
"Access-Control-Allow-Methods": "GET",
69-
"Access-Control-Allow-Headers": "Content-Type",
67+
"Access-Control-Allow-Origin": "*",
68+
"Access-Control-Allow-Methods": "GET",
69+
"Access-Control-Allow-Headers": "Content-Type",
7070
};
7171

7272
export async function onRequest(ctx: Context): Promise<Response> {
73-
const { request, env } = ctx;
73+
const { request, env } = ctx;
7474

75-
try {
76-
switch (request.method) {
77-
case "POST": {
78-
const result = await validatePOST(request);
79-
if (!result.isValid || !result.gitHubUserId) {
80-
return new Response("Unauthorized", {
81-
headers: corsHeaders,
82-
status: 400,
83-
});
84-
}
85-
try {
86-
const supabase = new SupabaseClient(env.SUPABASE_URL, env.SUPABASE_ANON_KEY);
87-
const response = await issueScraper(result.gitHubUserId, supabase, env.VOYAGEAI_API_KEY, result.authToken);
88-
return new Response(response, {
89-
headers: corsHeaders,
90-
status: 200,
91-
});
92-
} catch (error) {
93-
console.error("Error processing request:", error);
94-
return new Response("Internal Server Error", {
95-
headers: corsHeaders,
96-
status: 500,
97-
});
98-
}
99-
}
100-
101-
default:
102-
return new Response("Method Not Allowed", {
103-
headers: corsHeaders,
104-
status: 405,
105-
});
75+
try {
76+
switch (request.method) {
77+
case "POST": {
78+
const result = await validatePOST(request);
79+
if (!result.isValid || !result.gitHubUserId) {
80+
return new Response("Unauthorized", {
81+
headers: corsHeaders,
82+
status: 400,
83+
});
10684
}
107-
} catch (error) {
108-
console.error("Error processing request:", error);
109-
return new Response("Internal Server Error", {
85+
try {
86+
const supabase = new SupabaseClient(env.SUPABASE_URL, env.SUPABASE_ANON_KEY);
87+
const response = await issueScraper(result.gitHubUserId, supabase, env.VOYAGEAI_API_KEY, result.authToken);
88+
return new Response(response, {
89+
headers: corsHeaders,
90+
status: 200,
91+
});
92+
} catch (error) {
93+
console.error("Error processing request:", error);
94+
return new Response("Internal Server Error", {
11095
headers: corsHeaders,
11196
status: 500,
97+
});
98+
}
99+
}
100+
101+
default:
102+
return new Response("Method Not Allowed", {
103+
headers: corsHeaders,
104+
status: 405,
112105
});
113106
}
107+
} catch (error) {
108+
console.error("Error processing request:", error);
109+
return new Response("Internal Server Error", {
110+
headers: corsHeaders,
111+
status: 500,
112+
});
113+
}
114114
}
115115

116-
117116
function markdownToPlainText(markdown: string | null): string | null {
118117
if (!markdown) return markdown;
119118
const md = markdownit() as MarkdownItWithPlainText;
@@ -122,7 +121,6 @@ function markdownToPlainText(markdown: string | null): string | null {
122121
return md.plainText;
123122
}
124123

125-
126124
const SEARCH_ISSUES_QUERY = `
127125
query SearchIssues($searchText: String!, $after: String) {
128126
search(
@@ -209,7 +207,6 @@ async function fetchUserIssues(octokit: InstanceType<typeof Octokit>, username:
209207
// Pulls issues from GitHub and stores them in Supabase
210208
async function issueScraper(username: string, supabase: SupabaseClient, voyageApiKey: string, token?: string): Promise<string> {
211209
try {
212-
213210
if (!username) {
214211
throw new Error("Username is required");
215212
}

src/home/getters/get-github-access-token.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ import { getLocalStore } from "./get-local-store";
99
export async function isOrgMemberWithoutScope() {
1010
const octokit = new Octokit({ auth: await getGitHubAccessToken() });
1111
try {
12-
await octokit.orgs.getMembershipForAuthenticatedUser({
13-
org: "ubiquity",
14-
});
12+
// await octokit.orgs.getMembershipForAuthenticatedUser({
13+
// org: "ubiquity",
14+
// });
1515
} catch (e) {
1616
if (e && typeof e === "object" && "status" in e && e.status === 404) {
1717
return false;

src/home/scraper/issue-scraper.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export async function startIssueScraper(username: string) {
1414
message: "Skipping fetch - last fetch was less than 24 hours ago",
1515
});
1616
}
17-
17+
1818
const response = await fetch("/issue-scraper", {
1919
method: "POST",
2020
headers: {
@@ -37,4 +37,4 @@ export async function startIssueScraper(username: string) {
3737
message: `Failed to fetch issues. Status: ${response.status}`,
3838
});
3939
}
40-
}
40+
}

0 commit comments

Comments
 (0)