@miniflare/core

Core module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers

Miniflare v2 is no longer supported. Please upgrade to Miniflare v4
Last updated 4 years ago by mrbbot .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @miniflare/core 
SYNC missed versions from official npm registry.

@miniflare/core

Core module for Miniflare: a fun, full-featured, fully-local simulator for Cloudflare Workers. See 🧰 Using the API for more details.

Example

import { CorePlugin, MiniflareCore } from "@miniflare/core";
import { KVPlugin } from "@miniflare/kv";
import { VMScriptRunner } from "@miniflare/runner-vm";
import { Log, LogLevel } from "@miniflare/shared";
import { MemoryStorage } from "@miniflare/storage-memory";

export class StorageFactory {
  storages = new Map();

  storage(namespace) {
    let storage = this.storages.get(namespace);
    if (storage) return storage;
    this.storages.set(namespace, (storage = new MemoryStorage()));
    return storage;
  }
}

const plugins = { CorePlugin, KVPlugin };
const ctx = {
  log: new Log(LogLevel.INFO),
  storageFactory: new StorageFactory(),
  scriptRunner: new VMScriptRunner(),
};

const mf = new MiniflareCore(plugins, ctx, {
  modules: true,
  script: `export default {
    async fetch(request, env) {
      return new Response(await env.TEST_NAMESPACE.get("key"));
    }
  }`,
  kvNamespaces: ["TEST_NAMESPACE"],
});

const { TEST_NAMESPACE } = await mf.getBindings();
await TEST_NAMESPACE.put("key", "value");

const res = await mf.dispatchFetch("http://localhost");
console.log(await res.text()); // value

Current Tags

  • 2.8.2-d1.0                                ...           d1 (4 years ago)
  • 2.14.4                                ...           latest (2 years ago)
  • 2.14.1                                ...           latest-2 (3 years ago)
  • 2.0.0-rc.5                                ...           next (5 years ago)

39 Versions

  • 2.14.4 [deprecated]           ...           2 years ago
  • 2.14.2 [deprecated]           ...           3 years ago
  • 2.14.1 [deprecated]           ...           3 years ago
  • 2.14.0 [deprecated]           ...           4 years ago
  • 2.13.0 [deprecated]           ...           4 years ago
  • 2.12.2 [deprecated]           ...           4 years ago
  • 2.12.1 [deprecated]           ...           4 years ago
  • 2.12.0 [deprecated]           ...           4 years ago
  • 2.11.0 [deprecated]           ...           4 years ago
  • 2.10.0 [deprecated]           ...           4 years ago
  • 2.9.0 [deprecated]           ...           4 years ago
  • 2.8.2-d1.0 [deprecated]           ...           4 years ago
  • 2.8.2 [deprecated]           ...           4 years ago
  • 2.9.0-next.1 [deprecated]           ...           4 years ago
  • 2.8.1 [deprecated]           ...           4 years ago
  • 2.8.0 [deprecated]           ...           4 years ago
  • 2.7.1 [deprecated]           ...           4 years ago
  • 2.7.0 [deprecated]           ...           4 years ago
  • 2.6.0-d1.5 [deprecated]           ...           4 years ago
  • 2.6.0-d1.4 [deprecated]           ...           4 years ago
  • 2.6.0-d1.3 [deprecated]           ...           4 years ago
  • 2.6.0-d1.2 [deprecated]           ...           4 years ago
  • 2.6.0 [deprecated]           ...           4 years ago
  • 2.6.0-d1.1 [deprecated]           ...           4 years ago
  • 2.5.1 [deprecated]           ...           4 years ago
  • 2.5.0 [deprecated]           ...           4 years ago
  • 2.4.0 [deprecated]           ...           5 years ago
  • 2.3.0 [deprecated]           ...           5 years ago
  • 2.2.0 [deprecated]           ...           5 years ago
  • 2.1.0 [deprecated]           ...           5 years ago
  • 2.0.0 [deprecated]           ...           5 years ago
  • 2.0.0-rc.5 [deprecated]           ...           5 years ago
  • 2.0.0-rc.4 [deprecated]           ...           5 years ago
  • 2.0.0-rc.3 [deprecated]           ...           5 years ago
  • 2.0.0-rc.2 [deprecated]           ...           5 years ago
  • 2.0.0-rc.1 [deprecated]           ...           5 years ago
  • 2.0.0-next.3 [deprecated]           ...           5 years ago
  • 2.0.0-next.2 [deprecated]           ...           5 years ago
  • 2.0.0-next.1 [deprecated]           ...           5 years ago
Downloads
Total 93
Today 1
This Week 15
This Month 83
Last Day 1
Last Week 57
Last Month 4
Dependencies (10)

© 2010 - cnpmjs.org x YWFE | Home | YWFE