Skip to content

Commit 921d8d6

Browse files
committed
refactor(gh): get kv
1 parent 3d5838d commit 921d8d6

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

scripts/edgeone/edge-functions/gh/[[default]].js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@ async function loadAllowedOwners(context) {
6868
}
6969

7070
const owners = new Set(DEFAULT_OWNERS);
71-
const kv =
72-
(context && context.env && context.env.GH_KV) ||
73-
globalThis.GH_KV;
71+
const kv = context?.env?.GH_KV || globalThis.GH_KV;
7472

7573
if (kv && typeof kv.get === "function") {
7674
try {
@@ -128,9 +126,7 @@ export default async function onRequest(context) {
128126
if (ifModifiedSince) headers.set("if-modified-since", ifModifiedSince);
129127
headers.set("user-agent", "edgeone-gh-proxy");
130128
if (kind === "api") {
131-
const token =
132-
(context && context.env && context.env.GH_TOKEN) ||
133-
globalThis.GH_TOKEN;
129+
const token = context?.env?.GH_TOKEN || '';
134130
if (token) {
135131
headers.set("authorization", `Bearer ${token}`);
136132
}

0 commit comments

Comments
 (0)