import app from "./app";
import { runGc } from "./gc";
import type { Env } from "./types";

export default {
  fetch: app.fetch,
  async scheduled(_controller, env, ctx) {
    ctx.waitUntil(
      runGc(env, new Date())
        .then((r) =>
          console.log(
            `gc: ${r.expiredSnapshots} snapshots expired, ${r.deletedBlobs} blobs deleted`,
          ),
        )
        .catch((err) => console.error("gc: run failed", err)),
    );
  },
} satisfies ExportedHandler<Env>;
