-
Notifications
You must be signed in to change notification settings - Fork 688
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 hello world example for Durable Objects #4747
Add hello world example for Durable Objects #4747
Conversation
|
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7585525527/npm-package-wrangler-4747 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/4747/npm-package-wrangler-4747 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7585525527/npm-package-wrangler-4747 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7585525527/npm-package-create-cloudflare-4747 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7585525527/npm-package-miniflare-4747 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/7585525527/npm-package-cloudflare-pages-shared-4747 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #4747 +/- ##
==========================================
- Coverage 75.63% 71.81% -3.83%
==========================================
Files 243 285 +42
Lines 13210 14759 +1549
Branches 3393 3719 +326
==========================================
+ Hits 9992 10599 +607
- Misses 3218 4160 +942 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More in-line code comments explaining each method call.
Assume a user hasn't read the docs and is jumping in via the create Cloudflare flow for the first time.
packages/create-cloudflare/templates/do-hello-world/js/package.json
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/do-hello-world/js/src/index.js
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/do-hello-world/js/src/index.js
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/do-hello-world/ts/src/index.ts
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/do-hello-world/js/src/index.js
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/do-hello-world/js/src/index.js
Outdated
Show resolved
Hide resolved
bec9fe5
to
19b39ab
Compare
@MellowYarker and @elithrar PTAL. I tested this locally and it works. Not sure what the test failures are here. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - the e2e failures are because you need secrets to run these, which are not available to PRs built in personal forks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there are a couple of issues with the JSDoc
typings
packages/create-cloudflare/templates/hello-world-durable-object/js/src/index.js
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/hello-world-durable-object/js/src/index.js
Show resolved
Hide resolved
packages/create-cloudflare/templates/hello-world-durable-object/js/src/index.js
Outdated
Show resolved
Hide resolved
19b39ab
to
3290c37
Compare
@penalosa I've addressed these changes. I was unsure about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pulled this down and tried it out. One last fix needed.
packages/create-cloudflare/templates/hello-world-durable-object/ts/tsconfig.json
Outdated
Show resolved
Hide resolved
packages/create-cloudflare/templates/hello-world-durable-object/js/src/index.js
Show resolved
Hide resolved
@petebacondarwin WDYM by "Can you do that with JSDoc comments?" |
In his comment @penalosa suggested that we would need to define the I note in the standard Workers Hello World starter, we don't both to define types (in jsdoc comments) at all. |
packages/create-cloudflare/templates/hello-world-durable-object/js/src/index.js
Outdated
Show resolved
Hide resolved
@petebacondarwin TypeScript supports typedefs in JSDoc files (https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html#typedef-callback-and-param) |
3290c37
to
fbf4c7a
Compare
Turns out that you can (though I'm not sure why someone would go through that much trouble to not use TypeScript lol). The type is annotated on line 12 in the same file. Comments are addressed. Should be good to go now. |
Created #4762 to run the e2e tests in CI. |
|
And this test needs to change: workers-sdk/packages/create-cloudflare/e2e-tests/cli.test.ts Lines 108 to 112 in fbf4c7a
Right now it is trying to select the "Example router & proxy Worker" type but since this PR adds a new item above this one, it is getting the wrong project type. |
fbf4c7a
to
7ffe646
Compare
@petebacondarwin I pushed some updates yesterday. I'm a little confused about what is supposed to run where, so please let me know if there are any other test failures I need to worry about. Otherwise, maybe we can hop on a call Monday and I can understand a bit more about how to develop on workers-sdk. |
Pushed the new commits to the origin fork. If the tests are good we can merge this. |
The other branch was green so let's land this! |
Darn it! I just realised that we should have added a changeset for this. I'll add one in a new PR now. |
This new starter corresponds to the getting started guide in the docs. See #4747
This new starter corresponds to the getting started guide in the docs. See #4747
Fixes # [insert GH or internal issue number(s)].
What this PR solves / how to test:
This PR attempts to add a new create-cloudflare example for Durable Objects, which corresponds to the getting started docs on Durable Objects.
Author has addressed the following:
Note for PR author:
We want to celebrate and highlight awesome PR review! If you think this PR received a particularly high-caliber review, please assign it the label
highlight pr review
so future reviewers can take inspiration and learn from it.