itty-router 3.0.1 → 3.0.3

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.
Files changed (2) hide show
  1. package/README.md +26 -1
  2. package/package.json +8 -4
package/README.md CHANGED
@@ -13,13 +13,38 @@
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
+ # Major Announcement: v3.x is Live!
17
+ Due to an NPM hiccup, `3.0.0` went live early (instead of staying on `next`). The immediate NPM unpublish (normally fine) was rejected, so rather than deprecate the version (super dirty), it's going to stay live on the main v3 path, and we'll smoke test the issues to address them rapidly. Please [join the discussion on Discord](https://discord.gg/53vyrZAu9u) to assist in this rollout! In the meantime, thanks everyone for your patience!
18
+
19
+ This comes with a couple major changes, and is now a TS-first lib.
20
+
21
+ ### Increase in bundle size (~250 bytes)
22
+ This was sadly overdue (and hopefully can be golfed down a bit), but as a result addressed the following issues from v2.x:
23
+
24
+ 1 . Routes can now capture complex/unknown paths using the trailing `+` modifier. As a result, this is now possible:
25
+ ```js
26
+ router.handle('/get-file/:path+', ({ params }) => params)
27
+
28
+ // GET /get-file/with/a/long/path.png => { path: "with/a/long/path.png" }
29
+ ```
30
+
31
+ 2. Query params with multiple same-name values now operate as you would expect (previously, they overwrote each other)
32
+ ```js
33
+ router.handle('/foo', ({ query }) => query)
34
+
35
+ // GET /foo?pets=mittens&pets=fluffy&pets=rex&bar=baz => { bar: "baz", pets: ["mittens", "fluffy", "rex"] }
36
+ ```
37
+
38
+ ### Breaking TS changes
39
+ I've been forced to rewrite the TS types. This will need a bit of documentation...
40
+
16
41
  ### Addons & Related Libraries
17
42
  1. [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)!
18
43
  2. [itty-cors](https://www.npmjs.com/package/itty-cors) (early access/alpha) - Easy CORS handling for itty APIs.
19
44
  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).
20
45
 
21
46
  ## Features
22
- - [x] Tiny ([~500 bytes](https://bundlephobia.com/package/itty-router) compressed), with zero dependencies.
47
+ - [x] Tiny ([~780 bytes](https://bundlephobia.com/package/itty-router) compressed), with zero dependencies.
23
48
  - [x] [Fully typed/TypeScript support](#typescript)
24
49
  - [x] Supports sync/async handlers/middleware.
25
50
  - [x] Parses route params, with wildcards and optionals (e.g. `/api/:collection/:id?`)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-router",
3
- "version": "3.0.1",
3
+ "version": "3.0.3",
4
4
  "description": "Tiny, zero-dependency API router - built for Cloudflare Workers, but works everywhere!",
5
5
  "sourceType": "module",
6
6
  "main": "./dist/itty-router.js",
@@ -8,8 +8,8 @@
8
8
  "exports": {
9
9
  ".": {
10
10
  "types": "./dist/itty-router.d.ts",
11
- "import": "./dist/itty-router.mjs",
12
- "require": "./dist/itty-router.js"
11
+ "import": "./dist/itty-router.min.mjs",
12
+ "require": "./dist/itty-router.min.js"
13
13
  }
14
14
  },
15
15
  "files": [
@@ -45,7 +45,10 @@
45
45
  "postbuild": "node check-size.js",
46
46
  "release": "release --tag --push --patch",
47
47
  "prerelease:next": "yarn verify",
48
- "release:next": "release --push --type=next"
48
+ "release:next": "release --push --type=next",
49
+ "uglify": "yarn uglify:cjs && yarn uglify:esm",
50
+ "uglify:esm": "uglifyjs dist/itty-router.mjs -c -m --toplevel > dist/itty-router.min.mjs",
51
+ "uglify:cjs": "uglifyjs dist/itty-router.js -c -m --toplevel > dist/itty-router.min.js"
49
52
  },
50
53
  "repository": {
51
54
  "type": "git",
@@ -72,6 +75,7 @@
72
75
  "rimraf": "^3.0.2",
73
76
  "tsup": "^6.3.0",
74
77
  "typescript": "^4.8.4",
78
+ "uglify": "^0.1.5",
75
79
  "uglify-js": "^3.15.3",
76
80
  "vite": "^2.8.6",
77
81
  "vitest": "^0.24.3",