itty-router 3.0.11 → 3.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -13,30 +13,16 @@
|
|
|
13
13
|
|
|
14
14
|
Tiny, zero-dependency router with route param and query parsing - built for [Cloudflare Workers](https://developers.cloudflare.com/workers/), but works everywhere!
|
|
15
15
|
|
|
16
|
-
#
|
|
17
|
-
|
|
16
|
+
# v4.x Announcement
|
|
17
|
+
CORS and extras are coming in-house to **itty-router** core in 4.x! We're still ironing out all the types and exports, but if you'd like to test this early, please visit [itty.dev](https://itty.dev/itty-router) for the full documentation, and join us in [Discord](https://discord.com/channels/832353585802903572) for questions, help, suggestions, etc.
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
1 . Routes can now capture complex/unknown paths using the trailing `+` modifier. As a result, this is now possible:
|
|
22
|
-
```js
|
|
23
|
-
router.handle('/get-file/:path+', ({ params }) => params)
|
|
24
|
-
|
|
25
|
-
// GET /get-file/with/a/long/path.png => { path: "with/a/long/path.png" }
|
|
26
|
-
```
|
|
27
|
-
|
|
28
|
-
2. Query params with multiple same-name values now operate as you would expect (previously, they overwrote each other)
|
|
29
|
-
```js
|
|
30
|
-
router.handle('/foo', ({ query }) => query)
|
|
31
|
-
|
|
32
|
-
// GET /foo?pets=mittens&pets=fluffy&pets=rex&bar=baz
|
|
33
|
-
// ==> { bar: "baz", pets: ["mittens", "fluffy", "rex"] }
|
|
34
|
-
```
|
|
19
|
+
**NOTE: This will be a non-breaking DX upgrade for 99.9% of you, simply allowing you to share a single dependecy.**
|
|
35
20
|
|
|
36
21
|
### Addons & Related Libraries
|
|
37
|
-
1. [itty-
|
|
38
|
-
2. [itty-cors](https://www.npmjs.com/package/itty-cors) (early access/alpha) - Easy CORS handling for itty APIs.
|
|
22
|
+
1. [itty-cors](https://www.npmjs.com/package/itty-cors) (early access/alpha) - Easy CORS handling for itty APIs.
|
|
39
23
|
2. [itty-durable](https://www.npmjs.com/package/itty-durable) - creates a more direct object-like API for interacting with [Cloudflare Durable Objects](https://developers.cloudflare.com/workers/learning/using-durable-objects).
|
|
24
|
+
3. [itty-router-extras](https://www.npmjs.com/package/itty-router-extras) - adds quality-of-life improvements and utility functions for simplifying request/response code (e.g. middleware, cookies, body parsing, json handling, errors, and an itty version with automatic exception handling)!
|
|
25
|
+
4. [itty-router-openapi](https://www.npmjs.com/package/@cloudflare/itty-router-openapi) - OpenAPI 3 schema generator and validator for Cloudflare Workers.
|
|
40
26
|
|
|
41
27
|
## Features
|
|
42
28
|
- [x] Tiny ([~550 bytes](https://bundlephobia.com/package/itty-router) compressed), with zero dependencies.
|
|
@@ -46,13 +32,11 @@ Here are the major changes in version 3, with `itty-router-extras` (certainly) a
|
|
|
46
32
|
- [x] ["Greedy" route captures](#greedy) (e.g. `/api/:path+`)
|
|
47
33
|
- [x] Query parsing (e.g. `?page=3&foo=bar&foo=baz`)
|
|
48
34
|
- [x] [Middleware support](#middleware). Any number of sync/async handlers may be passed to a route.
|
|
35
|
+
- [x] [Global middleware support](#nested-routers-with-404-handling) using the `.all()` channel.
|
|
49
36
|
- [x] [Nestable](#nested-routers-with-404-handling). Supports nesting routers for API branching.
|
|
50
37
|
- [x] [Base path](#nested-routers-with-404-handling) for prefixing all routes.
|
|
51
|
-
- [x] [Multi-method support](#nested-routers-with-404-handling) using the `.all()` channel.
|
|
52
38
|
- [x] Supports **any** method type (e.g. `.get() --> 'GET'` or `.puppy() --> 'PUPPY'`).
|
|
53
39
|
- [x] Supports [Cloudflare ES Module syntax](#cf-es6-module-syntax)! :)
|
|
54
|
-
- [x] [Preload or manually inject custom regex for routes](#manual-routes) (advanced usage)
|
|
55
|
-
- [x] [Extendable](#extending-itty-router). Use itty as the internal base for more feature-rich/elaborate routers.
|
|
56
40
|
- [x] Chainable route declarations (why not?)
|
|
57
41
|
- [ ] Readable internal code (yeah right...)
|
|
58
42
|
|
package/package.json
CHANGED