Noisy Pillaging Monster

    @miniflare/scheduler
    TypeScript icon, indicating that this package has built-in type declarations

    2.4.0 • Public • Published

    @miniflare/scheduler

    Scheduler module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers. See Scheduled Events for more details.

    Example

    import { CorePlugin, MiniflareCore } from "@miniflare/core";
    import { VMScriptRunner } from "@miniflare/runner-vm";
    import { Log, LogLevel } from "@miniflare/shared";
    import { SchedulerPlugin, startScheduler } from "@miniflare/scheduler";
    import { MemoryStorage } from "@miniflare/storage-memory";
    
    export class BadStorageFactory {
      storage() {
        throw new Error("This example shouldn't need storage!");
      }
    }
    const plugins = { CorePlugin, SchedulerPlugin };
    const ctx = {
      log: new Log(LogLevel.INFO),
      storageFactory: new BadStorageFactory(),
      scriptRunner: new VMScriptRunner(),
    };
    
    const mf = new MiniflareCore(plugins, ctx, {
      modules: true,
      script: `export default {
        async scheduled(request, env) {
          console.log("tick");
        }
      }`,
      crons: ["* * * * *"],
    });
    
    const scheduler = await startScheduler(mf); // tick, tick, tick, ...
    scheduler.dispose();

    Install

    npm i @miniflare/scheduler

    DownloadsWeekly Downloads

    17,565

    Version

    2.4.0

    License

    MIT

    Unpacked Size

    11.1 kB

    Total Files

    5

    Last publish

    Collaborators

    • mrbbot