From 66773fba1702e332cda7861907bcfe06cfdd9849 Mon Sep 17 00:00:00 2001
From: Souma <101255979+5ouma@users.noreply.github.com>
Date: Fri, 11 Oct 2024 16:11:29 +0900
Subject: [PATCH] Follow the Deno 2 (#81)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
### โ ๏ธ Issue
close #
### ๐ Type of the Change
- [ ] ๐ New Feature
- [ ] ๐งฐ Bug
- [ ] ๐ก๏ธ Security
- [ ] ๐ Documentation
- [ ] ๐๏ธ Performance
- [x] ๐งน Refactoring
- [ ] ๐งช Testing
- [ ] ๐ง Maintenance
- [ ] ๐ฝ CI
- [ ] โ๏ธ Dependencies
- [ ] ๐ง Meta
### โ๏ธ Description
Get the benefits of the Deno 2.
- [x] I agree to follow the [Code of
Conduct](https://github.com/5ouma/reproxy/blob/main/.github/CODE_OF_CONDUCT.md).
---------
Signed-off-by: Souma <101255979+5ouma@users.noreply.github.com>
---
.../actions/setup-deno-with-cache/action.yml | 4 +-
.github/workflows/ci.yml | 2 +-
deno.json | 11 +-
deno.lock | 327 +++++++++---------
src/libs/content.ts | 15 +-
src/libs/redirect.ts | 12 +
src/libs/test_utils.ts | 8 +-
src/libs/utils.ts | 2 +
src/server.ts | 2 +
9 files changed, 206 insertions(+), 177 deletions(-)
diff --git a/.github/actions/setup-deno-with-cache/action.yml b/.github/actions/setup-deno-with-cache/action.yml
index dda24d8..ab0bf7a 100644
--- a/.github/actions/setup-deno-with-cache/action.yml
+++ b/.github/actions/setup-deno-with-cache/action.yml
@@ -6,9 +6,7 @@ runs:
steps:
- name: ๐ฆ Setup Deno
- uses: denoland/setup-deno@5e01c016a857a4dbb5afe9d0f9733cd472cba985 # v1.5.1
- with:
- deno-version: v1.x
+ uses: denoland/setup-deno@4606d5cc6fb3f673efd4f594850e3f4b3e9d29cd # v2.0.0
- name: ๐ซ Cache Deno Dependencies
uses: actions/cache@3624ceb22c1c5a301c8db4169662070a689d9ea8 # v4.1.1
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 99b9f22..17cf64e 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -58,7 +58,7 @@ jobs:
uses: ./.github/actions/setup-deno-with-cache
- name: ๐ Type Check
- run: deno check ./src
+ run: deno check --doc ./src
test:
name: ๐งช Test
diff --git a/deno.json b/deno.json
index 7274e43..326afb8 100644
--- a/deno.json
+++ b/deno.json
@@ -8,15 +8,16 @@
},
"fmt": { "exclude": ["LICENSE", "README.md", ".github/**/*.md"] },
"tasks": {
- "serve": "deno serve --env='.env' --allow-env --allow-net='api.github.com'",
- "start": "deno task serve src/server.ts",
- "dev": "deno task serve --watch src/server.ts",
- "test": "deno test --allow-env --allow-net='api.github.com' --parallel --shuffle",
+ "run": "deno run --env-file='.env' -EN='api.github.com'",
+ "start": "deno task run src/server.ts",
+ "dev": "deno task run --watch src/server.ts",
+ "test": "deno test --doc -EN='api.github.com' --parallel --shuffle",
"cov": "deno task test --coverage && deno coverage --lcov > coverage.lcov"
},
"imports": {
- "@octokit/rest": "npm:@octokit/rest@21.0.2",
"@hono/hono": "jsr:@hono/hono@4.6.3",
+ "@octokit/request-error": "npm:@octokit/request-error@6.1.5",
+ "@octokit/rest": "npm:@octokit/rest@21.0.2",
"@std/assert": "jsr:@std/assert@1.0.6",
"@std/http": "jsr:@std/http@1.0.8",
"@std/path": "jsr:@std/path@1.0.6"
diff --git a/deno.lock b/deno.lock
index ae1d0b9..32f2002 100644
--- a/deno.lock
+++ b/deno.lock
@@ -1,178 +1,173 @@
{
- "version": "3",
- "packages": {
- "specifiers": {
- "jsr:@hono/hono@4.6.3": "jsr:@hono/hono@4.6.3",
- "jsr:@std/assert@1.0.6": "jsr:@std/assert@1.0.6",
- "jsr:@std/bytes@^1.0.2": "jsr:@std/bytes@1.0.2",
- "jsr:@std/cli@^1.0.6": "jsr:@std/cli@1.0.6",
- "jsr:@std/encoding@^1.0.5": "jsr:@std/encoding@1.0.5",
- "jsr:@std/fmt@^1.0.2": "jsr:@std/fmt@1.0.2",
- "jsr:@std/http@1.0.8": "jsr:@std/http@1.0.8",
- "jsr:@std/internal@^1.0.4": "jsr:@std/internal@1.0.4",
- "jsr:@std/media-types@^1.0.3": "jsr:@std/media-types@1.0.3",
- "jsr:@std/net@^1.0.4": "jsr:@std/net@1.0.4",
- "jsr:@std/path@1.0.6": "jsr:@std/path@1.0.6",
- "jsr:@std/path@^1.0.6": "jsr:@std/path@1.0.6",
- "jsr:@std/streams@^1.0.7": "jsr:@std/streams@1.0.7",
- "npm:@octokit/rest@21.0.2": "npm:@octokit/rest@21.0.2_@octokit+core@6.1.2"
- },
- "jsr": {
- "@hono/hono@4.6.3": {
- "integrity": "a1f5a18cd12a0db54755b0461dd5a4e2d93a6f85403073eb710103eacc42daf3"
- },
- "@std/assert@1.0.6": {
- "integrity": "1904c05806a25d94fe791d6d883b685c9e2dcd60e4f9fc30f4fc5cf010c72207",
- "dependencies": [
- "jsr:@std/internal@^1.0.4"
- ]
- },
- "@std/bytes@1.0.2": {
- "integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57"
- },
- "@std/cli@1.0.6": {
- "integrity": "d22d8b38c66c666d7ad1f2a66c5b122da1704f985d3c47f01129f05abb6c5d3d"
- },
- "@std/encoding@1.0.5": {
- "integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04"
- },
- "@std/fmt@1.0.2": {
- "integrity": "87e9dfcdd3ca7c066e0c3c657c1f987c82888eb8103a3a3baa62684ffeb0f7a7"
- },
- "@std/http@1.0.8": {
- "integrity": "6ea1b2e8d33929967754a3b6d6c6f399ad6647d7bbb5a466c1eaf9b294a6ebcd",
- "dependencies": [
- "jsr:@std/cli@^1.0.6",
- "jsr:@std/encoding@^1.0.5",
- "jsr:@std/fmt@^1.0.2",
- "jsr:@std/media-types@^1.0.3",
- "jsr:@std/net@^1.0.4",
- "jsr:@std/path@^1.0.6",
- "jsr:@std/streams@^1.0.7"
- ]
- },
- "@std/internal@1.0.4": {
- "integrity": "62e8e4911527e5e4f307741a795c0b0a9e6958d0b3790716ae71ce085f755422"
- },
- "@std/media-types@1.0.3": {
- "integrity": "b12d30a7852f7578f4d210622df713bbfd1cbdd9b4ec2eaf5c1845ab70bab159"
- },
- "@std/net@1.0.4": {
- "integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
- },
- "@std/path@1.0.6": {
- "integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed"
- },
- "@std/streams@1.0.7": {
- "integrity": "1a93917ca0c58c01b2bfb93647189229b1702677f169b6fb61ad6241cd2e499b",
- "dependencies": [
- "jsr:@std/bytes@^1.0.2"
- ]
- }
- },
- "npm": {
- "@octokit/auth-token@5.1.1": {
- "integrity": "sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA==",
- "dependencies": {}
- },
- "@octokit/core@6.1.2": {
- "integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==",
- "dependencies": {
- "@octokit/auth-token": "@octokit/auth-token@5.1.1",
- "@octokit/graphql": "@octokit/graphql@8.1.1",
- "@octokit/request": "@octokit/request@9.1.3",
- "@octokit/request-error": "@octokit/request-error@6.1.5",
- "@octokit/types": "@octokit/types@13.5.1",
- "before-after-hook": "before-after-hook@3.0.2",
- "universal-user-agent": "universal-user-agent@7.0.2"
- }
- },
- "@octokit/endpoint@10.1.1": {
- "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",
- "dependencies": {
- "@octokit/types": "@octokit/types@13.5.1",
- "universal-user-agent": "universal-user-agent@7.0.2"
- }
- },
- "@octokit/graphql@8.1.1": {
- "integrity": "sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==",
- "dependencies": {
- "@octokit/request": "@octokit/request@9.1.3",
- "@octokit/types": "@octokit/types@13.5.1",
- "universal-user-agent": "universal-user-agent@7.0.2"
- }
- },
- "@octokit/openapi-types@22.2.0": {
- "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg==",
- "dependencies": {}
- },
- "@octokit/plugin-paginate-rest@11.3.3_@octokit+core@6.1.2": {
- "integrity": "sha512-o4WRoOJZlKqEEgj+i9CpcmnByvtzoUYC6I8PD2SA95M+BJ2x8h7oLcVOg9qcowWXBOdcTRsMZiwvM3EyLm9AfA==",
- "dependencies": {
- "@octokit/core": "@octokit/core@6.1.2",
- "@octokit/types": "@octokit/types@13.5.1"
- }
- },
- "@octokit/plugin-request-log@5.3.1_@octokit+core@6.1.2": {
- "integrity": "sha512-n/lNeCtq+9ofhC15xzmJCNKP2BWTv8Ih2TTy+jatNCCq/gQP/V7rK3fjIfuz0pDWDALO/o/4QY4hyOF6TQQFUw==",
- "dependencies": {
- "@octokit/core": "@octokit/core@6.1.2"
- }
- },
- "@octokit/plugin-rest-endpoint-methods@13.2.4_@octokit+core@6.1.2": {
- "integrity": "sha512-gusyAVgTrPiuXOdfqOySMDztQHv6928PQ3E4dqVGEtOvRXAKRbJR4b1zQyniIT9waqaWk/UDaoJ2dyPr7Bk7Iw==",
- "dependencies": {
- "@octokit/core": "@octokit/core@6.1.2",
- "@octokit/types": "@octokit/types@13.5.1"
- }
- },
- "@octokit/request-error@6.1.5": {
- "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",
- "dependencies": {
- "@octokit/types": "@octokit/types@13.5.1"
- }
- },
- "@octokit/request@9.1.3": {
- "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",
- "dependencies": {
- "@octokit/endpoint": "@octokit/endpoint@10.1.1",
- "@octokit/request-error": "@octokit/request-error@6.1.5",
- "@octokit/types": "@octokit/types@13.5.1",
- "universal-user-agent": "universal-user-agent@7.0.2"
- }
- },
- "@octokit/rest@21.0.2_@octokit+core@6.1.2": {
- "integrity": "sha512-+CiLisCoyWmYicH25y1cDfCrv41kRSvTq6pPWtRroRJzhsCZWZyCqGyI8foJT5LmScADSwRAnr/xo+eewL04wQ==",
- "dependencies": {
- "@octokit/core": "@octokit/core@6.1.2",
- "@octokit/plugin-paginate-rest": "@octokit/plugin-paginate-rest@11.3.3_@octokit+core@6.1.2",
- "@octokit/plugin-request-log": "@octokit/plugin-request-log@5.3.1_@octokit+core@6.1.2",
- "@octokit/plugin-rest-endpoint-methods": "@octokit/plugin-rest-endpoint-methods@13.2.4_@octokit+core@6.1.2"
- }
- },
- "@octokit/types@13.5.1": {
- "integrity": "sha512-F41lGiWBKPIWPBgjSvaDXTTQptBujnozENAK3S//nj7xsFdYdirImKlBB/hTjr+Vii68SM+8jG3UJWRa6DMuDA==",
- "dependencies": {
- "@octokit/openapi-types": "@octokit/openapi-types@22.2.0"
- }
- },
- "before-after-hook@3.0.2": {
- "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==",
- "dependencies": {}
- },
- "universal-user-agent@7.0.2": {
- "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==",
- "dependencies": {}
- }
+ "version": "4",
+ "specifiers": {
+ "jsr:@hono/hono@4.6.3": "4.6.3",
+ "jsr:@std/assert@1.0.6": "1.0.6",
+ "jsr:@std/bytes@^1.0.2": "1.0.2",
+ "jsr:@std/cli@^1.0.6": "1.0.6",
+ "jsr:@std/encoding@^1.0.5": "1.0.5",
+ "jsr:@std/fmt@^1.0.2": "1.0.2",
+ "jsr:@std/http@1.0.8": "1.0.8",
+ "jsr:@std/internal@^1.0.4": "1.0.4",
+ "jsr:@std/media-types@^1.0.3": "1.0.3",
+ "jsr:@std/net@^1.0.4": "1.0.4",
+ "jsr:@std/path@1.0.6": "1.0.6",
+ "jsr:@std/path@^1.0.6": "1.0.6",
+ "jsr:@std/streams@^1.0.7": "1.0.7",
+ "npm:@octokit/request-error@6.1.5": "6.1.5",
+ "npm:@octokit/rest@21.0.2": "21.0.2_@octokit+core@6.1.2"
+ },
+ "jsr": {
+ "@hono/hono@4.6.3": {
+ "integrity": "a1f5a18cd12a0db54755b0461dd5a4e2d93a6f85403073eb710103eacc42daf3"
+ },
+ "@std/assert@1.0.6": {
+ "integrity": "1904c05806a25d94fe791d6d883b685c9e2dcd60e4f9fc30f4fc5cf010c72207",
+ "dependencies": [
+ "jsr:@std/internal"
+ ]
+ },
+ "@std/bytes@1.0.2": {
+ "integrity": "fbdee322bbd8c599a6af186a1603b3355e59a5fb1baa139f8f4c3c9a1b3e3d57"
+ },
+ "@std/cli@1.0.6": {
+ "integrity": "d22d8b38c66c666d7ad1f2a66c5b122da1704f985d3c47f01129f05abb6c5d3d"
+ },
+ "@std/encoding@1.0.5": {
+ "integrity": "ecf363d4fc25bd85bd915ff6733a7e79b67e0e7806334af15f4645c569fefc04"
+ },
+ "@std/fmt@1.0.2": {
+ "integrity": "87e9dfcdd3ca7c066e0c3c657c1f987c82888eb8103a3a3baa62684ffeb0f7a7"
+ },
+ "@std/http@1.0.8": {
+ "integrity": "6ea1b2e8d33929967754a3b6d6c6f399ad6647d7bbb5a466c1eaf9b294a6ebcd",
+ "dependencies": [
+ "jsr:@std/cli",
+ "jsr:@std/encoding",
+ "jsr:@std/fmt",
+ "jsr:@std/media-types",
+ "jsr:@std/net",
+ "jsr:@std/path@^1.0.6",
+ "jsr:@std/streams"
+ ]
+ },
+ "@std/internal@1.0.4": {
+ "integrity": "62e8e4911527e5e4f307741a795c0b0a9e6958d0b3790716ae71ce085f755422"
+ },
+ "@std/media-types@1.0.3": {
+ "integrity": "b12d30a7852f7578f4d210622df713bbfd1cbdd9b4ec2eaf5c1845ab70bab159"
+ },
+ "@std/net@1.0.4": {
+ "integrity": "2f403b455ebbccf83d8a027d29c5a9e3a2452fea39bb2da7f2c04af09c8bc852"
+ },
+ "@std/path@1.0.6": {
+ "integrity": "ab2c55f902b380cf28e0eec501b4906e4c1960d13f00e11cfbcd21de15f18fed"
+ },
+ "@std/streams@1.0.7": {
+ "integrity": "1a93917ca0c58c01b2bfb93647189229b1702677f169b6fb61ad6241cd2e499b",
+ "dependencies": [
+ "jsr:@std/bytes"
+ ]
+ }
+ },
+ "npm": {
+ "@octokit/auth-token@5.1.1": {
+ "integrity": "sha512-rh3G3wDO8J9wSjfI436JUKzHIxq8NaiL0tVeB2aXmG6p/9859aUOAjA9pmSPNGGZxfwmaJ9ozOJImuNVJdpvbA=="
+ },
+ "@octokit/core@6.1.2": {
+ "integrity": "sha512-hEb7Ma4cGJGEUNOAVmyfdB/3WirWMg5hDuNFVejGEDFqupeOysLc2sG6HJxY2etBp5YQu5Wtxwi020jS9xlUwg==",
+ "dependencies": [
+ "@octokit/auth-token",
+ "@octokit/graphql",
+ "@octokit/request",
+ "@octokit/request-error",
+ "@octokit/types",
+ "before-after-hook",
+ "universal-user-agent"
+ ]
+ },
+ "@octokit/endpoint@10.1.1": {
+ "integrity": "sha512-JYjh5rMOwXMJyUpj028cu0Gbp7qe/ihxfJMLc8VZBMMqSwLgOxDI1911gV4Enl1QSavAQNJcwmwBF9M0VvLh6Q==",
+ "dependencies": [
+ "@octokit/types",
+ "universal-user-agent"
+ ]
+ },
+ "@octokit/graphql@8.1.1": {
+ "integrity": "sha512-ukiRmuHTi6ebQx/HFRCXKbDlOh/7xEV6QUXaE7MJEKGNAncGI/STSbOkl12qVXZrfZdpXctx5O9X1AIaebiDBg==",
+ "dependencies": [
+ "@octokit/request",
+ "@octokit/types",
+ "universal-user-agent"
+ ]
+ },
+ "@octokit/openapi-types@22.2.0": {
+ "integrity": "sha512-QBhVjcUa9W7Wwhm6DBFu6ZZ+1/t/oYxqc2tp81Pi41YNuJinbFRx8B133qVOrAaBbF7D/m0Et6f9/pZt9Rc+tg=="
+ },
+ "@octokit/plugin-paginate-rest@11.3.3_@octokit+core@6.1.2": {
+ "integrity": "sha512-o4WRoOJZlKqEEgj+i9CpcmnByvtzoUYC6I8PD2SA95M+BJ2x8h7oLcVOg9qcowWXBOdcTRsMZiwvM3EyLm9AfA==",
+ "dependencies": [
+ "@octokit/core",
+ "@octokit/types"
+ ]
+ },
+ "@octokit/plugin-request-log@5.3.1_@octokit+core@6.1.2": {
+ "integrity": "sha512-n/lNeCtq+9ofhC15xzmJCNKP2BWTv8Ih2TTy+jatNCCq/gQP/V7rK3fjIfuz0pDWDALO/o/4QY4hyOF6TQQFUw==",
+ "dependencies": [
+ "@octokit/core"
+ ]
+ },
+ "@octokit/plugin-rest-endpoint-methods@13.2.4_@octokit+core@6.1.2": {
+ "integrity": "sha512-gusyAVgTrPiuXOdfqOySMDztQHv6928PQ3E4dqVGEtOvRXAKRbJR4b1zQyniIT9waqaWk/UDaoJ2dyPr7Bk7Iw==",
+ "dependencies": [
+ "@octokit/core",
+ "@octokit/types"
+ ]
+ },
+ "@octokit/request-error@6.1.5": {
+ "integrity": "sha512-IlBTfGX8Yn/oFPMwSfvugfncK2EwRLjzbrpifNaMY8o/HTEAFqCA1FZxjD9cWvSKBHgrIhc4CSBIzMxiLsbzFQ==",
+ "dependencies": [
+ "@octokit/types"
+ ]
+ },
+ "@octokit/request@9.1.3": {
+ "integrity": "sha512-V+TFhu5fdF3K58rs1pGUJIDH5RZLbZm5BI+MNF+6o/ssFNT4vWlCh/tVpF3NxGtP15HUxTTMUbsG5llAuU2CZA==",
+ "dependencies": [
+ "@octokit/endpoint",
+ "@octokit/request-error",
+ "@octokit/types",
+ "universal-user-agent"
+ ]
+ },
+ "@octokit/rest@21.0.2_@octokit+core@6.1.2": {
+ "integrity": "sha512-+CiLisCoyWmYicH25y1cDfCrv41kRSvTq6pPWtRroRJzhsCZWZyCqGyI8foJT5LmScADSwRAnr/xo+eewL04wQ==",
+ "dependencies": [
+ "@octokit/core",
+ "@octokit/plugin-paginate-rest",
+ "@octokit/plugin-request-log",
+ "@octokit/plugin-rest-endpoint-methods"
+ ]
+ },
+ "@octokit/types@13.5.1": {
+ "integrity": "sha512-F41lGiWBKPIWPBgjSvaDXTTQptBujnozENAK3S//nj7xsFdYdirImKlBB/hTjr+Vii68SM+8jG3UJWRa6DMuDA==",
+ "dependencies": [
+ "@octokit/openapi-types"
+ ]
+ },
+ "before-after-hook@3.0.2": {
+ "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A=="
+ },
+ "universal-user-agent@7.0.2": {
+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q=="
}
},
- "remote": {},
"workspace": {
"dependencies": [
"jsr:@hono/hono@4.6.3",
"jsr:@std/assert@1.0.6",
"jsr:@std/http@1.0.8",
"jsr:@std/path@1.0.6",
+ "npm:@octokit/request-error@6.1.5",
"npm:@octokit/rest@21.0.2"
]
}
diff --git a/src/libs/content.ts b/src/libs/content.ts
index b81f117..1f4053f 100644
--- a/src/libs/content.ts
+++ b/src/libs/content.ts
@@ -1,4 +1,5 @@
import { Octokit } from "@octokit/rest";
+import type { RequestError } from "@octokit/request-error";
import type { StatusCode } from "@std/http";
export type { StatusCode };
@@ -12,6 +13,8 @@ import type { Repository } from "./types.ts";
*
* @example Use the default branch
* ```ts
+ * import type { Repository } from "./types.ts";
+ *
* const repository: Repository = {
* owner: "denoland",
* name: "deno",
@@ -21,6 +24,8 @@ import type { Repository } from "./types.ts";
* ```
* @example Use a specific branch
* ```ts
+ * import type { Repository } from "./types.ts";
+ *
* const repository: Repository = {
* owner: "denoland",
* name: "deno",
@@ -31,6 +36,8 @@ import type { Repository } from "./types.ts";
* ```
* @example Use a specific tag
* ```ts
+ * import type { Repository } from "./types.ts";
+ *
* const repository: Repository = {
* owner: "denoland",
* name: "deno",
@@ -41,6 +48,8 @@ import type { Repository } from "./types.ts";
* ```
* @example Use a specific commit
* ```ts
+ * import type { Repository } from "./types.ts";
+ *
* const repository: Repository = {
* owner: "denoland",
* name: "deno",
@@ -69,6 +78,10 @@ export async function getContent(
return [data.toString(), status];
} catch (error) {
- return [`โ ๏ธ ${error.status}: ${error.message}`, error.status];
+ const requestError = error as RequestError;
+ return [
+ `โ ๏ธ ${requestError.status}: ${requestError.message}`,
+ requestError.status as StatusCode,
+ ];
}
}
diff --git a/src/libs/redirect.ts b/src/libs/redirect.ts
index 5dc822f..c18b709 100644
--- a/src/libs/redirect.ts
+++ b/src/libs/redirect.ts
@@ -13,6 +13,9 @@ import { getGitHubUrl } from "./utils.ts";
*
* @example Use the default branch
* ```ts
+ * import { UserAgent } from "@std/http/user-agent";
+ * import type { Repository } from "./types.ts";
+ *
* const userAgent = new UserAgent("Chrome/1.2.3");
* const repository: Repository = {
* owner: "denoland",
@@ -23,6 +26,9 @@ import { getGitHubUrl } from "./utils.ts";
* ```
* @example Use a specific branch
* ```ts
+ * import { UserAgent } from "@std/http/user-agent";
+ * import type { Repository } from "./types.ts";
+ *
* const userAgent = new UserAgent("Chrome/1.2.3");
* const repository: Repository = {
* owner: "denoland",
@@ -34,6 +40,9 @@ import { getGitHubUrl } from "./utils.ts";
* ```
* @example Use a specific tag
* ```ts
+ * import { UserAgent } from "@std/http/user-agent";
+ * import type { Repository } from "./types.ts";
+ *
* const userAgent = new UserAgent("Chrome/1.2.3");
* const repository: Repository = {
* owner: "denoland",
@@ -45,6 +54,9 @@ import { getGitHubUrl } from "./utils.ts";
* ```
* @example Use a specific commit
* ```ts
+ * import { UserAgent } from "@std/http/user-agent";
+ * import type { Repository } from "./types.ts";
+ *
* const userAgent = new UserAgent("Chrome/1.2.3");
* const repository: Repository = {
* owner: "denoland",
diff --git a/src/libs/test_utils.ts b/src/libs/test_utils.ts
index c589cfc..7927de7 100644
--- a/src/libs/test_utils.ts
+++ b/src/libs/test_utils.ts
@@ -57,7 +57,13 @@ export const testUserAgent = new UserAgent("Chrome/1.2.3");
*
* @example
* ```ts
- * const repository = new Repository("5ouma", "reproxy", "src/server.ts");
+ * import type { Repository } from "./types.ts";
+ *
+ * const repository: Repository = {
+ * owner: "denoland",
+ * name: "deno",
+ * path: "README.md",
+ * };
* exportRepo(repository);
* ```
*/
diff --git a/src/libs/utils.ts b/src/libs/utils.ts
index a619489..56a53ab 100644
--- a/src/libs/utils.ts
+++ b/src/libs/utils.ts
@@ -11,6 +11,8 @@ import type { Repository } from "./types.ts";
*
* @example
* ```ts
+ * import type { Repository } from "./types.ts";
+ *
* const repository: Repository = {
* owner: "5ouma",
* name: "reproxy",
diff --git a/src/server.ts b/src/server.ts
index 4adab7b..5e80c3e 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -16,6 +16,8 @@ import { checkRedirect, getContent, type Repository } from "./libs/mod.ts";
* ```
* @example Access with a user agent
* ```ts
+ * import { UserAgent } from "@std/http/user-agent";
+ *
* const res: Response = await app.request("/", {
* headers: { "User-Agent": new UserAgent("Chrome/1.2.3").toString() },
* });