msutkowski / cloudflare-workers-typescript-router

A template for Cloudflare workers with a fully-typed router

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ʕ •́؈•̀) 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

yarn
yarn dev
wrangler preview

👩 💻 Developing

The router returns the specified request handler, and will return the 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 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.

⚠️ 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

A template for Cloudflare workers with a fully-typed router

License:MIT License


Languages

Language:TypeScript 93.8%Language:JavaScript 6.2%