1
0
Files
cloudflare-worker-router/MIGRATION.md
2022-06-26 02:29:47 +02:00

1.9 KiB
Raw Permalink Blame History

Migration Guide

From v1.x.x to v2.x.x.

Contents

Preparation

Follow Cloudflare's Migration Guide to update your protject to wrangler2.

Update

Update to the latest version verstion

npm i -D @tsndr/cloudflare-worker-router

Import / Require

Switch to ESModules.

Before

const Router = require('@tsndr/cloudflare-worker-router')

After

import Router from '@tsndr/cloudflare-worker-router'

Routes

Just add curly braces.

Before

Petrify 2022-06-24 at 5 57 01 PM

After

Petrify 2022-06-24 at 5 55 56 PM

Fetch / router.handle()

Be aware that with v2.0.0 the parameters of router.handle() changed

Before

Petrify 2022-06-24 at 5 58 43 PM

After

Petrify 2022-06-24 at 5 59 22 PM