From 39f38fc085a494ec46f9022b115105064b719e26 Mon Sep 17 00:00:00 2001 From: fengmk2 Date: Sat, 11 Jan 2025 09:40:37 +0800 Subject: [PATCH] fix: change repository.url to let auto release work --- CHANGELOG.md | 190 +++++++++++++++++++++++++++++++++++++++++++++++++++ History.md | 187 -------------------------------------------------- README.md | 25 ++++++- package.json | 2 +- 4 files changed, 215 insertions(+), 189 deletions(-) delete mode 100644 History.md diff --git a/CHANGELOG.md b/CHANGELOG.md index a3dd6bc..9b6dc17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,3 +6,193 @@ ### Features * remove is-type-of and debug deps ([#17](https://github.com/eggjs/egg-router/issues/17)) ([d737a20](https://github.com/eggjs/egg-router/commit/d737a20a5806ce899595e09c9b8f8b42e36fe443)) + +--- + + +2.0.1 / 2021-07-12 +================== + +**fixes** + * [[`2c44ec0`](http://github.com/eggjs/egg-router/commit/2c44ec0bdeff1e8f46d899ed4386d1e28a93a854)] - fix: ensure ctx._matchedRoute and ctx._matchedRouteName to be correct (#7) (Yiyu He <>) + +2.0.0 / 2019-02-14 +================== + +**features** + * [[`f0b29ec`](https://github.com/eggjs/egg-router/commit/f0b29ec34df32ba9d872f6318f4febd2b4ef9359)] - refactor: use class instead prototype (#4) (fengmk2 <>) + +1.2.0 / 2019-02-13 +================== + +**features** + * [[`1a0036a`](http://github.com/eggjs/egg-router/commit/1a0036a64a023b6b7993fecffe8062d5d0150971)] - feat: add routerPath to respond to routerName (#2) (Khaidi Chu <>) + +**others** + * [[`ff723fd`](http://github.com/eggjs/egg-router/commit/ff723fd03630ec49d5fe861abf129a583d214d22)] - chore: add koa-router license (#3) (fengmk2 <>) + +1.1.0 / 2019-01-30 +================== + +**features** + * [[`b318dd5`](http://github.com/eggjs/egg-router/commit/b318dd5ff2eea60013ed62b2a435f803c12bf20f)] - feat: add egg-router (dead-horse <>) + +**fixes** + * [[`b3db7b4`](http://github.com/eggjs/egg-router/commit/b3db7b41988d3bf1b4e885ed76b3a8165c1d3b1d)] - fix: add missing dependencies koa-convert (dead-horse <>) + * [[`c280336`](http://github.com/eggjs/egg-router/commit/c2803368a8256bc9504ae3c821eefeb9d1fcbc4d)] - fix: only support node@8 (dead-horse <>) + * [[`7a887a2`](http://github.com/eggjs/egg-router/commit/7a887a252445e602c2ea7e1c6f4cde52a433644d)] - fix: update license (dead-horse <>) + +**others** + * [[`ae40168`](http://github.com/eggjs/egg-router/commit/ae4016862fb8bdaf30e730a9278fbb1455d8b75d)] - docs: clean doc (dead-horse <>) + * [[`e4f21a8`](http://github.com/eggjs/egg-router/commit/e4f21a8ed6dfd72c4d6f4a13bbda9a4e90b0401c)] - chore: fix history (dead-horse <>) + +1.0.0 / 2019-01-30 +================== + +**others** + * [[`d6496e0`](http://github.com/eggjs/egg-router/commit/d6496e09be6b0f91dcb96611f31ec5ab6ad8ac78)] - refactor: rename to @eggjs/router (dead-horse <>) + +------------------------------- + +# Release History from koa-router + +## 7.4.0 + +- Fix router.url() for multiple nested routers [#407](https://github.com/alexmingoia/koa-router/pull/407) +- `layer.name` added to `ctx` at `ctx.routerName` during routing [#412](https://github.com/alexmingoia/koa-router/pull/412) +- 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. + +## 7.3.0 + +- Router#url() now accepts query parameters to add to generated urls [#396](https://github.com/alexmingoia/koa-router/pull/396) + +## 7.2.1 + +- Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359) + +## 7.2.0 + +- Fix a bug in Router#url and append Router object to ctx. [#350](https://github.com/alexmingoia/koa-router/pull/350) +- Adds `_matchedRouteName` to context [#337](https://github.com/alexmingoia/koa-router/pull/337) +- Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359) + +## 7.1.1 + +- Fix bug where param handlers were run out of order [#282](https://github.com/alexmingoia/koa-router/pull/282) + +## 7.1.0 + +- Backports: merge 5.4 work into the 7.x upstream. See 5.4.0 updates for more details. + +## 7.0.1 + +- Fix: allowedMethods should be ctx.method not this.method [#215](https://github.com/alexmingoia/koa-router/pull/215) + +## 7.0.0 + +- The API has changed to match the new promise-based middleware + signature of koa 2. See the + [koa 2.x readme](https://github.com/koajs/koa/tree/2.0.0-alpha.3) for more + information. +- Middleware is now always run in the order declared by `.use()` (or `.get()`, + etc.), which matches Express 4 API. + +## 5.4.0 + +- Expose matched route at `ctx._matchedRoute`. + +## 5.3.0 + +- Register multiple routes with array of paths [#203](https://github.com/alexmingoia/koa-router/issue/143). +- Improved router.url() [#143](https://github.com/alexmingoia/koa-router/pull/143) +- Adds support for named routes and regular expressions + [#152](https://github.com/alexmingoia/koa-router/pull/152) +- Add support for custom throw functions for 405 and 501 responses [#206](https://github.com/alexmingoia/koa-router/pull/206) + +## 5.2.3 + +- Fix for middleware running twice when nesting routes [#184](https://github.com/alexmingoia/koa-router/issues/184) + +## 5.2.2 + +- Register routes without params before those with params [#183](https://github.com/alexmingoia/koa-router/pull/183) +- Fix for allowed methods [#182](https://github.com/alexmingoia/koa-router/issues/182) + +## 5.2.0 + +- Add support for async/await. Resolves [#130](https://github.com/alexmingoia/koa-router/issues/130). +- Add support for array of paths by Router#use(). Resolves [#175](https://github.com/alexmingoia/koa-router/issues/175). +- Inherit param middleware when nesting routers. Fixes [#170](https://github.com/alexmingoia/koa-router/issues/170). +- 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). +- Run nested router middleware after parent's. Fixes [#156](https://github.com/alexmingoia/koa-router/issues/156). +- Remove dependency on koa-compose. + +## 5.1.1 + +- Match routes in order they were defined. Fixes #131. + +## 5.1.0 + +- Support mounting router middleware at a given path. + +## 5.0.1 + +- Fix bug with missing parameters when nesting routers. + +## 5.0.0 + +- Remove confusing API for extending koa app with router methods. Router#use() + does not have the same behavior as app#use(). +- Add support for nesting routes. +- Remove support for regular expression routes to achieve nestable routers and + enable future trie-based routing optimizations. + +## 4.3.2 + +- Do not send 405 if route matched but status is 404. Fixes #112, closes #114. + +## 4.3.1 + +- Do not run middleware if not yielded to by previous middleware. Fixes #115. + +## 4.3.0 + +- Add support for router prefixes. +- Add MIT license. + +## 4.2.0 + +- Fixed issue with router middleware being applied even if no route was +matched. +- Router.url - new static method to generate url from url pattern and data + +## 4.1.0 + +Private API changed to separate context parameter decoration from route +matching. `Router#match` and `Route#match` are now pure functions that return +an array of routes that match the URL path. + +For modules using this private API that need to determine if a method and path +match a route, `route.methods` must be checked against the routes returned from +`router.match()`: + +```javascript +var matchedRoute = router.match(path).filter(function (route) { + return ~route.methods.indexOf(method); +}).shift(); +``` + +## 4.0.0 + +405, 501, and OPTIONS response handling was moved into separate middleware +`router.allowedMethods()`. This resolves incorrect 501 or 405 responses when +using multiple routers. + +### Breaking changes + +4.x is mostly backwards compatible with 3.x, except for the following: + +- Instantiating a router with `new` and `app` returns the router instance, + whereas 3.x returns the router middleware. When creating a router in 4.x, the + only time router middleware is returned is when creating using the + `Router(app)` signature (with `app` and without `new`). diff --git a/History.md b/History.md deleted file mode 100644 index cef20aa..0000000 --- a/History.md +++ /dev/null @@ -1,187 +0,0 @@ - -2.0.1 / 2021-07-12 -================== - -**fixes** - * [[`2c44ec0`](http://github.com/eggjs/egg-router/commit/2c44ec0bdeff1e8f46d899ed4386d1e28a93a854)] - fix: ensure ctx._matchedRoute and ctx._matchedRouteName to be correct (#7) (Yiyu He <>) - -2.0.0 / 2019-02-14 -================== - -**features** - * [[`f0b29ec`](https://github.com/eggjs/egg-router/commit/f0b29ec34df32ba9d872f6318f4febd2b4ef9359)] - refactor: use class instead prototype (#4) (fengmk2 <>) - -1.2.0 / 2019-02-13 -================== - -**features** - * [[`1a0036a`](http://github.com/eggjs/egg-router/commit/1a0036a64a023b6b7993fecffe8062d5d0150971)] - feat: add routerPath to respond to routerName (#2) (Khaidi Chu <>) - -**others** - * [[`ff723fd`](http://github.com/eggjs/egg-router/commit/ff723fd03630ec49d5fe861abf129a583d214d22)] - chore: add koa-router license (#3) (fengmk2 <>) - -1.1.0 / 2019-01-30 -================== - -**features** - * [[`b318dd5`](http://github.com/eggjs/egg-router/commit/b318dd5ff2eea60013ed62b2a435f803c12bf20f)] - feat: add egg-router (dead-horse <>) - -**fixes** - * [[`b3db7b4`](http://github.com/eggjs/egg-router/commit/b3db7b41988d3bf1b4e885ed76b3a8165c1d3b1d)] - fix: add missing dependencies koa-convert (dead-horse <>) - * [[`c280336`](http://github.com/eggjs/egg-router/commit/c2803368a8256bc9504ae3c821eefeb9d1fcbc4d)] - fix: only support node@8 (dead-horse <>) - * [[`7a887a2`](http://github.com/eggjs/egg-router/commit/7a887a252445e602c2ea7e1c6f4cde52a433644d)] - fix: update license (dead-horse <>) - -**others** - * [[`ae40168`](http://github.com/eggjs/egg-router/commit/ae4016862fb8bdaf30e730a9278fbb1455d8b75d)] - docs: clean doc (dead-horse <>) - * [[`e4f21a8`](http://github.com/eggjs/egg-router/commit/e4f21a8ed6dfd72c4d6f4a13bbda9a4e90b0401c)] - chore: fix history (dead-horse <>) - -1.0.0 / 2019-01-30 -================== - -**others** - * [[`d6496e0`](http://github.com/eggjs/egg-router/commit/d6496e09be6b0f91dcb96611f31ec5ab6ad8ac78)] - refactor: rename to @eggjs/router (dead-horse <>) - -------------------------------- - -# Release History from koa-router - -## 7.4.0 - -- Fix router.url() for multiple nested routers [#407](https://github.com/alexmingoia/koa-router/pull/407) -- `layer.name` added to `ctx` at `ctx.routerName` during routing [#412](https://github.com/alexmingoia/koa-router/pull/412) -- 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. - -## 7.3.0 - -- Router#url() now accepts query parameters to add to generated urls [#396](https://github.com/alexmingoia/koa-router/pull/396) - -## 7.2.1 - -- Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359) - -## 7.2.0 - -- Fix a bug in Router#url and append Router object to ctx. [#350](https://github.com/alexmingoia/koa-router/pull/350) -- Adds `_matchedRouteName` to context [#337](https://github.com/alexmingoia/koa-router/pull/337) -- Respond to CORS preflights with 200, 0 length body [#359](https://github.com/alexmingoia/koa-router/issues/359) - -## 7.1.1 - -- Fix bug where param handlers were run out of order [#282](https://github.com/alexmingoia/koa-router/pull/282) - -## 7.1.0 - -- Backports: merge 5.4 work into the 7.x upstream. See 5.4.0 updates for more details. - -## 7.0.1 - -- Fix: allowedMethods should be ctx.method not this.method [#215](https://github.com/alexmingoia/koa-router/pull/215) - -## 7.0.0 - -- The API has changed to match the new promise-based middleware - signature of koa 2. See the - [koa 2.x readme](https://github.com/koajs/koa/tree/2.0.0-alpha.3) for more - information. -- Middleware is now always run in the order declared by `.use()` (or `.get()`, - etc.), which matches Express 4 API. - -## 5.4.0 - -- Expose matched route at `ctx._matchedRoute`. - -## 5.3.0 - -- Register multiple routes with array of paths [#203](https://github.com/alexmingoia/koa-router/issue/143). -- Improved router.url() [#143](https://github.com/alexmingoia/koa-router/pull/143) -- Adds support for named routes and regular expressions - [#152](https://github.com/alexmingoia/koa-router/pull/152) -- Add support for custom throw functions for 405 and 501 responses [#206](https://github.com/alexmingoia/koa-router/pull/206) - -## 5.2.3 - -- Fix for middleware running twice when nesting routes [#184](https://github.com/alexmingoia/koa-router/issues/184) - -## 5.2.2 - -- Register routes without params before those with params [#183](https://github.com/alexmingoia/koa-router/pull/183) -- Fix for allowed methods [#182](https://github.com/alexmingoia/koa-router/issues/182) - -## 5.2.0 - -- Add support for async/await. Resolves [#130](https://github.com/alexmingoia/koa-router/issues/130). -- Add support for array of paths by Router#use(). Resolves [#175](https://github.com/alexmingoia/koa-router/issues/175). -- Inherit param middleware when nesting routers. Fixes [#170](https://github.com/alexmingoia/koa-router/issues/170). -- 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). -- Run nested router middleware after parent's. Fixes [#156](https://github.com/alexmingoia/koa-router/issues/156). -- Remove dependency on koa-compose. - -## 5.1.1 - -- Match routes in order they were defined. Fixes #131. - -## 5.1.0 - -- Support mounting router middleware at a given path. - -## 5.0.1 - -- Fix bug with missing parameters when nesting routers. - -## 5.0.0 - -- Remove confusing API for extending koa app with router methods. Router#use() - does not have the same behavior as app#use(). -- Add support for nesting routes. -- Remove support for regular expression routes to achieve nestable routers and - enable future trie-based routing optimizations. - -## 4.3.2 - -- Do not send 405 if route matched but status is 404. Fixes #112, closes #114. - -## 4.3.1 - -- Do not run middleware if not yielded to by previous middleware. Fixes #115. - -## 4.3.0 - -- Add support for router prefixes. -- Add MIT license. - -## 4.2.0 - -- Fixed issue with router middleware being applied even if no route was -matched. -- Router.url - new static method to generate url from url pattern and data - -## 4.1.0 - -Private API changed to separate context parameter decoration from route -matching. `Router#match` and `Route#match` are now pure functions that return -an array of routes that match the URL path. - -For modules using this private API that need to determine if a method and path -match a route, `route.methods` must be checked against the routes returned from -`router.match()`: - -```javascript -var matchedRoute = router.match(path).filter(function (route) { - return ~route.methods.indexOf(method); -}).shift(); -``` - -## 4.0.0 - -405, 501, and OPTIONS response handling was moved into separate middleware -`router.allowedMethods()`. This resolves incorrect 501 or 405 responses when -using multiple routers. - -### Breaking changes - -4.x is mostly backwards compatible with 3.x, except for the following: - -- Instantiating a router with `new` and `app` returns the router instance, - whereas 3.x returns the router middleware. When creating a router in 4.x, the - only time router middleware is returned is when creating using the - `Router(app)` signature (with `app` and without `new`). diff --git a/README.md b/README.md index 3530802..0d20f67 100644 --- a/README.md +++ b/README.md @@ -32,12 +32,13 @@ Router core component for [Egg.js](https://github.com/eggjs). ### Router ⏏ + **Kind**: Exported class #### new Router([opts]) -Create a new router. +Create a new router. | Param | Type | Description | | --- | --- | --- | @@ -62,9 +63,11 @@ app .use(router.routes()) .use(router.allowedMethods()); ``` + #### router.get|put|post|patch|delete|del ⇒ Router + Create `router.verb()` methods, where *verb* is one of the HTTP verbs such as `router.get()` or `router.post()`. @@ -188,12 +191,14 @@ used to convert paths to regular expressions. #### router.routes ⇒ function + Returns router middleware which dispatches a route matching the request. **Kind**: instance property of [Router](#exp_module_egg-router--Router) #### router.use([path], middleware) ⇒ Router + Use given middleware. Middleware run in the order they are defined by `.use()`. They are invoked @@ -209,6 +214,7 @@ sequentially, requests start at the first middleware and work their way | [...] | function | **Example** + ```javascript // session middleware will run before authorize router @@ -223,9 +229,11 @@ router.use(['/users', '/admin'], userAuth()); app.use(router.routes()); ``` + #### router.prefix(prefix) ⇒ Router + Set the path prefix for a Router instance that was already initialized. **Kind**: instance method of [Router](#exp_module_egg-router--Router) @@ -235,12 +243,15 @@ Set the path prefix for a Router instance that was already initialized. | prefix | String | **Example** + ```javascript router.prefix('/things/:thing_id') ``` + #### router.allowedMethods([options]) ⇒ function + Returns separate middleware for responding to `OPTIONS` requests with an `Allow` header containing the allowed methods, as well as responding with `405 Method Not Allowed` and `501 Not Implemented` as appropriate. @@ -255,6 +266,7 @@ with `405 Method Not Allowed` and `501 Not Implemented` as appropriate. | [options.methodNotAllowed] | function | throw the returned value in place of the default MethodNotAllowed error | **Example** + ```javascript var Koa = require('koa'); var Router = require('egg-router'); @@ -283,9 +295,11 @@ app.use(router.allowedMethods({ methodNotAllowed: () => new Boom.methodNotAllowed() })); ``` + #### router.redirect(source, destination, [code]) ⇒ Router + Redirect `source` to `destination` URL with optional 30x status `code`. Both `source` and `destination` can be route names. @@ -314,6 +328,7 @@ router.all('/login', ctx => { #### router.route(name) ⇒ Layer | false + Lookup route with given `name`. **Kind**: instance method of [Router](#exp_module_egg-router--Router) @@ -325,6 +340,7 @@ Lookup route with given `name`. #### router.url(name, params, [options]) ⇒ String | Error + Generate URL for route. Takes a route name and map of named `params`. **Kind**: instance method of [Router](#exp_module_egg-router--Router) @@ -337,6 +353,7 @@ Generate URL for route. Takes a route name and map of named `params`. | [options.query] | Object | String | query options | **Example** + ```javascript router.get('user', '/users/:id', (ctx, next) => { // ... @@ -359,9 +376,11 @@ router.url('user', { id: 3 }, { query: { limit: 1 } }); router.url('user', { id: 3 }, { query: "limit=1" }); // => "/users/3?limit=1" ``` + #### router.param(param, middleware) ⇒ Router + Run middleware for named route parameters. Useful for auto-loading or validation. @@ -373,6 +392,7 @@ validation. | middleware | function | **Example** + ```javascript router .param('user', (id, ctx, next) => { @@ -391,9 +411,11 @@ router // /users/3 => {"id": 3, "name": "Alex"} // /users/3/friends => [{"id": 4, "name": "TJ"}] ``` + #### Router.url(path, params [, options]) ⇒ String + Generate URL from url pattern and given `params`. **Kind**: static method of [Router](#exp_module_egg-router--Router) @@ -406,6 +428,7 @@ Generate URL from url pattern and given `params`. | [options.query] | Object | String | query options | **Example** + ```javascript var url = Router.url('/users/:id', {id: 1}); // => "/users/1" diff --git a/package.json b/package.json index 815b0ec..10bdbff 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "description": "Router middleware for egg/koa. Provides RESTful resource routing.", "repository": { "type": "git", - "url": "https://github.com/eggjs/egg-router.git" + "url": "git@github.com:eggjs/router.git" }, "bugs": { "url": "https://github.com/eggjs/egg/issues"