chore: import upstream snapshot with attribution
Deploy (to testing) and Test Playground Preview Worker / Deploy Playground Preview Worker (testing) (push) Has been skipped
Deploy Workers Shared Staging / Deploy Workers Shared Staging (push) Failing after 0s
Prerelease / build (push) Has been skipped
Handle Changesets / Handle Changesets (push) Has been cancelled
Semgrep OSS scan / semgrep-oss (push) Has been cancelled

This commit is contained in:
wehub-resource-sync
2026-07-13 12:30:11 +08:00
commit 70bf21e064
5213 changed files with 731895 additions and 0 deletions
@@ -0,0 +1,42 @@
/**
* Web Worker: renders user profiles and reports by calling the API Worker over a service binding.
*/
export default {
async fetch(request, env) {
const url = new URL(request.url);
if (url.pathname === "/") {
return new Response("Hello World");
}
const userPathPrefix = "/users/";
if (url.pathname.startsWith(userPathPrefix)) {
const userId = url.pathname.slice(userPathPrefix.length);
const { name } = await env.API.getUser(userId);
return new Response(`Profile: ${name}`);
}
const reportsPathPrefix = "/reports/";
if (url.pathname.startsWith(reportsPathPrefix)) {
const date = url.pathname.slice(reportsPathPrefix.length).slice(0, 10); // YYYY-MM-DD
const report = await env.API.getDailyReport(date);
if (report === null) {
return new Response("No report", { status: 404 });
}
if (url.pathname.endsWith(".png")) {
return env.BROWSER.quickAction("screenshot", {
html: `<h1>Daily report (${date}): active users ${report.join(", ")}</h1>`,
viewport: { width: 600, height: 200 },
});
}
return new Response(
`Daily report (${date}): active users ${report.join(", ")}`
);
}
return new Response("Not Found", { status: 404 });
},
} satisfies ExportedHandler<WebEnv>;
@@ -0,0 +1,13 @@
/* eslint-disable */
// Generated by Wrangler by running `wrangler types --config=./workers/web/wrangler.jsonc --config=./workers/api/wrangler.jsonc --include-runtime=false --env-interface=WebEnv ./workers/web/worker-configuration.d.ts` (hash: ba220acc5e7d9da5ae68234db2179e34)
interface __BaseEnv_WebEnv {
BROWSER: BrowserRun;
API: Service<typeof import("../api/index").default>;
}
declare namespace Cloudflare {
interface GlobalProps {
mainModule: typeof import("./index");
}
interface Env extends __BaseEnv_WebEnv {}
}
interface WebEnv extends __BaseEnv_WebEnv {}
@@ -0,0 +1,8 @@
{
"name": "web-worker",
"main": "index.ts",
"compatibility_date": "2026-06-01",
"routes": ["example.com/*"],
"browser": { "binding": "BROWSER" },
"services": [{ "binding": "API", "service": "api-worker" }],
}