@@ -11,12 +11,6 @@ import { Request, ExecutionContext } from '@cloudflare/workers-types';
11
11
import { WritableStream as WebWritableStream } from 'node:stream/web' ;
12
12
import { Env } from '../worker-configuration' ;
13
13
14
- declare global {
15
- const GITHUB_ACCOUNT : string ;
16
- const GITHUB_REPO : string ;
17
- const GITHUB_API_TOKEN : string ;
18
- }
19
-
20
14
const SendJSON = ( data : Record < string , unknown > ) => {
21
15
return new Response ( JSON . stringify ( data ) , {
22
16
headers : { 'Content-Type' : 'application/json; charset=utf-8' }
@@ -49,7 +43,7 @@ const handleV1Request = async (
49
43
if ( ! target || ! arch || ! appVersion || ! semverValid ( appVersion ) ) {
50
44
return responses . NotFound ( ) ;
51
45
}
52
- const release = await getLatestRelease ( request , env , ctx ) ;
46
+ const release = await getLatestRelease ( request , env ) ;
53
47
54
48
const remoteVersion = sanitizeVersion ( release . tag_name . toLowerCase ( ) ) ;
55
49
if ( ! remoteVersion || ! semverValid ( remoteVersion ) ) {
@@ -72,7 +66,7 @@ const handleV1Request = async (
72
66
}
73
67
74
68
const signature = await findAssetSignature ( match . name , release . assets ) ;
75
- const proxy = GITHUB_API_TOKEN ?. length ;
69
+ const proxy = env . GITHUB_API_TOKEN ?. length ;
76
70
const downloadURL = proxy
77
71
? createProxiedFileUrl ( request , env , ctx , match . browser_download_url )
78
72
: match . browser_download_url ;
@@ -107,14 +101,15 @@ const createProxiedFileUrl = (
107
101
const getLatestAssets = async (
108
102
request : Request ,
109
103
env : Env ,
104
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
110
105
ctx : ExecutionContext
111
106
) => {
112
107
const fileName = request . url . split ( '/' ) ?. at ( - 1 ) ;
113
108
if ( ! fileName ) {
114
109
throw new Error ( 'Could not get file name from download URL' ) ;
115
110
}
116
111
117
- const release = await getLatestRelease ( request , env , ctx ) ;
112
+ const release = await getLatestRelease ( request , env ) ;
118
113
const downloadPath = release . assets . find (
119
114
( { name } ) => name === fileName
120
115
) ?. browser_download_url ;
@@ -159,5 +154,5 @@ export async function handleRequest(
159
154
}
160
155
}
161
156
162
- return handleLegacyRequest ( request , env , ctx ) ;
157
+ return handleLegacyRequest ( request , env ) ;
163
158
}
0 commit comments