https://github.com/cloudflare/worker-template-router
https://github.com/cloudflare/worker-template-router
Last synced: 9 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/cloudflare/worker-template-router
- Owner: cloudflare
- Created: 2019-04-26T16:59:08.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-09-25T22:49:18.000Z (7 months ago)
- Last Synced: 2025-03-27T06:09:40.841Z (18 days ago)
- Language: JavaScript
- Size: 40 KB
- Stars: 235
- Watchers: 12
- Forks: 85
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-cloudflare - Router - Router that can be used with REST APIs or apps for basic routing logic. (Workers / Recipes)
- awesome-cloudflare - Router - Router that can be used with REST APIs or apps for basic routing logic. (Workers / Recipes)
README
## Router
This template demonstrates using the [`itty-router`](https://github.com/kwhitley/itty-router) package to add routing to your Cloudflare Workers.
[`index.js`](https://github.com/cloudflare/worker-template-router/blob/master/index.js) is the content of the Workers script.
#### Wrangler
You can use [wrangler](https://github.com/cloudflare/wrangler) to generate a new Cloudflare Workers project based on this template by running the following command from your terminal:
```
wrangler generate myapp https://github.com/cloudflare/worker-template-router
```Before publishing your code you need to edit `wrangler.toml` file and add your Cloudflare `account_id` - more information about configuring and publishing your code can be found [in the documentation](https://developers.cloudflare.com/workers/learning/getting-started#7-configure-your-project-for-deployment).
Once you are ready, you can publish your code by running the following command:
```
wrangler publish
```