From 58f0dd666ff64f47de5fea87af875888f557750e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Somhairle=20MacLe=C3=B2id?= Date: Wed, 11 Dec 2024 18:19:27 +0000 Subject: [PATCH] Apply suggestions from code review Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com> --- src/content/docs/workers/miniflare/core/fetch.mdx | 4 ++-- .../docs/workers/miniflare/core/multiple-workers.md | 2 +- src/content/docs/workers/miniflare/core/queues.md | 2 +- src/content/docs/workers/miniflare/core/scheduled.md | 2 +- src/content/docs/workers/miniflare/core/standards.md | 2 +- .../docs/workers/miniflare/core/variables-secrets.md | 2 +- src/content/docs/workers/miniflare/core/web-sockets.md | 4 ++-- src/content/docs/workers/miniflare/developing/debugger.md | 4 ++-- .../docs/workers/miniflare/developing/live-reload.md | 2 +- src/content/docs/workers/miniflare/index.mdx | 4 ++-- src/content/docs/workers/miniflare/migrations/from-v2.mdx | 8 ++++---- src/content/docs/workers/miniflare/storage/cache.md | 2 +- src/content/docs/workers/miniflare/storage/d1.md | 2 +- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/content/docs/workers/miniflare/core/fetch.mdx b/src/content/docs/workers/miniflare/core/fetch.mdx index 46bbd6d077f9f1..c6edf4b6c90361 100644 --- a/src/content/docs/workers/miniflare/core/fetch.mdx +++ b/src/content/docs/workers/miniflare/core/fetch.mdx @@ -14,7 +14,7 @@ Whenever an HTTP request is made, a `Request` object is dispatched to your worke [`cf` object](/workers/runtime-apis/request#incomingrequestcfproperties). Miniflare will log the method, path, status, and the time it took to respond. -If the worker throws an error whilst generating a response, an error page +If the Worker throws an error whilst generating a response, an error page containing the stack trace is returned instead. You can use [🗺 Source Maps](/developing/source-maps) to make these point to your source files. @@ -22,7 +22,7 @@ files. ## Dispatching Events When using the API, the `dispatchFetch` function can be used to dispatch `fetch` -events to your worker. This can be used for testing responses. `dispatchFetch` +events to your Worker. This can be used for testing responses. `dispatchFetch` has the same API as the regular `fetch` method: it either takes a `Request` object, or a URL and optional `RequestInit` object: diff --git a/src/content/docs/workers/miniflare/core/multiple-workers.md b/src/content/docs/workers/miniflare/core/multiple-workers.md index a1a2cd1947a0fc..d53121ed36466d 100644 --- a/src/content/docs/workers/miniflare/core/multiple-workers.md +++ b/src/content/docs/workers/miniflare/core/multiple-workers.md @@ -107,7 +107,7 @@ $ curl "http://localhost:8787/todos/update/1" -H "Host: api.mf" ``` When using the API, Miniflare will use the request's URL to determine which -worker to dispatch to. +Worker to dispatch to. ```js // Dispatches to the "api" worker diff --git a/src/content/docs/workers/miniflare/core/queues.md b/src/content/docs/workers/miniflare/core/queues.md index 1f26b5d5b25f56..05a869e6154a62 100644 --- a/src/content/docs/workers/miniflare/core/queues.md +++ b/src/content/docs/workers/miniflare/core/queues.md @@ -3,7 +3,7 @@ order: 8 title: "🚥 Queues" --- -- [Queues Reference](https://developers.cloudflare.com/queues/) +- [Queues Reference](/queues/) ## Producers diff --git a/src/content/docs/workers/miniflare/core/scheduled.md b/src/content/docs/workers/miniflare/core/scheduled.md index 5557823efe963a..2d4fce45085567 100644 --- a/src/content/docs/workers/miniflare/core/scheduled.md +++ b/src/content/docs/workers/miniflare/core/scheduled.md @@ -37,7 +37,7 @@ $ curl "http://localhost:8787/cdn-cgi/mf/scheduled?cron=*+*+*+*+*" ## Dispatching Events When using the API, the `getWorker` function can be used to dispatch -`scheduled` events to your worker. This can be used for testing responses. It +`scheduled` events to your Worker. This can be used for testing responses. It takes optional `scheduledTime` and `cron` parameters, which default to the current time and the empty string respectively. It will return a promise which resolves to an array containing data returned by all waited promises: diff --git a/src/content/docs/workers/miniflare/core/standards.md b/src/content/docs/workers/miniflare/core/standards.md index c25ca7935899f3..5469d21497e7c5 100644 --- a/src/content/docs/workers/miniflare/core/standards.md +++ b/src/content/docs/workers/miniflare/core/standards.md @@ -17,7 +17,7 @@ title: "🕸 Web Standards" When using the API, Miniflare allows you to substitute custom `Response`s for `fetch()` calls using `undici`'s [`MockAgent` API](https://undici.nodejs.org/#/docs/api/MockAgent?id=mockagentgetorigin). -This is useful for testing workers that make HTTP requests to other services. To +This is useful for testing Workers that make HTTP requests to other services. To enable `fetch` mocking, create a [`MockAgent`](https://undici.nodejs.org/#/docs/api/MockAgent?id=mockagentgetorigin) using the `createFetchMock()` function, then set this using the `fetchMock` diff --git a/src/content/docs/workers/miniflare/core/variables-secrets.md b/src/content/docs/workers/miniflare/core/variables-secrets.md index bbd446a9d9df3d..b9a4ff947f96cb 100644 --- a/src/content/docs/workers/miniflare/core/variables-secrets.md +++ b/src/content/docs/workers/miniflare/core/variables-secrets.md @@ -30,4 +30,4 @@ const mf = new Miniflare({ ## Globals -Injecting arbitrary globals is not supported by [workerd](https://github.com/cloudflare/workerd). If you're using a service worker, bindings will be injected as globals, but these must be JSON-serialisable. +Injecting arbitrary globals is not supported by [workerd](https://github.com/cloudflare/workerd). If you're using a service Worker, bindings will be injected as globals, but these must be JSON-serialisable. diff --git a/src/content/docs/workers/miniflare/core/web-sockets.md b/src/content/docs/workers/miniflare/core/web-sockets.md index 453ceeeba44b14..f859f256bc894a 100644 --- a/src/content/docs/workers/miniflare/core/web-sockets.md +++ b/src/content/docs/workers/miniflare/core/web-sockets.md @@ -8,9 +8,9 @@ title: "✉️ WebSockets" ## Server -Miniflare will always upgrade Web Socket connections. The worker must respond +Miniflare will always upgrade Web Socket connections. The Worker must respond with a status `101 Switching Protocols` response including a `webSocket`. For -example, the worker below implements an echo WebSocket server: +example, the Worker below implements an echo WebSocket server: ```js export default { diff --git a/src/content/docs/workers/miniflare/developing/debugger.md b/src/content/docs/workers/miniflare/developing/debugger.md index b146a4614eccdb..aae650b0c1ed99 100644 --- a/src/content/docs/workers/miniflare/developing/debugger.md +++ b/src/content/docs/workers/miniflare/developing/debugger.md @@ -7,7 +7,7 @@ title: "🐛 Attaching a Debugger" This documentation describes breakpoint debugging when using Miniflare directly, which is only relevant for advanced use cases. Instead, most users should refer to the [Workers Observability documentation for how to set this up when using Wrangler](/workers/observability/dev-tools/breakpoints/). ::: -You can use regular Node.js tools to debug your workers. Setting breakpoints, +You can use regular Node.js tools to debug your Workers. Setting breakpoints, watching values and inspecting the call stack are all examples of things you can do with a debugger. @@ -63,5 +63,5 @@ debugging. ## DevTools Breakpoints can also be added via the Workers DevTools. For more information, -[read the guide](https://developers.cloudflare.com/workers/observability/local-development-and-testing/#devtools) +[read the guide](/workers/observability/local-development-and-testing/#devtools) in the Cloudflare Workers docs. diff --git a/src/content/docs/workers/miniflare/developing/live-reload.md b/src/content/docs/workers/miniflare/developing/live-reload.md index 9f9927759fbaef..b0bf504c3d73c9 100644 --- a/src/content/docs/workers/miniflare/developing/live-reload.md +++ b/src/content/docs/workers/miniflare/developing/live-reload.md @@ -3,7 +3,7 @@ order: 2 title: ⚡️ Live Reload --- -Miniflare automatically refreshes your browser when your worker script +Miniflare automatically refreshes your browser when your Worker script changes when `liveReload` is set to `true`. ```js diff --git a/src/content/docs/workers/miniflare/index.mdx b/src/content/docs/workers/miniflare/index.mdx index d1b605456350eb..7e08e664ce3111 100644 --- a/src/content/docs/workers/miniflare/index.mdx +++ b/src/content/docs/workers/miniflare/index.mdx @@ -18,11 +18,11 @@ This documentation describes the Miniflare API, which is only relevant for advan [**Cloudflare Workers**](https://workers.cloudflare.com/). It's written in TypeScript, and runs your code in a sandbox implementing Workers' runtime APIs. -- 🎉 **Fun:** develop workers easily with detailed logging, file watching and +- 🎉 **Fun:** develop Workers easily with detailed logging, file watching and pretty error pages supporting source maps. - 🔋 **Full-featured:** supports most Workers features, including KV, Durable Objects, WebSockets, modules and more. -- ⚡ **Fully-local:** test and develop Workers without an internet connection. +- ⚡ **Fully-local:** test and develop Workers without an Internet connection. Reload code on change quickly. diff --git a/src/content/docs/workers/miniflare/migrations/from-v2.mdx b/src/content/docs/workers/miniflare/migrations/from-v2.mdx index 876055de0367dd..3d008e462555a6 100644 --- a/src/content/docs/workers/miniflare/migrations/from-v2.mdx +++ b/src/content/docs/workers/miniflare/migrations/from-v2.mdx @@ -5,7 +5,7 @@ title: ⬆️Migrating from Version 2 Miniflare v3 now uses [`workerd`](https://github.com/cloudflare/workerd), the open-source Cloudflare Workers runtime. This is the same runtime that's deployed -on Cloudflare’s network, giving bug-for-bug compatibility and practically +on Cloudflare's network, giving bug-for-bug compatibility and practically eliminating behavior mismatches. Refer to the [Miniflare v3](https://blog.cloudflare.com/miniflare-and-workerd/) and [Wrangler v3 announcements](https://blog.cloudflare.com/wrangler3/) for more @@ -28,7 +28,7 @@ please open an issue on ## API Changes -We have tried to keep Miniflare v3’s API close to Miniflare v2 where possible, +We have tried to keep Miniflare v3's API close to Miniflare v2 where possible, but many options and methods have been removed or changed with the switch to the open-source `workerd` runtime. @@ -75,7 +75,7 @@ open-source `workerd` runtime. `scriptPath` option to specify your script instead. - `watch` - Miniflare's API is primarily intended for testing use cases, where file - watching isn't usually required. This option was here to enable Miniflare’s + watching isn't usually required. This option was here to enable Miniflare's CLI which has now been removed. If you need to watch files, consider using a separate file watcher like [`fs.watch()`](https://nodejs.org/api/fs.html#fswatchfilename-options-listener) @@ -108,7 +108,7 @@ open-source `workerd` runtime. const message = "The count is "; const mf = new Miniflare({ - // Options shared between workers such as HTTP and persistence configuration + // Options shared between Workers such as HTTP and persistence configuration // should always be defined at the top level. host: "0.0.0.0", port: 8787, diff --git a/src/content/docs/workers/miniflare/storage/cache.md b/src/content/docs/workers/miniflare/storage/cache.md index 728bcdbd4e1c22..747a88fd701547 100644 --- a/src/content/docs/workers/miniflare/storage/cache.md +++ b/src/content/docs/workers/miniflare/storage/cache.md @@ -41,7 +41,7 @@ const mf = new Miniflare({ ## Manipulating Outside Workers -For testing, it can be useful to put/match data from cache outside a worker. You +For testing, it can be useful to put/match data from cache outside a Worker. You can do this with the `getCaches` method: ```js {23,24,25,26,27,28,29,30,31,32} diff --git a/src/content/docs/workers/miniflare/storage/d1.md b/src/content/docs/workers/miniflare/storage/d1.md index 6dbd4996d24206..15ef113ef76a48 100644 --- a/src/content/docs/workers/miniflare/storage/d1.md +++ b/src/content/docs/workers/miniflare/storage/d1.md @@ -20,7 +20,7 @@ const mf = new Miniflare({ ## Working with D1 Databases For testing, it can be useful to put/get data from D1 storage -bound to a worker. You can do this with the `getD1Database` method: +bound to a Worker. You can do this with the `getD1Database` method: ```js const db = await mf.getD1Database("DB");