website
git clone https://git.pyrossh.dev/website
木 Personal website of pyrossh. Built with astrojs, shiki, vite.
1e1dc9d
— pyrossh
2026-07-07T12:19:44+05:30
feat: add dev router worker
Generated files not shown: pnpm-lock.yaml
packages/workers/dev-router/package.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pyrossh/dev-router",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"private": true,
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "src/index.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"@pyrossh/assets": "workspace:*",
|
|
9
|
+
"@pyrossh/cv": "workspace:*",
|
|
10
|
+
"@pyrossh/home": "workspace:*",
|
|
11
|
+
"@pyrossh/not-found": "workspace:*",
|
|
12
|
+
"@pyrossh/only-bible-app-index": "workspace:*",
|
|
13
|
+
"@pyrossh/only-bible-app-privacy": "workspace:*",
|
|
14
|
+
"@pyrossh/only-bible-app-terms": "workspace:*",
|
|
15
|
+
"@pyrossh/posts": "workspace:*",
|
|
16
|
+
"@pyrossh/posts-detail": "workspace:*",
|
|
17
|
+
"@pyrossh/repos-commits-detail": "workspace:*",
|
|
18
|
+
"@pyrossh/repos-commits-index": "workspace:*",
|
|
19
|
+
"@pyrossh/repos-files-blame": "workspace:*",
|
|
20
|
+
"@pyrossh/repos-files-detail": "workspace:*",
|
|
21
|
+
"@pyrossh/repos-files-history": "workspace:*",
|
|
22
|
+
"@pyrossh/repos-files-index": "workspace:*",
|
|
23
|
+
"@pyrossh/repos-issues-detail": "workspace:*",
|
|
24
|
+
"@pyrossh/repos-issues-index": "workspace:*",
|
|
25
|
+
"@pyrossh/repos-readme": "workspace:*",
|
|
26
|
+
"@pyrossh/robots": "workspace:*",
|
|
27
|
+
"@pyrossh/rss": "workspace:*",
|
|
28
|
+
"@pyrossh/server-error": "workspace:*"
|
|
29
|
+
}
|
|
30
|
+
}
|
packages/workers/dev-router/src/index.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import home from "@pyrossh/home";
|
|
2
|
+
import cv from "@pyrossh/cv";
|
|
3
|
+
import blogList from "@pyrossh/posts";
|
|
4
|
+
import blogDetail from "@pyrossh/posts-detail";
|
|
5
|
+
import repoReadme from "@pyrossh/repos-readme";
|
|
6
|
+
import repoCommits from "@pyrossh/repos-commits-index";
|
|
7
|
+
import repoCommitDetail from "@pyrossh/repos-commits-detail";
|
|
8
|
+
import repoFiles from "@pyrossh/repos-files-index";
|
|
9
|
+
import repoFileDetail from "@pyrossh/repos-files-detail";
|
|
10
|
+
import repoFileHistory from "@pyrossh/repos-files-history";
|
|
11
|
+
import repoFileBlame from "@pyrossh/repos-files-blame";
|
|
12
|
+
import repoIssues from "@pyrossh/repos-issues-index";
|
|
13
|
+
import repoIssueDetail from "@pyrossh/repos-issues-detail";
|
|
14
|
+
import onlyBible from "@pyrossh/only-bible-app-index";
|
|
15
|
+
import onlyBiblePrivacy from "@pyrossh/only-bible-app-privacy";
|
|
16
|
+
import onlyBibleTerms from "@pyrossh/only-bible-app-terms";
|
|
17
|
+
import assetsWorker from "@pyrossh/assets";
|
|
18
|
+
import robots from "@pyrossh/robots";
|
|
19
|
+
import rss from "@pyrossh/rss";
|
|
20
|
+
import notFound from "@pyrossh/not-found";
|
|
21
|
+
import serverError from "@pyrossh/server-error";
|
|
22
|
+
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
type WorkerModule = { fetch: (...args: any[]) => Promise<Response> };
|
|
25
|
+
|
|
26
|
+
interface Route {
|
|
27
|
+
pattern: RegExp;
|
|
28
|
+
worker: WorkerModule;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const routes: Route[] = [
|
|
32
|
+
{ pattern: /^\/robots\.txt$/, worker: robots },
|
|
33
|
+
{ pattern: /^\/rss\.xml$/, worker: rss },
|
|
34
|
+
{ pattern: /^\/$/, worker: home },
|
|
35
|
+
{ pattern: /^\/cv$/, worker: cv },
|
|
36
|
+
{ pattern: /^\/posts\/(.+)$/, worker: blogDetail },
|
|
37
|
+
{ pattern: /^\/posts$/, worker: blogList },
|
|
38
|
+
{ pattern: /^\/repos\/[^/]+\/issues\/[^/]+$/, worker: repoIssueDetail },
|
|
39
|
+
{ pattern: /^\/repos\/[^/]+\/issues$/, worker: repoIssues },
|
|
40
|
+
{ pattern: /^\/repos\/[^/]+\/commits\/[^/]+$/, worker: repoCommitDetail },
|
|
41
|
+
{ pattern: /^\/repos\/[^/]+\/commits$/, worker: repoCommits },
|
|
42
|
+
{ pattern: /^\/repos\/[^/]+\/files\/.+\/history$/, worker: repoFileHistory },
|
|
43
|
+
{ pattern: /^\/repos\/[^/]+\/files\/.+\/blame$/, worker: repoFileBlame },
|
|
44
|
+
{ pattern: /^\/repos\/[^/]+\/files\/.+$/, worker: repoFileDetail },
|
|
45
|
+
{ pattern: /^\/repos\/[^/]+\/files$/, worker: repoFiles },
|
|
46
|
+
{ pattern: /^\/repos\/.+$/, worker: repoReadme },
|
|
47
|
+
{ pattern: /^\/only-bible-app\/privacy-policy$/, worker: onlyBiblePrivacy },
|
|
48
|
+
{ pattern: /^\/only-bible-app\/terms-and-conditions$/, worker: onlyBibleTerms },
|
|
49
|
+
{ pattern: /^\/only-bible-app/, worker: onlyBible },
|
|
50
|
+
{ pattern: /^\/assets\/.+$/, worker: assetsWorker },
|
|
51
|
+
];
|
|
52
|
+
|
|
53
|
+
export default {
|
|
54
|
+
async fetch(request: Request, env: unknown, ctx: ExecutionContext): Promise<Response> {
|
|
55
|
+
const url = new URL(request.url);
|
|
56
|
+
for (const route of routes) {
|
|
57
|
+
if (route.pattern.test(url.pathname)) {
|
|
58
|
+
try {
|
|
59
|
+
return await route.worker.fetch(request, env, ctx);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error("dev-router error:", err);
|
|
62
|
+
return await serverError.fetch(request);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return await notFound.fetch(request);
|
|
67
|
+
},
|
|
68
|
+
};
|
packages/workers/dev-router/tsconfig.json
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
{
|
|
2
|
+
"extends": "../../../tsconfig.base.json",
|
|
3
|
+
"include": ["src"]
|
|
4
|
+
}
|
packages/workers/dev-router/wrangler.jsonc
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "pyrossh-dev",
|
|
3
|
+
"main": "src/index.ts",
|
|
4
|
+
"compatibility_date": "2026-07-07",
|
|
5
|
+
"compatibility_flags": ["nodejs_compat"],
|
|
6
|
+
"workers_dev": true,
|
|
7
|
+
"r2_buckets": [{ "binding": "REPOS", "bucket_name": "pyrossh-repos-prd" }],
|
|
8
|
+
}
|