@@ -7,6 +7,15 @@ import {
7
7
import semverValid from 'semver/functions/valid'
8
8
import semverGt from 'semver/functions/gt'
9
9
10
+
11
+ type TauriUpdateResponse = {
12
+ url : string ,
13
+ version : string ,
14
+ notes ?: string ,
15
+ pub_date ?: string ,
16
+ signature ?: string
17
+ }
18
+
10
19
const GITHUB_ACCOUNT = 'killeencode'
11
20
const GITHUB_REPO = 'brancato'
12
21
export async function handleRequest ( request : Request ) : Promise < Response > {
@@ -39,6 +48,7 @@ export async function handleRequest(request: Request): Promise<Response> {
39
48
if ( ! remoteVersion || ! semverValid ( remoteVersion ) ) {
40
49
return new Response ( 'Not found' , { status : 404 } )
41
50
}
51
+
42
52
const shouldUpdate = semverGt ( remoteVersion , version )
43
53
if ( ! shouldUpdate ) {
44
54
return new Response ( null , { status : 204 } )
@@ -53,15 +63,15 @@ export async function handleRequest(request: Request): Promise<Response> {
53
63
54
64
// try to find signature for this asset
55
65
const signature = await findAssetSignature ( name , release . assets )
56
-
66
+ const data : TauriUpdateResponse = {
67
+ url : browser_download_url ,
68
+ version : remoteVersion ,
69
+ notes : release . body ,
70
+ pub_date : release . published_at ,
71
+ signature,
72
+ }
57
73
return new Response (
58
- JSON . stringify ( {
59
- name : release . tag_name ,
60
- notes : release . body ,
61
- pub_date : release . published_at ,
62
- signature,
63
- url : browser_download_url ,
64
- } ) ,
74
+ JSON . stringify ( data ) ,
65
75
{ headers : { 'Content-Type' : 'application/json; charset=utf-8' } } ,
66
76
)
67
77
}
0 commit comments