koatty_router 1.7.10 → 1.8.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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.8.0](https://github.com/koatty/koatty_router/compare/v1.7.12...v1.8.0) (2022-11-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * httpRouter与wsRouter使用了错误的加载方式 ([94d111c](https://github.com/koatty/koatty_router/commit/94d111cc321d80b3098a3abcb999ca64d0cc4f95))
11
+
12
+ ### [1.7.12](https://github.com/koatty/koatty_router/compare/v1.7.10...v1.7.12) (2022-11-01)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * ctx.body 赋值 ([2a8d8c8](https://github.com/koatty/koatty_router/commit/2a8d8c8d4e8615777f50dc4ccaf331e4f10bc66b))
18
+
5
19
  ### [1.7.10](https://github.com/koatty/koatty_router/compare/v1.7.9...v1.7.10) (2022-10-31)
6
20
 
7
21
  ### [1.7.9](https://github.com/koatty/koatty_router/compare/v1.7.8...v1.7.9) (2022-08-19)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-10-31 15:15:47
3
+ * @Date: 2022-11-13 00:14:09
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-10-31 15:15:33
3
+ * @Date: 2022-11-13 00:13:55
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -294,7 +294,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
294
294
  * @Usage:
295
295
  * @Author: richen
296
296
  * @Date: 2021-11-10 16:58:57
297
- * @LastEditTime: 2022-03-15 17:10:46
297
+ * @LastEditTime: 2022-11-01 15:41:24
298
298
  */
299
299
  /**
300
300
  * controller handler
@@ -319,7 +319,8 @@ async function Handler(app, ctx, ctl, method, ctlParams) {
319
319
  args = await getParamter(app, ctx, ctlParams);
320
320
  }
321
321
  // method
322
- return ctl[method](...args);
322
+ const res = await ctl[method](...args);
323
+ ctx.body = res;
323
324
  }
324
325
  /**
325
326
  *
@@ -575,14 +576,11 @@ class HttpRouter {
575
576
  const path = router.path;
576
577
  const requestMethod = router.requestMethod;
577
578
  const params = ctlParams[method];
578
- // websocket only handler get request
579
- if (requestMethod == exports.RequestMethod.GET || requestMethod == exports.RequestMethod.ALL) {
580
- koatty_logger.DefaultLogger.Debug(`Register request mapping: [${requestMethod}] : ["${path}" => ${n}.${method}]`);
581
- this.SetRouter(path, (ctx) => {
582
- const ctl = koatty_container.IOCContainer.getInsByClass(ctlClass, [ctx]);
583
- return Handler(this.app, ctx, ctl, method, params);
584
- }, requestMethod);
585
- }
579
+ koatty_logger.DefaultLogger.Debug(`Register request mapping: ["${path}" => ${n}.${method}]`);
580
+ this.SetRouter(path, (ctx) => {
581
+ const ctl = koatty_container.IOCContainer.getInsByClass(ctlClass, [ctx]);
582
+ return Handler(this.app, ctx, ctl, method, params);
583
+ }, requestMethod);
586
584
  }
587
585
  }
588
586
  // exp: in middleware
@@ -655,11 +653,14 @@ class WebsocketRouter {
655
653
  const method = router.method;
656
654
  const requestMethod = router.requestMethod;
657
655
  const params = ctlParams[method];
658
- koatty_logger.DefaultLogger.Debug(`Register request mapping: ["${path}" => ${n}.${method}]`);
659
- this.SetRouter(path, (ctx) => {
660
- const ctl = koatty_container.IOCContainer.getInsByClass(ctlClass, [ctx]);
661
- return Handler(this.app, ctx, ctl, method, params);
662
- }, requestMethod);
656
+ // websocket only handler get request
657
+ if (requestMethod == exports.RequestMethod.GET || requestMethod == exports.RequestMethod.ALL) {
658
+ koatty_logger.DefaultLogger.Debug(`Register request mapping: [${requestMethod}] : ["${path}" => ${n}.${method}]`);
659
+ this.SetRouter(path, (ctx) => {
660
+ const ctl = koatty_container.IOCContainer.getInsByClass(ctlClass, [ctx]);
661
+ return Handler(this.app, ctx, ctl, method, params);
662
+ }, requestMethod);
663
+ }
663
664
  }
664
665
  }
665
666
  // Add websocket handler
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-10-31 15:15:33
3
+ * @Date: 2022-11-13 00:13:55
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -268,7 +268,7 @@ const HeadMapping = (path = "/", routerOptions = {}) => {
268
268
  * @Usage:
269
269
  * @Author: richen
270
270
  * @Date: 2021-11-10 16:58:57
271
- * @LastEditTime: 2022-03-15 17:10:46
271
+ * @LastEditTime: 2022-11-01 15:41:24
272
272
  */
273
273
  /**
274
274
  * controller handler
@@ -293,7 +293,8 @@ async function Handler(app, ctx, ctl, method, ctlParams) {
293
293
  args = await getParamter(app, ctx, ctlParams);
294
294
  }
295
295
  // method
296
- return ctl[method](...args);
296
+ const res = await ctl[method](...args);
297
+ ctx.body = res;
297
298
  }
298
299
  /**
299
300
  *
@@ -549,14 +550,11 @@ class HttpRouter {
549
550
  const path = router.path;
550
551
  const requestMethod = router.requestMethod;
551
552
  const params = ctlParams[method];
552
- // websocket only handler get request
553
- if (requestMethod == RequestMethod.GET || requestMethod == RequestMethod.ALL) {
554
- DefaultLogger.Debug(`Register request mapping: [${requestMethod}] : ["${path}" => ${n}.${method}]`);
555
- this.SetRouter(path, (ctx) => {
556
- const ctl = IOCContainer.getInsByClass(ctlClass, [ctx]);
557
- return Handler(this.app, ctx, ctl, method, params);
558
- }, requestMethod);
559
- }
553
+ DefaultLogger.Debug(`Register request mapping: ["${path}" => ${n}.${method}]`);
554
+ this.SetRouter(path, (ctx) => {
555
+ const ctl = IOCContainer.getInsByClass(ctlClass, [ctx]);
556
+ return Handler(this.app, ctx, ctl, method, params);
557
+ }, requestMethod);
560
558
  }
561
559
  }
562
560
  // exp: in middleware
@@ -629,11 +627,14 @@ class WebsocketRouter {
629
627
  const method = router.method;
630
628
  const requestMethod = router.requestMethod;
631
629
  const params = ctlParams[method];
632
- DefaultLogger.Debug(`Register request mapping: ["${path}" => ${n}.${method}]`);
633
- this.SetRouter(path, (ctx) => {
634
- const ctl = IOCContainer.getInsByClass(ctlClass, [ctx]);
635
- return Handler(this.app, ctx, ctl, method, params);
636
- }, requestMethod);
630
+ // websocket only handler get request
631
+ if (requestMethod == RequestMethod.GET || requestMethod == RequestMethod.ALL) {
632
+ DefaultLogger.Debug(`Register request mapping: [${requestMethod}] : ["${path}" => ${n}.${method}]`);
633
+ this.SetRouter(path, (ctx) => {
634
+ const ctl = IOCContainer.getInsByClass(ctlClass, [ctx]);
635
+ return Handler(this.app, ctx, ctl, method, params);
636
+ }, requestMethod);
637
+ }
637
638
  }
638
639
  }
639
640
  // Add websocket handler
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.7.10",
3
+ "version": "1.8.0",
4
4
  "description": "Koatty routing component, adapt to http1/2, websocket, gRPC.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -12,6 +12,7 @@
12
12
  "prepublishOnly": "npm test && npm run build",
13
13
  "prerelease": "npm test && npm run build",
14
14
  "release": "standard-version",
15
+ "release:minor": "npm run release -- --release-as minor",
15
16
  "test": "npm run eslint && jest --passWithNoTests"
16
17
  },
17
18
  "main": "./dist/index.js",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.7.10",
3
+ "version": "1.8.0",
4
4
  "description": "Koatty routing component, adapt to http1/2, websocket, gRPC.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -12,6 +12,7 @@
12
12
  "prepublishOnly": "npm test && npm run build",
13
13
  "prerelease": "npm test && npm run build",
14
14
  "release": "standard-version",
15
+ "release:minor": "npm run release -- --release-as minor",
15
16
  "test": "npm run eslint && jest --passWithNoTests"
16
17
  },
17
18
  "main": "./dist/index.js",