koatty_router 1.13.2 → 1.14.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,13 @@
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.14.0](https://github.com/koatty/koatty_router/compare/v1.13.2...v1.14.0) (2025-03-15)
6
+
7
+
8
+ ### Features
9
+
10
+ * enhance GraphQL router configuration and add ctlPath to RouterMetadata ([71c96a9](https://github.com/koatty/koatty_router/commit/71c96a930ca492811400f8d6e974abcc81eb2d18))
11
+
5
12
  ### [1.13.2](https://github.com/koatty/koatty_router/compare/v1.13.1...v1.13.2) (2025-03-15)
6
13
 
7
14
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-03-15 16:45:54
3
+ * @Date: 2025-03-15 17:11:49
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: 2025-03-15 16:45:42
3
+ * @Date: 2025-03-15 17:11:38
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -395,7 +395,7 @@ const HeadMapping = (path = "/", routerOptions) => {
395
395
  * @Usage:
396
396
  * @Author: richen
397
397
  * @Date: 2023-12-09 12:02:29
398
- * @LastEditTime: 2025-03-15 16:41:41
398
+ * @LastEditTime: 2025-03-15 17:07:30
399
399
  * @License: BSD (3-Clause)
400
400
  * @Copyright (c): <richenlin(at)gmail.com>
401
401
  */
@@ -461,7 +461,8 @@ function injectRouter(app, target, protocol = 'http') {
461
461
  for (const val of rmetaData[metaKey]) {
462
462
  const tmp = {
463
463
  ...val,
464
- path: `${options.path}${val.path}`.replace("//", "/")
464
+ path: `${options.path}${val.path}`.replace("//", "/"),
465
+ ctlPath: options.path,
465
466
  };
466
467
  router[`${tmp.path}||${tmp.requestMethod}`] = tmp;
467
468
  }
@@ -702,7 +703,7 @@ function getControllerPath(className) {
702
703
  * @Usage:
703
704
  * @Author: richen
704
705
  * @Date: 2025-03-12 14:54:42
705
- * @LastEditTime: 2025-03-14 18:15:15
706
+ * @LastEditTime: 2025-03-15 17:06:54
706
707
  * @License: BSD (3-Clause)
707
708
  * @Copyright (c): <richenlin(at)gmail.com>
708
709
  */
@@ -777,12 +778,12 @@ class GraphQLRouter {
777
778
  const ctl = koatty_container.IOCContainer.getInsByClass(ctlClass, [ctx]);
778
779
  return Handler(app, ctx, ctl, method, params, Object.values(args));
779
780
  };
781
+ this.SetRouter(router.ctlPath || "/graphql", {
782
+ schema,
783
+ implementation: rootValue
784
+ });
780
785
  }
781
786
  }
782
- this.SetRouter("/graphql", {
783
- schema,
784
- implementation: rootValue
785
- });
786
787
  // exp: in middleware
787
788
  // app.Router.SetRouter('/xxx', (ctx: Koa.KoattyContext): any => {...}, 'GET')
788
789
  app.use(this.router.routes()).use(this.router.allowedMethods());
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-03-15 16:45:42
3
+ * @Date: 2025-03-15 17:11:38
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -375,7 +375,7 @@ const HeadMapping = (path = "/", routerOptions) => {
375
375
  * @Usage:
376
376
  * @Author: richen
377
377
  * @Date: 2023-12-09 12:02:29
378
- * @LastEditTime: 2025-03-15 16:41:41
378
+ * @LastEditTime: 2025-03-15 17:07:30
379
379
  * @License: BSD (3-Clause)
380
380
  * @Copyright (c): <richenlin(at)gmail.com>
381
381
  */
@@ -441,7 +441,8 @@ function injectRouter(app, target, protocol = 'http') {
441
441
  for (const val of rmetaData[metaKey]) {
442
442
  const tmp = {
443
443
  ...val,
444
- path: `${options.path}${val.path}`.replace("//", "/")
444
+ path: `${options.path}${val.path}`.replace("//", "/"),
445
+ ctlPath: options.path,
445
446
  };
446
447
  router[`${tmp.path}||${tmp.requestMethod}`] = tmp;
447
448
  }
@@ -682,7 +683,7 @@ function getControllerPath(className) {
682
683
  * @Usage:
683
684
  * @Author: richen
684
685
  * @Date: 2025-03-12 14:54:42
685
- * @LastEditTime: 2025-03-14 18:15:15
686
+ * @LastEditTime: 2025-03-15 17:06:54
686
687
  * @License: BSD (3-Clause)
687
688
  * @Copyright (c): <richenlin(at)gmail.com>
688
689
  */
@@ -757,12 +758,12 @@ class GraphQLRouter {
757
758
  const ctl = IOCContainer.getInsByClass(ctlClass, [ctx]);
758
759
  return Handler(app, ctx, ctl, method, params, Object.values(args));
759
760
  };
761
+ this.SetRouter(router.ctlPath || "/graphql", {
762
+ schema,
763
+ implementation: rootValue
764
+ });
760
765
  }
761
766
  }
762
- this.SetRouter("/graphql", {
763
- schema,
764
- implementation: rootValue
765
- });
766
767
  // exp: in middleware
767
768
  // app.Router.SetRouter('/xxx', (ctx: Koa.KoattyContext): any => {...}, 'GET')
768
769
  app.use(this.router.routes()).use(this.router.allowedMethods());
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.13.2",
3
+ "version": "1.14.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",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty_router",
3
- "version": "1.13.2",
3
+ "version": "1.14.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",