Initial commit (by create-cloudflare CLI)

This commit is contained in:
J-onasJones 2023-09-14 18:58:13 +02:00
commit 58a42872a0
1745 changed files with 741893 additions and 0 deletions

View file

@ -0,0 +1,15 @@
import type { Middleware } from "./common";
// A middleware has to be a function of type Middleware
const scheduled: Middleware = async (request, env, _ctx, middlewareCtx) => {
const url = new URL(request.url);
if (url.pathname === "/__scheduled") {
const cron = url.searchParams.get("cron") ?? "";
await middlewareCtx.dispatch("scheduled", { cron });
return new Response("Ran scheduled event");
}
return middlewareCtx.next(request, env);
};
export default scheduled;