Initial commit (by create-cloudflare CLI)

This commit is contained in:
Jonas_Jones 2023-09-12 00:20:38 +02:00
parent 8cb86120f1
commit fff961078a
1777 changed files with 1011798 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;