# @d1testflare/core

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

Latest version **2.9.0** (published 2022-10-04) · MIT license · 0 weekly downloads

## Install

```sh
npm install @d1testflare/core
pnpm add @d1testflare/core
yarn add @d1testflare/core
bun add @d1testflare/core
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.9.0 |
| Published | 2022-10-04 |
| First published | 2022-08-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.13 |
| Dependencies | 10 |
| Unpacked size | 202.5 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3922 |
| Author | MrBBot |
| Maintainers | oconnorct1 |
| Keywords | cloudflare, workers, worker, local, cloudworker |

## Links

- npm: https://www.npmjs.com/package/@d1testflare/core
- Repository: https://github.com/cloudflare/miniflare
- Homepage: https://github.com/cloudflare/miniflare/tree/master/packages/core#readme
- Issues: https://github.com/cloudflare/miniflare/issues
- npm.io page: https://npm.io/package/@d1testflare/core

## Dependencies (10)

- [kleur](https://npm.io/package/kleur.md) ^4.1.4
- [busboy](https://npm.io/package/busboy.md) ^1.6.0
- [dotenv](https://npm.io/package/dotenv.md) ^10.0.0
- [undici](https://npm.io/package/undici.md) 5.9.1
- [@iarna/toml](https://npm.io/package/@iarna/toml.md) ^2.2.5
- [set-cookie-parser](https://npm.io/package/set-cookie-parser.md) ^2.4.8
- [@d1testflare/queues](https://npm.io/package/@d1testflare/queues.md) 2.9.0
- [@d1testflare/shared](https://npm.io/package/@d1testflare/shared.md) 2.9.0
- [urlpattern-polyfill](https://npm.io/package/urlpattern-polyfill.md) ^4.0.3
- [@d1testflare/watcher](https://npm.io/package/@d1testflare/watcher.md) 2.9.0

## Alternatives

- [cron](https://npm.io/package/cron.md) — 4.9M weekly downloads
- [@vercel/queue](https://npm.io/package/@vercel/queue.md) — 731.6K weekly downloads
- [create-sonicjs](https://npm.io/package/create-sonicjs.md) — 1.6K weekly downloads
- [@exellix/jobs-api](https://npm.io/package/@exellix/jobs-api.md) — 941 weekly downloads
- [@forwardimpact/libskill](https://npm.io/package/@forwardimpact/libskill.md) — 575 weekly downloads

## Recent versions

- 2.9.0 (latest) — 2022-10-04
- 2.7.1 — 2022-08-30

## README

# `@d1testflare/core`

Core module for [Miniflare](https://github.com/cloudflare/miniflare): a fun,
full-featured, fully-local simulator for Cloudflare Workers. See
[🧰 Using the API](https://miniflare.dev/get-started/api) for more details.

## Example

```js
import { CorePlugin, MiniflareCore } from "@d1testflare/core";
import { KVPlugin } from "@d1testflare/kv";
import { VMScriptRunner } from "@d1testflare/runner-vm";
import { Log, LogLevel } from "@d1testflare/shared";
import { MemoryStorage } from "@d1testflare/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
```

---
_Source: https://npm.io/package/@d1testflare/core · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
