// Generated by bynkc — do not edit by hand.
// Worker entry point for context `metrics`.

import { Ok, Err, type Result, type JsonValue, type BoundaryError, boundaryError } from "../../runtime.js";
import { compose, type Env } from "./compose.js";
import * as handlers from "./handlers.js";

export default {
  async fetch(request: Request, env: Env): Promise<Response> {
    const url = new URL(request.url);
    const path = url.pathname;
    const method = request.method;
    const surface = compose(env);
    try {
      if (path.startsWith("/_bynk/call/")) {
        const servicePath = path.slice("/_bynk/call/".length);
        switch (servicePath) {
          default:
            return new Response("Not found", { status: 404 });
        }
      }

      return new Response("Not Found", { status: 404 });
    } catch {
      return new Response("Internal Server Error", { status: 500 });
    }
  },
  async scheduled(event: { readonly cron: string; readonly scheduledTime: number }, env: Env): Promise<void> {
    const surface = compose(env);
    switch (event.cron) {
      case "0 * * * *": {
        const result = await surface.cron_ticker_0();
        if (result.tag === "Err") console.error("cron 0 * * * * failed", result.error);
        return;
      }
      default:
        return;
    }
  },
};
