https://github.com/msutkowski/cloudflare-workers-typescript-router
A template for Cloudflare workers with a fully-typed router
https://github.com/msutkowski/cloudflare-workers-typescript-router
Last synced: about 1 year ago
JSON representation
A template for Cloudflare workers with a fully-typed router
- Host: GitHub
- URL: https://github.com/msutkowski/cloudflare-workers-typescript-router
- Owner: msutkowski
- License: mit
- Created: 2020-11-11T08:09:00.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2020-11-11T17:47:23.000Z (over 5 years ago)
- Last Synced: 2025-03-25T04:04:17.066Z (over 1 year ago)
- Language: TypeScript
- Size: 115 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ʕ •́؈•̀) `Cloudflare Workers TS Template with a Router`
This is just used for quickly prototyping handlers with TS.
## 🔋 Getting Started
Update `wrangler.toml` with your information
```shell
yarn
yarn dev
wrangler preview
```
### 👩 💻 Developing
The router returns the specified request handler, and will return the [request method](https://developer.mozilla.org/en-US/docs/Web/API/Request/method) for the given request.
### 🧪 Testing
This comes with mocha tests which simply test that the request handler can handle each request method. `yarn test` will run your tests.
### ✏️ Formatting
This uses [`prettier`](https://prettier.io/) to format the project. To invoke, run `yarn format`.
### 👀 Previewing and Publishing
Github actions will automatically deploy anything pushed to `main`.
For information on how to preview and publish workers, please see the [Wrangler docs](https://developers.cloudflare.com/workers/tooling/wrangler/commands/#publish).
## ⚠️ 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](https://developers.cloudflare.com/workers/tooling/wrangler/configuration/environments/) to test things before deploying.