Skip to content
This repository was archived by the owner on Mar 13, 2025. It is now read-only.

Commit 7ef1635

Browse files
admahmrbbot
andauthored
Docs: update docs to represent v3 (#733)
* docs: remove cli config. remove refs to mf cli. remove pages related to wrangler 1. other cleanup. * remove options not in v3. add initial queues page commit. * update cron, queues, fetch docs. remove docs for other methods not in v3. * update examples * remove references to redis package. update fetch mock imports. * cleanup scheduled example and queues example. * update get started examples. update fetcher const to worker. * remove cli option from config tabs. update fetch doc. * update line mubers for highlighting. update queues consumer doc. * update docs per github comments * Update docs/src/content/core/queues.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/core/queues.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/core/queues.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/core/queues.md Co-authored-by: MrBBot <[email protected]> * update etWorker to dispatchFetch where appropriate. update config tabs usage. * add d1 doc to storage. remove persistence mentions. * Update docs/src/content/core/multiple-workers.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/core/scheduled.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * Update docs/src/content/get-started/index.md Co-authored-by: MrBBot <[email protected]> * remove extra options from cert options --------- Co-authored-by: MrBBot <[email protected]>
1 parent 9ce24ed commit 7ef1635

37 files changed

+802
-3518
lines changed

docs/index.md

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,6 @@ title: Home
44

55
# 🔥 Miniflare
66

7-
<!--prettier-ignore-start-->
8-
:::warning
9-
⚠️ These docs are for the next major version of Miniflare, which is
10-
under development. They're very likely incorrect and incomplete.
11-
:::
12-
<!--prettier-ignore-end-->
13-
147
**Miniflare** is a simulator for developing and testing
158
[**Cloudflare Workers**](https://workers.cloudflare.com/).
169

@@ -21,7 +14,7 @@ under development. They're very likely incorrect and incomplete.
2114
-**Fully-local:** test and develop Workers without an internet connection.
2215
Reload code on change quickly.
2316

24-
It's an alternative to `wrangler dev`, written in TypeScript, that runs your
17+
It's written in TypeScript, and runs your
2518
workers in a sandbox implementing Workers' runtime APIs.
2619

2720
These docs primarily cover Miniflare specific things. For more information on
@@ -31,4 +24,4 @@ runtime APIs, refer to the
3124
If you find something that doesn't behave as it does in the real Workers
3225
environment (and this difference isn't documented), or something's wrong in
3326
these docs, please
34-
[open a GitHub issue](https://github.com/cloudflare/miniflare/issues/new/choose).
27+
[open a GitHub issue](https://github.com/cloudflare/workers-sdk/issues/new/choose).

docs/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@
99
"ghactionsbootstrap": "node_modules/cloudflare-docs-engine/bin/commands.sh ghactionsbootstrap",
1010
"savechanges": "node_modules/cloudflare-docs-engine/bin/commands.sh savechanges",
1111
"serve": "node_modules/cloudflare-docs-engine/bin/commands.sh serve",
12-
1312
"docs:reset": "rimraf ./.docs/src/content && node ./changelog.mjs",
1413
"docs:build": "npm run docs:reset && npm run build && cp ./_redirects ./.docs/public/",
1514
"docs:dev": "npm run docs:reset && concurrently \"npm:develop\" \"node watch.mjs\" -n dev,wat -c magenta,gray -k",
16-
1715
"pages:build": "npm run ghactionsbootstrap && npm run docs:build"
1816
},
1917
"devDependencies": {

docs/src/content/components/mdx/config-tabs.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import Helmet from "react-helmet";
55

66
import getUniqueReadableID from "../../../utils/get-unique-readable-id";
77
import IconAPI from "../icons/api";
8-
import IconCLI from "../icons/cli";
98
import IconWrangler from "../icons/wrangler";
109

1110
// Page/storage synchronisation adapted from components/theme-toggle.js
1211

1312
const TABS = [
14-
{ id: "cli", name: "CLI", Icon: IconCLI },
1513
{ id: "wrangler", name: "wrangler.toml", Icon: IconWrangler, mono: true },
1614
{ id: "api", name: "JavaScript API", Icon: IconAPI },
1715
];

docs/src/content/core/compatibility.md

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,17 @@ default to some time far in the past.
1414

1515
import ConfigTabs from "../components/mdx/config-tabs";
1616

17-
<ConfigTabs>
18-
19-
```sh
20-
$ miniflare --compat-date 2021-11-12
21-
```
22-
23-
```toml
24-
---
25-
filename: wrangler.toml
26-
---
27-
compatibility_date = "2021-11-12"
28-
```
29-
3017
```js
3118
const mf = new Miniflare({
3219
compatibilityDate: "2021-11-12",
3320
});
3421
```
3522

36-
</ConfigTabs>
37-
3823
## Compatibility Flags
3924

4025
Miniflare also lets you opt-in/out of specific changes using compatibility
4126
flags:
4227

43-
<ConfigTabs>
44-
45-
```sh
46-
$ miniflare --compat-flag formdata_parser_supports_files --compat-flag durable_object_fetch_allows_relative_url
47-
```
48-
49-
```toml
50-
---
51-
filename: wrangler.toml
52-
---
53-
compatibility_flags = [
54-
"formdata_parser_supports_files",
55-
"durable_object_fetch_allows_relative_url"
56-
]
57-
```
58-
5928
```js
6029
const mf = new Miniflare({
6130
compatibilityFlags: [
@@ -65,8 +34,6 @@ const mf = new Miniflare({
6534
});
6635
```
6736

68-
</ConfigTabs>
69-
7037
Specifically Miniflare supports the following flags:
7138

7239
- `nodejs_compat` (specifically the `node:assert`, `node:async_hooks`,

docs/src/content/core/fetch.md

Lines changed: 16 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@ order: 0
1010

1111
## HTTP Requests
1212

13-
When using the CLI, an HTTP server is automatically started. Whenever an HTTP
14-
request is made, it is converted to a workers-compatible `Request` object,
15-
dispatched to your worker, then the generated `Response` is returned. The
16-
`Request` object will include
17-
[`CF-*` headers](https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-)
18-
and a
13+
Whenever an HTTP request is made, a `Request` object is dispatched to your worker, then the generated `Response` is returned. The
14+
`Request` object will include a
1915
[`cf` object](https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties).
20-
Miniflare will log the method, path, status, the time it took to respond, and
21-
the time taken for all `waitUntil` promises to resolve.
16+
Miniflare will log the method, path, status, and the time it took to respond.
2217

2318
If the worker throws an error whilst generating a response, an error page
2419
containing the stack trace is returned instead. You can use
@@ -36,16 +31,19 @@ object, or a URL and optional `RequestInit` object:
3631
import { Miniflare, Request } from "miniflare";
3732

3833
const mf = new Miniflare({
34+
modules: true,
3935
script: `
40-
addEventListener("fetch", (event) => {
41-
const body = JSON.stringify({
42-
url: event.request.url,
43-
header: event.request.headers.get("X-Message"),
44-
});
45-
event.respondWith(new Response(body, {
46-
headers: { "Content-Type": "application/json" },
47-
}));
48-
});
36+
export default {
37+
async fetch(request, env, ctx) {
38+
const body = JSON.stringify({
39+
url: event.request.url,
40+
header: event.request.headers.get("X-Message"),
41+
});
42+
return new Response(body, {
43+
headers: { "Content-Type": "application/json" },
44+
});
45+
})
46+
}
4947
`,
5048
});
5149

@@ -65,28 +63,7 @@ res = await mf.dispatchFetch(
6563
console.log(await res.json()); // { url: "http://localhost:8787/2", header: "2" }
6664
```
6765

68-
You can use the `waitUntil` method of `Response` to get the data returned by all
69-
waited promises:
70-
71-
```js
72-
import { Miniflare } from "miniflare";
73-
74-
const mf = new Miniflare({
75-
script: `
76-
addEventListener("fetch", (event) => {
77-
event.waitUntil(Promise.resolve(1));
78-
event.waitUntil(Promise.resolve("2"));
79-
event.respondWith(new Response());
80-
});
81-
`,
82-
});
83-
const res = await mf.dispatchFetch("http://localhost:8787/");
84-
const waitUntil = await res.waitUntil();
85-
console.log(waitUntil[0]); // 1
86-
console.log(waitUntil[1]); // "2"
87-
```
88-
89-
When using the API to dispatch events, you are responsible for adding
66+
When dispatching events, you are responsible for adding
9067
[`CF-*` headers](https://support.cloudflare.com/hc/en-us/articles/200170986-How-does-Cloudflare-handle-HTTP-Request-headers-)
9168
and the
9269
[`cf` object](https://developers.cloudflare.com/workers/runtime-apis/request#incomingrequestcfproperties).
@@ -110,22 +87,6 @@ response is returned, or an exception is thrown and `passThroughOnException()`
11087
has been called, the response will be fetched from the specified upstream
11188
instead:
11289

113-
import ConfigTabs from "../components/mdx/config-tabs";
114-
115-
<ConfigTabs>
116-
117-
```sh
118-
$ miniflare --upstream https://miniflare.dev # or -u
119-
```
120-
121-
```toml
122-
---
123-
filename: wrangler.toml
124-
---
125-
[miniflare]
126-
upstream = "https://miniflare.dev"
127-
```
128-
12990
```js
13091
import { Miniflare } from "miniflare";
13192

@@ -143,5 +104,3 @@ const mf = new Miniflare({
143104
const res = await mf.dispatchFetch("https://miniflare.dev/core/fetch");
144105
console.log(await res.text()); // Source code of this page
145106
```
146-
147-
</ConfigTabs>

docs/src/content/core/modules.md

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,33 +11,12 @@ order: 3
1111
Miniflare supports both the traditional `service-worker` and newer `modules`
1212
formats for writing workers. To use the `modules` format, enable it with:
1313

14-
import ConfigTabs from "../components/mdx/config-tabs";
15-
16-
<ConfigTabs>
17-
18-
```sh
19-
$ miniflare --modules # or -m
20-
```
21-
22-
```toml
23-
---
24-
filename: wrangler.toml
25-
---
26-
[build.upload]
27-
format = "modules"
28-
```
29-
3014
```js
3115
const mf = new Miniflare({
3216
modules: true,
3317
});
3418
```
3519

36-
</ConfigTabs>
37-
38-
When using the API you must also pass the **`--experimental-vm-modules`** flag
39-
to Node.js. This is added automatically when using the CLI.
40-
4120
You can now use `modules` worker scripts like the following:
4221

4322
```js
@@ -59,7 +38,7 @@ export default {
5938

6039
<Aside type="warning" header="Warning">
6140

62-
When using the API, string scripts via the `script` option are supported using
41+
String scripts via the `script` option are supported using
6342
the `modules` format, but you cannot import other modules using them. You must
6443
use a script file via the `scriptPath` option for this.
6544

@@ -70,25 +49,6 @@ use a script file via the `scriptPath` option for this.
7049
Miniflare supports all module types: `ESModule`, `CommonJS`, `Text`, `Data` and
7150
`CompiledWasm`. You can specify additional module resolution rules as follows:
7251

73-
<ConfigTabs>
74-
75-
```sh
76-
# Note all rules implicitly have the `fallthrough` option set to true
77-
$ miniflare --modules-rule "ESModule=**/*.js" --modules-rule "Text=**/*.txt"
78-
```
79-
80-
```toml
81-
---
82-
filename: wrangler.toml
83-
---
84-
[[build.upload.rules]]
85-
type = "ESModule"
86-
globs = ["**/*.js"]
87-
[[build.upload.rules]]
88-
type = "Text"
89-
globs = ["**/*.txt"]
90-
```
91-
9252
```js
9353
const mf = new Miniflare({
9454
modulesRules: [
@@ -98,8 +58,6 @@ const mf = new Miniflare({
9858
});
9959
```
10060

101-
</ConfigTabs>
102-
10361
### Default Rules
10462

10563
The following rules are automatically added to the end of your modules rules

0 commit comments

Comments
 (0)