Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add miniflare docs #18690

Merged
merged 8 commits into from
Dec 18, 2024
Merged

Add miniflare docs #18690

merged 8 commits into from
Dec 18, 2024

Conversation

penalosa
Copy link
Contributor

@penalosa penalosa commented Dec 11, 2024

Adds the contents of https://miniflare.dev/, with non-relevant sections removed/modified. There are two commits—one with a full import of the content, and one with sections removed.

I imagine this will be a process of keeping these up to date and making them more detailed, but this should be a good start to allow us to retire https://miniflare.dev/ and the Miniflare 2 repo.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

22 files reviewed, 30 total issue(s) found.

src/content/docs/workers/miniflare/core/modules.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/core/standards.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/core/queues.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/index.mdx Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/migrations/from-v2.mdx Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/migrations/from-v2.mdx Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/storage/d1.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/core/scheduled.md Outdated Show resolved Hide resolved
Co-authored-by: hyperlint-ai[bot] <154288675+hyperlint-ai[bot]@users.noreply.github.com>
Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

21 files reviewed, 10 total issue(s) found.


Note: We resolved prior Hyperlint review comments because:

We updated our inline suggestion AI.

We do this to avoid keeping outdated or irrelevant comments around. We'll leave a new review with current comments below.

src/content/docs/workers/miniflare/core/fetch.mdx Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/storage/r2.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/storage/kv.md Outdated Show resolved Hide resolved
src/content/docs/workers/miniflare/storage/kv.md Outdated Show resolved Hide resolved
Copy link

cloudflare-workers-and-pages bot commented Dec 11, 2024

Deploying cloudflare-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5262d96
Status: ✅  Deploy successful!
Preview URL: https://cbfbc0a3.cloudflare-docs-7ou.pages.dev
Branch Preview URL: https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev

View logs

Copy link

github-actions bot commented Dec 11, 2024

Files with changes (up to 15)

Original Link Updated Link
https://developers.cloudflare.com/workers/testing/miniflare/get-started/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/get-started/
https://developers.cloudflare.com/workers/testing/miniflare/migrations/from-v2/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/migrations/from-v2/
https://developers.cloudflare.com/workers/testing/miniflare/core/fetch/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/core/fetch/
https://developers.cloudflare.com/workers/testing/miniflare/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/
https://developers.cloudflare.com/workers/testing/integration-testing/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/integration-testing/
https://developers.cloudflare.com/workers/testing/miniflare/core/compatibility/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/core/compatibility/
https://developers.cloudflare.com/workers/testing/miniflare/migrations/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/migrations/
https://developers.cloudflare.com/workers/testing/miniflare/core/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/core/
https://developers.cloudflare.com/workers/testing/miniflare/developing/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/developing/
https://developers.cloudflare.com/workers/testing/miniflare/storage/ https://penalosa-miniflare-docs.cloudflare-docs-7ou.pages.dev/workers/testing/miniflare/storage/

@@ -1,466 +0,0 @@
---
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of removing this whole page, let's perhaps keep it in a more condensed form, and keep stuff that is relevant to miniflare 3, and remove all the miniflare 2 specific bits 🙏

@@ -25,12 +25,7 @@ TypeScript, and runs your code in a sandbox implementing Workers' runtime APIs.
- ⚡ **Fully-local:** test and develop Workers without an internet connection.
Reload code on change quickly.

<LinkButton variant="primary" href="/workers/get-started/guide/">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we keep the get started page, we'll prolly wanna keep the btn as well :)

@@ -1,6 +1,6 @@
---
order: 3
title: ⬆️ Migrating from Version 2
title: ⬆️Migrating from Version 2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re-add the space here

@@ -30,15 +30,10 @@ please open an issue on

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. See the
[Getting Started guide for the new API docs](/get-started).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should add this get started link back

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

23 files reviewed, 7 total issue(s) found.

## Manipulating Outside Workers

For testing, it can be useful to put/get data from R2 storage
outside a worker. You can do this with the `getR2Bucket` method:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outside a worker. You can do this with the `getR2Bucket` method:
outside a Worker. You can do this with the `getR2Bucket` method:

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The term 'worker' should be capitalized to 'Worker' as per the style guide recommendation. It is not a code reference, so the correction is applicable.

## Using a Class Exported by Another Script

Miniflare supports the `script_name` option for accessing Durable Objects
exported by other scripts. This requires mounting the other worker as described
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exported by other scripts. This requires mounting the other worker as described
exported by other scripts. This requires mounting the other Worker as described

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The term 'worker' should be capitalized to 'Worker' as per the style guide recommendation. This is a straightforward capitalization fix.

title: Get Started
---

The Miniflare API allows you to dispatch events to workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/storage/kv), [R2](/storage/r2), and [Durable Objects](/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Miniflare API allows you to dispatch events to workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/storage/kv), [R2](/storage/r2), and [Durable Objects](/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.
The Miniflare API allows you to dispatch events to Workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/storage/kv), [R2](/storage/r2), and [Durable Objects](/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The term 'workers' should be capitalized to 'Workers' as per the style guide recommendation. This is not a code reference, so the correction is valid.

### Dispatching Events

`getWorker` dispatches `fetch`, `queues`, and `scheduled` events
to workers respectively:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to workers respectively:
to Workers respectively:

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The capitalization of 'workers' should be corrected to 'Workers' as per the style guide recommendation.

- `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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
service worker, `bindings` will be injected as globals, but these must be
service Worker, `bindings` will be injected as globals, but these must be

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The style guide suggests capitalizing 'Worker'. Since 'worker' is not a code reference, we should follow the recommendation and capitalize it.

});
```

You can now access KV namespaces in your workers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can now access KV namespaces in your workers:
You can now access KV namespaces in your Workers:

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The term 'workers' should be capitalized as 'Workers' according to the style guide recommendation. This is not a code reference, so the capitalization correction is appropriate.


## Manipulating Outside Workers

For testing, it can be useful to put/get data from KV outside a worker. You can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For testing, it can be useful to put/get data from KV outside a worker. You can
For testing, it can be useful to put/get data from KV outside a Worker. You can

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The word 'worker' should be capitalized to 'Worker' as per the style guide recommendation. This is a straightforward capitalization fix.

Copy link
Contributor

@CarmenPopoviciu CarmenPopoviciu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much @penalosa for working on this ♥️ . This is awesome!!

Copy link
Contributor

@irvinebroque irvinebroque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should not be top-level in dev docs:
Screenshot 2024-12-17 at 9 28 30 AM

And certainly not above other content that is currently below it.

Suggestion would be:

  • The content itself is part of /workers/testing — we already talk about Miniflare here.
  • It should be linked to from /workers/wrangler/api

Docs for Miniflare lead with:

Screenshot 2024-12-17 at 9 30 36 AM

Things in the left-hand nav of Workers docs should be things that in the base case, people building Workers need to interact with and understand.

Copy link
Contributor

@hyperlint-ai hyperlint-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

24 files reviewed, 7 total issue(s) found.

- `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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
service worker, `bindings` will be injected as globals, but these must be
service Worker, `bindings` will be injected as globals, but these must be

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The word 'worker' should be capitalized to 'Worker' as per the style guide recommendation. It is not a code reference, so the correction is valid.

## Manipulating Outside Workers

For testing, it can be useful to put/get data from R2 storage
outside a worker. You can do this with the `getR2Bucket` method:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
outside a worker. You can do this with the `getR2Bucket` method:
outside a Worker. You can do this with the `getR2Bucket` method:

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The term 'worker' should be capitalized to 'Worker' as per the style guide recommendation since it is not a code reference.

## Using a Class Exported by Another Script

Miniflare supports the `script_name` option for accessing Durable Objects
exported by other scripts. This requires mounting the other worker as described
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
exported by other scripts. This requires mounting the other worker as described
exported by other scripts. This requires mounting the other Worker as described

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The capitalization of 'worker' to 'Worker' is recommended by the style guide and is not part of any code reference or special syntax, so it should be corrected.

title: Get Started
---

The Miniflare API allows you to dispatch events to workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/workers/miniflare/storage/kv), [R2](/workers/miniflare/storage/r2), and [Durable Objects](/workers/miniflare/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The Miniflare API allows you to dispatch events to workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/workers/miniflare/storage/kv), [R2](/workers/miniflare/storage/r2), and [Durable Objects](/workers/miniflare/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.
The Miniflare API allows you to dispatch events to Workers without making actual HTTP requests, simulate connections between Workers, and interact with local emulations of storage products like [KV](/workers/miniflare/storage/kv), [R2](/workers/miniflare/storage/r2), and [Durable Objects](/workers/miniflare/storage/durable-objects). This makes it great for writing tests, or other advanced use cases where you need finer-grained control.

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The term 'Workers' should be capitalized as it refers to a specific product or service, consistent with the style guide's recommendation.

### Dispatching Events

`getWorker` dispatches `fetch`, `queues`, and `scheduled` events
to workers respectively:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
to workers respectively:
to Workers respectively:

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The review process identified a capitalization issue, recommending 'Workers' instead of 'workers'. This is a straightforward capitalization correction, and the guidelines instruct us to follow the recommendation in such cases.

});
```

You can now access KV namespaces in your workers:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
You can now access KV namespaces in your workers:
You can now access KV namespaces in your Workers:

Issues:

  • Style Guide - (Terms-error) Use 'Workers' instead of 'workers'.

Fix Explanation:

The style guide suggests capitalizing 'Workers'. Since it is not a code reference, the capitalization should be corrected.


## Manipulating Outside Workers

For testing, it can be useful to put/get data from KV outside a worker. You can
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For testing, it can be useful to put/get data from KV outside a worker. You can
For testing, it can be useful to put/get data from KV outside a Worker. You can

Issues:

  • Style Guide - (Terms-error) Use 'Worker' instead of 'worker'.

Fix Explanation:

The capitalization of 'worker' should be corrected to 'Worker' as per the style guide recommendation. This is not a code reference, so the change is appropriate.

@penalosa
Copy link
Contributor Author

@irvinebroque I've moved it to the testing folder. I'm a bit hesitant to link to it from Wrangler's API page though, since for most users it won't provide what they want from an API (especially for a Wrangler user, since it won't read their Wrangler config file). What do you think?

@irvinebroque
Copy link
Contributor

@penalosa I'm good with that

@penalosa penalosa merged commit 30eb97f into production Dec 18, 2024
11 of 12 checks passed
@penalosa penalosa deleted the penalosa/miniflare-docs branch December 18, 2024 20:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product:workers Related to Workers product size/xl
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants