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,32 @@
import type { PluginArgs } from "..";
type ExamplePagesPluginFunction<
Env = unknown,
// eslint-disable-next-line @typescript-eslint/no-explicit-any
Params extends string = any,
Data extends Record<string, unknown> = Record<string, unknown>,
> = PagesPluginFunction<Env, Params, Data, PluginArgs>;
class BodyHandler {
footerText: string;
constructor({ footerText }) {
this.footerText = footerText;
}
element(element) {
// Don't actually set HTML like this!
element.append(`<footer>${this.footerText}</footer>`, { html: true });
}
}
export const onRequest: ExamplePagesPluginFunction = async ({
next,
pluginArgs,
}) => {
const response = await next();
return new HTMLRewriter()
.on("body", new BodyHandler({ footerText: pluginArgs.footerText }))
.transform(response);
};
@@ -0,0 +1 @@
export const onRequest = () => new Response("Response from a nested folder");
@@ -0,0 +1,5 @@
import isOdd from "is-odd";
export const onRequest: PagesFunction = () => {
return new Response(`42 is ${isOdd(42) ? "odd" : "even"}`);
};
@@ -0,0 +1,3 @@
export const onRequest: PagesFunction = () => {
return new Response("I'm a fixed response");
};
@@ -0,0 +1 @@
export const onRequest = ({ next }) => next("/here");
@@ -0,0 +1 @@
export { onRequest } from "assets:../../public";
@@ -0,0 +1,3 @@
export const onRequest = () => {
return new Response("This should return a 502 status code", { status: 502 });
};