website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
bd41d91
— pyrossh
2026-07-08T19:51:11+05:30
fix: import types from ../types in gitBug, add @types/dom
- package.json +2 -1
- packages/shared/types/src/env.d.ts +1 -0
- packages/workers/assets/src/index.ts +16 -5
- packages/workers/assets/wrangler.jsonc +2 -1
- packages/workers/dev-router/src/index.ts +1 -1
- packages/workers/dev-router/wrangler.jsonc +4 -1
- scripts/deploy-all.sh +4 -6
- src/lib/gitBug.ts +1 -26
- worker-configuration.d.ts +1 -0
package.json
CHANGED
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"@cloudflare/workers-types": "^4.20250214.0",
|
|
24
24
|
"wrangler": "^4.0.0",
|
|
25
|
-
"typescript": "^5.7.0"
|
|
25
|
+
"typescript": "^5.7.0",
|
|
26
|
+
"@types/dom": "latest"
|
|
26
27
|
}
|
|
27
28
|
}
|
packages/shared/types/src/env.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export interface Env {
|
|
2
2
|
REPOS: R2Bucket;
|
|
3
|
+
WEBSITE_BUCKET?: R2Bucket;
|
|
3
4
|
}
|
packages/workers/assets/src/index.ts
CHANGED
|
@@ -975,13 +975,24 @@ section {
|
|
|
975
975
|
}`, type: "text/css" },};
|
|
976
976
|
|
|
977
977
|
export default {
|
|
978
|
-
async fetch(request: Request): Promise<Response> {
|
|
978
|
+
async fetch(request: Request, env: { WEBSITE_BUCKET?: R2Bucket }): Promise<Response> {
|
|
979
979
|
const url = new URL(request.url);
|
|
980
980
|
const key = url.pathname.replace("/assets/", "");
|
|
981
981
|
const asset = ASSETS[key];
|
|
982
|
-
if (
|
|
982
|
+
if (asset) {
|
|
983
|
-
|
|
983
|
+
return new Response(asset.data, {
|
|
984
|
-
|
|
984
|
+
headers: { "content-type": asset.type, "cache-control": "public, max-age=3600" },
|
|
985
|
-
|
|
985
|
+
});
|
|
986
|
+
}
|
|
987
|
+
if (env.WEBSITE_BUCKET) {
|
|
988
|
+
const obj = await env.WEBSITE_BUCKET.get(key);
|
|
989
|
+
if (obj) {
|
|
990
|
+
const headers = new Headers();
|
|
991
|
+
obj.writeHttpMetadata(headers);
|
|
992
|
+
headers.set("cache-control", "public, max-age=3600");
|
|
993
|
+
return new Response(obj.body, { headers });
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
return new Response("Not found", { status: 404 });
|
|
986
997
|
},
|
|
987
998
|
};
|
packages/workers/assets/wrangler.jsonc
CHANGED
|
@@ -4,5 +4,6 @@
|
|
|
4
4
|
"compatibility_date": "2026-07-07",
|
|
5
5
|
"compatibility_flags": ["nodejs_compat"],
|
|
6
6
|
"workers_dev": false,
|
|
7
|
-
"routes": [{ "pattern": "pyrossh.dev/assets/*", "custom_domain": true }]
|
|
7
|
+
"routes": [{ "pattern": "pyrossh.dev/assets/*", "custom_domain": true }],
|
|
8
|
+
"r2_buckets": [{ "binding": "WEBSITE_BUCKET", "bucket_name": "pyrossh-website-prd" }]
|
|
8
9
|
}
|
packages/workers/dev-router/src/index.ts
CHANGED
|
@@ -55,7 +55,7 @@ export default {
|
|
|
55
55
|
const url = new URL(request.url);
|
|
56
56
|
|
|
57
57
|
if (/^\/assets\//.test(url.pathname)) {
|
|
58
|
-
return await assetsWorker.fetch(request);
|
|
58
|
+
return await assetsWorker.fetch(request, env);
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
for (const route of routes) {
|
packages/workers/dev-router/wrangler.jsonc
CHANGED
|
@@ -4,5 +4,8 @@
|
|
|
4
4
|
"compatibility_date": "2026-07-07",
|
|
5
5
|
"compatibility_flags": ["nodejs_compat"],
|
|
6
6
|
"workers_dev": true,
|
|
7
|
+
"r2_buckets": [
|
|
7
|
-
|
|
8
|
+
{ "binding": "REPOS", "bucket_name": "pyrossh-repos-prd" },
|
|
9
|
+
{ "binding": "WEBSITE_BUCKET", "bucket_name": "pyrossh-website-prd" }
|
|
10
|
+
]
|
|
8
11
|
}
|
scripts/deploy-all.sh
CHANGED
|
@@ -2,15 +2,13 @@
|
|
|
2
2
|
set -euo pipefail
|
|
3
3
|
|
|
4
4
|
echo "=== Step 1: Upload blog content to R2 ==="
|
|
5
|
-
|
|
5
|
+
rclone sync content/ r2_website_bucket:pyrossh-website-prd/content/
|
|
6
|
-
if [ -f "$file" ]; then
|
|
7
|
-
|
|
6
|
+
rclone sync content/ r2:pyrossh-repos-prd/content/
|
|
8
|
-
|
|
7
|
+
echo " Content synced."
|
|
9
|
-
fi
|
|
10
|
-
done
|
|
11
8
|
|
|
12
9
|
echo ""
|
|
13
10
|
echo "=== Step 2: Upload assets to R2 ==="
|
|
11
|
+
rclone sync assets/ r2_website_bucket:pyrossh-website-prd/assets/ --progress
|
|
14
12
|
rclone sync assets/ r2:pyrossh-repos-prd/assets/ --progress
|
|
15
13
|
echo " Assets synced."
|
|
16
14
|
|
src/lib/gitBug.ts
CHANGED
|
@@ -1,30 +1,5 @@
|
|
|
1
1
|
import { S3mini } from 's3mini'
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import type { GitBugIssue, GitBugComment, GitBugIssueState, GitBugIssuesResult } from '../types'
|
|
4
|
-
|
|
5
|
-
export interface GitBugIssue {
|
|
6
|
-
id: string;
|
|
7
|
-
title: string;
|
|
8
|
-
state: GitBugIssueState;
|
|
9
|
-
author?: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
updatedAt: string;
|
|
12
|
-
labels: string[];
|
|
13
|
-
body?: string;
|
|
14
|
-
comments: GitBugComment[];
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export interface GitBugComment {
|
|
18
|
-
id: string;
|
|
19
|
-
author?: string;
|
|
20
|
-
createdAt: string;
|
|
21
|
-
body: string;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface GitBugIssuesResult {
|
|
25
|
-
issues: GitBugIssue[];
|
|
26
|
-
isAvailable: boolean;
|
|
27
|
-
}
|
|
28
3
|
|
|
29
4
|
const safeRepoId = (repoId: string) => {
|
|
30
5
|
if (!/^[a-zA-Z0-9._-]+$/.test(repoId)) {
|
worker-configuration.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
// Runtime types generated with [email protected] 2026-06-25 nodejs_compat
|
|
4
4
|
interface __BaseEnv_Env {
|
|
5
5
|
REPOS: R2Bucket;
|
|
6
|
+
WEBSITE_BUCKET: R2Bucket;
|
|
6
7
|
ASSETS: Fetcher;
|
|
7
8
|
DATABASE_URL: string;
|
|
8
9
|
DATABASE_PASSWORD: string;
|