tienquanutc / cloudflare-workers-typescript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

πŸ”₯ Miniflare

Miniflare is a simulator for developing and testing Cloudflare Workers.

  • πŸŽ‰ 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. Reload code on change quickly.

It's an alternative to wrangler dev, written in TypeScript, that runs your workers in a sandbox implementing Workers' runtime APIs.

See https://miniflare.dev for more detailed documentation.

✍ TypeScript template for Cloudflare Workers

πŸ”‹ Getting Started

This template is meant to be used with Wrangler. If you are not already familiar with the tool, we recommend that you install the tool and configure it to work with your Cloudflare account. Documentation can be found here.

To generate using Wrangler, run this command:

wrangler generate my-ts-project https://github.com/cloudflare/worker-typescript-template

πŸ‘© πŸ’» Developing

src/index.ts calls the request handler in src/handler.ts, and will return the request method for the given request.

πŸ§ͺ Testing

This template comes with jest tests which simply test that the request handler can handle each request method. npm test will run your tests.

✏️ Formatting

This template uses prettier to format the project. To invoke, run npm run format.

πŸ‘€ Previewing and Publishing

For information on how to preview and publish your worker, please see the Wrangler docs.

🀒 Issues

If you run into issues with this specific project, please feel free to file an issue here. If the problem is with Wrangler, please file an issue here.

⚠️ Caveats

The service-worker-mock used by the tests is not a perfect representation of the Cloudflare Workers runtime. It is a general approximation. We recommend that you test end to end with wrangler dev in addition to a staging environment to test things before deploying.

About

License:Apache License 2.0


Languages

Language:TypeScript 60.0%Language:JavaScript 40.0%