Skip to content

Commit b33f72c

Browse files
committed
chore: bump all (dev) deps
1 parent be6d4cb commit b33f72c

File tree

15 files changed

+272
-160
lines changed

15 files changed

+272
-160
lines changed

.editorconfig

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
root=true
2+
3+
[*]
4+
indent_style=space
5+
indent_size=2
6+
tab_width=2
7+
end_of_line=lf
8+
charset=utf-8
9+
trim_trailing_whitespace=true
10+
insert_final_newline=true

.github/FUNDING.yml

-2
This file was deleted.

.github/workflows/ci.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- pull_request
66

77
jobs:
8-
build:
8+
ci:
99
name: ${{ matrix.os }}
1010
runs-on: ${{ matrix.os }}
1111
strategy:
@@ -17,11 +17,11 @@ jobs:
1717

1818
steps:
1919
- name: Checkout Repo
20-
uses: actions/checkout@v3
20+
uses: actions/checkout@v4
2121

22-
- uses: denoland/setup-deno@v1
22+
- uses: denoland/setup-deno@v2
2323
with:
24-
deno-version: v1.x
24+
deno-version: v2.x
2525

2626
- name: Lint
2727
run: |

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!.vscode/settings.json

.renovaterc

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"extends": [
3+
"github>1stG/configs"
4+
]
5+
}

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"editor.defaultFormatter": "denoland.vscode-deno"
3+
}

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2022 Devno
3+
Copyright (c) 2022-present Devno
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,47 @@
33
Stable link that redirects to unstable [App Center][App Center] download link
44
via Deno Deploy.
55

6+
## TOC <!-- omit in toc -->
7+
8+
- [Usage](#usage)
9+
- [Examples](#examples)
10+
- [Sponsors and Backers](#sponsors-and-backers)
11+
- [Sponsors](#sponsors)
12+
- [Backers](#backers)
13+
- [License](#license)
14+
615
## Usage
716

817
`https://appcenter.deno.dev/{owner}/{app}/{version}`
918

1019
## Examples
1120

12-
1. `ClashX Pro`: https://appcenter.deno.dev/clashx/clashx-pro/1.30.3.2
13-
14-
2. `Timeless`: The followings version and short version are both fine.
21+
1. `Timeless`: The followings version and short version are both fine.
1522

1623
- https://appcenter.deno.dev/dangercove/timeless/2020.7
1724
- https://appcenter.deno.dev/dangercove/timeless/37
1825

1926
![Timeless](https://user-images.githubusercontent.com/8336744/98822766-30e03500-246c-11eb-8cab-f7c31d196f5a.png)
2027

28+
2. ~~`ClashX Pro`: https://appcenter.deno.dev/clashx/clashx-pro/1.30.3.2~~ (The
29+
source project is not available anymore.)
30+
31+
## Sponsors and Backers
32+
33+
[![Sponsors and Backers](https://raw.githubusercontent.com/1stG/static/master/sponsors.svg)](https://github.com/sponsors/JounQin)
34+
35+
### Sponsors
36+
37+
| 1stG | RxTS | UnTS |
38+
| ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
39+
| [![1stG Open Collective sponsors](https://opencollective.com/1stG/organizations.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective sponsors](https://opencollective.com/rxts/organizations.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective sponsors](https://opencollective.com/unts/organizations.svg)](https://opencollective.com/unts) |
40+
41+
### Backers
42+
43+
| 1stG | RxTS | UnTS |
44+
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- |
45+
| [![1stG Open Collective backers](https://opencollective.com/1stG/individuals.svg)](https://opencollective.com/1stG) | [![RxTS Open Collective backers](https://opencollective.com/rxts/individuals.svg)](https://opencollective.com/rxts) | [![UnTS Open Collective backers](https://opencollective.com/unts/individuals.svg)](https://opencollective.com/unts) |
46+
2147
## License
2248

2349
[MIT][MIT] © [JounQin][JounQin]@[1stG.me][1stG.me]

deno.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"start": "deno run --allow-read --allow-net main.ts"
1010
},
1111
"fmt": {
12-
"options": {
13-
"singleQuote": true
14-
}
12+
"semiColons": false,
13+
"singleQuote": true,
14+
"exclude": ["public/index.html"]
1515
}
1616
}

deno.lock

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

main.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import { serve } from 'https://deno.land/std@0.137.0/http/server.ts';
1+
import { appcenter } from './mod.ts'
22

3-
import { appcenter } from './mod.ts';
4-
5-
serve(appcenter);
3+
Deno.serve(appcenter)

mod.ts

+49-33
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,90 @@
11
export interface ReleaseInfo {
2-
id: string;
3-
version: string;
4-
short_version: string;
2+
id: string
3+
version: string
4+
short_version: string
55
}
66

77
export interface DownloadInfo {
8-
download_url: string;
8+
download_url: string
99
}
1010

11-
export const REDIRECT = 302;
12-
export const NOT_FOUND = 404;
11+
export interface ErrorResponse {
12+
code: number | string
13+
message: string
14+
}
15+
16+
const NOT_FOUND = 404
1317

1418
export async function appcenter(req: Request): Promise<Response> {
15-
let url = new URL(req.url).pathname;
19+
let url = new URL(req.url).pathname
1620

1721
if (!url || url === '/') {
18-
url = '/index.html';
22+
url = '/index.html'
1923
}
2024

2125
if (/\.[a-z]+[a-z\d]*$/.test(url)) {
22-
return new Response(await Deno.readFile(`./public${url}`));
26+
return new Response(await Deno.readFile(`./public${url}`))
2327
}
2428

25-
const matched = /\/([\w-]+)\/([\w-]+)\/([.\w]+)/.exec(url);
29+
const matched = /\/([\w-]+)\/([\w-]+)\/([.\w]+)/.exec(url)
2630

2731
if (!matched) {
28-
return new Response('Not Found', {
32+
return Response.json({
33+
code: NOT_FOUND,
34+
message: 'Not Found',
35+
}, {
2936
status: NOT_FOUND,
30-
});
37+
})
3138
}
3239

33-
const [, owner, app, version] = matched;
40+
const [, owner, app, version] = matched
3441

3542
const releasesUrl =
36-
`https://install.appcenter.ms/api/v0.1/apps/${owner}/${app}/distribution_groups/public/public_releases`;
43+
`https://install.appcenter.ms/api/v0.1/apps/${owner}/${app}/distribution_groups/public/public_releases`
44+
45+
console.log(`Fetching ${releasesUrl}`)
3746

38-
console.log(`Fetching ${releasesUrl}`);
47+
const releasesRes = await fetch(releasesUrl)
48+
49+
if (!releasesRes.ok) {
50+
return releasesRes
51+
}
3952

40-
const releases: ReleaseInfo[] = await fetch(releasesUrl).then((res) =>
41-
res.ok ? res.json() : []
42-
);
53+
const releases = await releasesRes.json() as ReleaseInfo[]
4354

4455
const found = releases.find(
4556
(it) => it.version === version || it.short_version === version,
46-
);
57+
)
4758

4859
if (!found) {
49-
return new Response(
50-
`No matched version ${version} found for ${owner}/${app}`,
60+
return Response.json(
61+
{
62+
code: NOT_FOUND,
63+
message: `No matched version ${version} found for ${owner}/${app}`,
64+
} satisfies ErrorResponse,
5165
{
5266
status: NOT_FOUND,
5367
},
54-
);
68+
)
5569
}
5670

5771
const releaseUrl =
58-
`https://install.appcenter.ms/api/v0.1/apps/${owner}/${app}/distribution_groups/public/releases/${found.id}`;
72+
`https://install.appcenter.ms/api/v0.1/apps/${owner}/${app}/distribution_groups/public/releases/${found.id}`
5973

60-
console.log(`Fetching ${releaseUrl}`);
74+
console.log(`Fetching ${releaseUrl}`)
6175

62-
const { download_url: downloadUrl }: DownloadInfo = await fetch(
76+
const downloadUrlRes = await fetch(
6377
releaseUrl,
64-
).then((res) => res.json());
78+
)
79+
80+
if (!downloadUrlRes.ok) {
81+
return downloadUrlRes
82+
}
83+
84+
const { download_url: downloadUrl } = await downloadUrlRes
85+
.json() as DownloadInfo
6586

66-
console.log(`Redirect to ${downloadUrl}`);
87+
console.log(`Redirect to ${downloadUrl}`)
6788

68-
return new Response(null, {
69-
status: REDIRECT,
70-
headers: {
71-
Location: downloadUrl,
72-
},
73-
});
89+
return Response.redirect(downloadUrl)
7490
}

0 commit comments

Comments
 (0)