itty-router 2.5.2 → 2.5.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  <img alt="Join the discussion on Github" src="https://img.shields.io/badge/Github%20Discussions%20%26%20Support-Chat%20now!-blue" />
20
20
  </a>-->
21
21
 
22
- It's an itty bitty router, designed for express-like routing within [Cloudflare Workers](https://developers.cloudflare.com/workers/) (or anywhere else). Like... it's super tiny ([~500 bytes](https://bundlephobia.com/package/itty-router)), with zero dependencies. For reals.
22
+ Tiny, zero-dependency router with route param and query parsing - built for [Cloudflare Workers](https://developers.cloudflare.com/workers/), but works everywhere!
23
23
 
24
24
  ### Addons & Related Libraries
25
25
  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)!
@@ -27,9 +27,9 @@ It's an itty bitty router, designed for express-like routing within [Cloudflare
27
27
 
28
28
  ## Features
29
29
  - [x] Tiny ([~500 bytes](https://bundlephobia.com/package/itty-router) compressed), with zero dependencies.
30
- - [x] [TypeScript support](#typescript)!
31
- - [x] Full sync/async support. Use it when you need it!
32
- - [x] Route params, with wildcards and optionals (e.g. `/api/:collection/:id?`)
30
+ - [x] [Fully typed/TypeScript support](#typescript)
31
+ - [x] Supports sync/async handlers/middleware.
32
+ - [x] Parses route params, with wildcards and optionals (e.g. `/api/:collection/:id?`)
33
33
  - [x] Query parsing (e.g. `?page=3&foo=bar`)
34
34
  - [x] [Middleware support](#middleware). Any number of sync/async handlers may be passed to a route.
35
35
  - [x] [Nestable](#nested-routers-with-404-handling). Supports nesting routers for API branching.
@@ -105,9 +105,9 @@ router.get('/todos/:user/:item?', (req) => {
105
105
  ```
106
106
 
107
107
  ### 3. Handle Incoming Request(s)
108
- ##### `async router.handle(request.proxy: Proxy || request: Request, ...anything else)`
108
+ ##### `async router.handle(request.proxy: Proxy || request: Request, ...anything else) => Promise<any>`
109
109
  Requests (doesn't have to be a real Request class) should have both a **method** and full **url**.
110
- The `handle` method will then return the first matching route handler that returns something (or nothing at all if no match).
110
+ The `handle` method will then return a Promise, resolving with the first matching route handler that returns something (or nothing at all if no match).
111
111
 
112
112
  ```js
113
113
  router.handle({
@@ -301,7 +301,7 @@ export default {
301
301
  export default {
302
302
  fetch: (...args) => router
303
303
  .handle(...args)
304
- .then(response =>
304
+ .then(response => {
305
305
  // can modify response here before final return, e.g. CORS headers
306
306
 
307
307
  return response
@@ -42,7 +42,7 @@ export interface IHTTPMethods {
42
42
  }
43
43
 
44
44
  export type Router<TRequest = Request, TMethods = {}> = {
45
- handle: (request: TRequest, ...extra: any) => any
45
+ handle: (request: TRequest, ...extra: any) => Promise<any>
46
46
  routes: RouteEntry<TRequest>[]
47
47
  all: Route
48
48
  } & TMethods & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "itty-router",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Tiny, zero-dependency router with route param and query parsing - built for Cloudflare Workers, but works everywhere!",
5
5
  "main": "./dist/itty-router.min.js",
6
6
  "types": "./dist/itty-router.d.ts",
@@ -62,20 +62,19 @@
62
62
  },
63
63
  "homepage": "https://itty-router.dev",
64
64
  "devDependencies": {
65
- "@vitejs/plugin-vue": "^1.4.0",
66
- "@vue/compiler-sfc": "^3.2.2",
67
- "chalk": "^4.1.2",
65
+ "@vitejs/plugin-vue": "^2.2.4",
66
+ "@vue/compiler-sfc": "^3.2.31",
68
67
  "coveralls": "^3.1.1",
69
- "eslint": "^7.32.0",
70
- "eslint-plugin-jest": "^24.4.0",
71
- "fs-extra": "^10.0.0",
68
+ "eslint": "^8.11.0",
69
+ "eslint-plugin-jest": "^26.1.2",
70
+ "fs-extra": "^10.0.1",
72
71
  "gzip-size": "^6.0.0",
73
72
  "isomorphic-fetch": "^3.0.0",
74
- "jest": "^27.0.6",
73
+ "jest": "^27.5.1",
75
74
  "rimraf": "^3.0.2",
76
- "uglify-js": "^3.14.1",
77
- "vite": "^2.4.4",
78
- "yarn": "^1.22.11",
75
+ "uglify-js": "^3.15.3",
76
+ "vite": "^2.8.6",
77
+ "yarn": "^1.22.18",
79
78
  "yarn-release": "^1.10.3"
80
79
  }
81
80
  }