@koa/router 13.0.0 → 13.1.0

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/HISTORY.md ADDED
@@ -0,0 +1,187 @@
1
+ # History
2
+
3
+ **[History has moved to the Releases tab of GitHub](https://github.com/koajs/router/releases).**
4
+
5
+
6
+ ## Log
7
+
8
+
9
+ ## 9.0.0 / 2020-04-09
10
+
11
+ * Update `path-to-regexp`. Migration path: change usage of `'*'` in routes to `(.*)` or `:splat*`.
12
+ * Example: `router.get('*', ....)` becomes `router.get('(.*)') ....)`
13
+
14
+
15
+ ## 8.0.0 / 2019-06-16
16
+
17
+ **others**
18
+
19
+ * [b5dd5e8](http://github.com/koajs/koa-router/commit/b5dd5e8f00e841b7061a62ab6228cbe96a999470)] - chore: rename to @koa/router (dead-horse)
20
+
21
+ ---
22
+
23
+ Changelogs inherit from koa-router.
24
+
25
+
26
+ ## 7.4.0
27
+
28
+ * Fix router.url() for multiple nested routers [#407](https://github.com/alexmingoia/koa-router/pull/407)
29
+ * `layer.name` added to `ctx` at `ctx.routerName` during routing [#412](https://github.com/alexmingoia/koa-router/pull/412)
30
+ * Router.use() was erroneously settings `(.*)` as a prefix to all routers nested with .use that did not pass an explicit prefix string as the first argument. This resulted in routes being matched that should not have been, included the running of multiple route handlers in error. [#369](https://github.com/alexmingoia/koa-router/issues/369) and [#410](https://github.com/alexmingoia/koa-router/issues/410) include information on this issue.
31
+
32
+
33
+ ## 7.3.0
34
+
35
+ * Router#url() now accepts query parameters to add to generated urls [#396](https://github.com/alexmingoia/koa-router/pull/396)
36
+
37
+
38
+ ## 7.2.1
39
+
40
+ * Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359)
41
+
42
+
43
+ ## 7.2.0
44
+
45
+ * Fix a bug in Router#url and append Router object to ctx. [#350](https://github.com/alexmingoia/koa-router/pull/350)
46
+ * Adds `_matchedRouteName` to context [#337](https://github.com/alexmingoia/koa-router/pull/337)
47
+ * Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359)
48
+
49
+
50
+ ## 7.1.1
51
+
52
+ * Fix bug where param handlers were run out of order [#282](https://github.com/alexmingoia/koa-router/pull/282)
53
+
54
+
55
+ ## 7.1.0
56
+
57
+ * Backports: merge 5.4 work into the 7.x upstream. See 5.4.0 updates for more details.
58
+
59
+
60
+ ## 7.0.1
61
+
62
+ * Fix: allowedMethods should be ctx.method not this.method [#215](https://github.com/alexmingoia/koa-router/pull/215)
63
+
64
+
65
+ ## 7.0.0
66
+
67
+ * The API has changed to match the new promise-based middleware
68
+ signature of koa 2. See the
69
+ [koa 2.x readme](https://github.com/koajs/koa/tree/2.0.0-alpha.3) for more
70
+ information.
71
+ * Middleware is now always run in the order declared by `.use()` (or `.get()`,
72
+ etc.), which matches Express 4 API.
73
+
74
+
75
+ ## 5.4.0
76
+
77
+ * Expose matched route at `ctx._matchedRoute`.
78
+
79
+
80
+ ## 5.3.0
81
+
82
+ * Register multiple routes with array of paths [#203](https://github.com/alexmingoia/koa-router/issue/143).
83
+ * Improved router.url() [#143](https://github.com/alexmingoia/koa-router/pull/143)
84
+ * Adds support for named routes and regular expressions
85
+ [#152](https://github.com/alexmingoia/koa-router/pull/152)
86
+ * Add support for custom throw functions for 405 and 501 responses [#206](https://github.com/alexmingoia/koa-router/pull/206)
87
+
88
+
89
+ ## 5.2.3
90
+
91
+ * Fix for middleware running twice when nesting routes [#184](https://github.com/alexmingoia/koa-router/issues/184)
92
+
93
+
94
+ ## 5.2.2
95
+
96
+ * Register routes without params before those with params [#183](https://github.com/alexmingoia/koa-router/pull/183)
97
+ * Fix for allowed methods [#182](https://github.com/alexmingoia/koa-router/issues/182)
98
+
99
+
100
+ ## 5.2.0
101
+
102
+ * Add support for async/await. Resolves [#130](https://github.com/alexmingoia/koa-router/issues/130).
103
+ * Add support for array of paths by Router#use(). Resolves [#175](https://github.com/alexmingoia/koa-router/issues/175).
104
+ * Inherit param middleware when nesting routers. Fixes [#170](https://github.com/alexmingoia/koa-router/issues/170).
105
+ * Default router middleware without path to root. Fixes [#161](https://github.com/alexmingoia/koa-router/issues/161), [#155](https://github.com/alexmingoia/koa-router/issues/155), [#156](https://github.com/alexmingoia/koa-router/issues/156).
106
+ * Run nested router middleware after parent's. Fixes [#156](https://github.com/alexmingoia/koa-router/issues/156).
107
+ * Remove dependency on koa-compose.
108
+
109
+
110
+ ## 5.1.1
111
+
112
+ * Match routes in order they were defined. Fixes #131.
113
+
114
+
115
+ ## 5.1.0
116
+
117
+ * Support mounting router middleware at a given path.
118
+
119
+
120
+ ## 5.0.1
121
+
122
+ * Fix bug with missing parameters when nesting routers.
123
+
124
+
125
+ ## 5.0.0
126
+
127
+ * Remove confusing API for extending koa app with router methods. Router#use()
128
+ does not have the same behavior as app#use().
129
+ * Add support for nesting routes.
130
+ * Remove support for regular expression routes to achieve nestable routers and
131
+ enable future trie-based routing optimizations.
132
+
133
+
134
+ ## 4.3.2
135
+
136
+ * Do not send 405 if route matched but status is 404. Fixes #112, closes #114.
137
+
138
+
139
+ ## 4.3.1
140
+
141
+ * Do not run middleware if not yielded to by previous middleware. Fixes #115.
142
+
143
+
144
+ ## 4.3.0
145
+
146
+ * Add support for router prefixes.
147
+ * Add MIT license.
148
+
149
+
150
+ ## 4.2.0
151
+
152
+ * Fixed issue with router middleware being applied even if no route was
153
+ matched.
154
+ * Router.url - new static method to generate url from url pattern and data
155
+
156
+
157
+ ## 4.1.0
158
+
159
+ Private API changed to separate context parameter decoration from route
160
+ matching. `Router#match` and `Route#match` are now pure functions that return
161
+ an array of routes that match the URL path.
162
+
163
+ For modules using this private API that need to determine if a method and path
164
+ match a route, `route.methods` must be checked against the routes returned from
165
+ `router.match()`:
166
+
167
+ ```javascript
168
+ var matchedRoute = router.match(path).filter(function (route) {
169
+ return ~route.methods.indexOf(method);
170
+ }).shift();
171
+ ```
172
+
173
+
174
+ ## 4.0.0
175
+
176
+ 405, 501, and OPTIONS response handling was moved into separate middleware
177
+ `router.allowedMethods()`. This resolves incorrect 501 or 405 responses when
178
+ using multiple routers.
179
+
180
+ ### Breaking changes
181
+
182
+ 4.x is mostly backwards compatible with 3.x, except for the following:
183
+
184
+ * Instantiating a router with `new` and `app` returns the router instance,
185
+ whereas 3.x returns the router middleware. When creating a router in 4.x, the
186
+ only time router middleware is returned is when creating using the
187
+ `Router(app)` signature (with `app` and without `new`).
package/lib/router.js CHANGED
@@ -228,7 +228,7 @@ class Router {
228
228
  ctx.routerPath;
229
229
  const matched = router.match(path, ctx.method);
230
230
  if (ctx.matched) {
231
- ctx.matched.push(matched.path);
231
+ ctx.matched.push.apply(ctx.matched, matched.path);
232
232
  } else {
233
233
  ctx.matched = matched.path;
234
234
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@koa/router",
3
3
  "description": "Router middleware for koa. Maintained by Forward Email and Lad.",
4
- "version": "13.0.0",
4
+ "version": "13.1.0",
5
5
  "author": "Alex Mingoia <talk@alexmingoia.com>",
6
6
  "bugs": {
7
7
  "url": "https://github.com/koajs/router/issues",
@@ -23,7 +23,7 @@
23
23
  "dependencies": {
24
24
  "http-errors": "^2.0.0",
25
25
  "koa-compose": "^4.1.0",
26
- "path-to-regexp": "^6.2.2"
26
+ "path-to-regexp": "^6.3.0"
27
27
  },
28
28
  "devDependencies": {
29
29
  "@commitlint/cli": "^17.7.2",
@@ -60,7 +60,7 @@
60
60
  "main": "lib/router.js",
61
61
  "repository": {
62
62
  "type": "git",
63
- "url": "https://github.com/koajs/router.git"
63
+ "url": "git+https://github.com/koajs/router.git"
64
64
  },
65
65
  "scripts": {
66
66
  "bench": "make -C bench",
@@ -68,7 +68,7 @@
68
68
  "docs": "NODE_ENV=test jsdoc2md -t ./lib/API_tpl.hbs --src ./lib/*.js >| API.md",
69
69
  "lint": "xo --fix && remark . -qfo && fixpack",
70
70
  "prepare": "husky install",
71
- "pretest": "npm run lint",
71
+ "prextest": "npm run lint",
72
72
  "test": "mocha test/**/*.js",
73
73
  "test:watch": "mocha test/**/*.js --watch"
74
74
  }