koatty_router 2.0.6 → 2.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/.rollup.config.js CHANGED
@@ -49,9 +49,16 @@ export default [
49
49
  compilerOptions: {
50
50
  declaration: false,
51
51
  declarationMap: false,
52
- module: "ESNext"
52
+ module: "ESNext",
53
+ skipLibCheck: true,
54
+ // 不使用 paths,让 TypeScript 使用 node_modules 中的类型
55
+ // 这样可以避免类型冲突
53
56
  }
54
- }
57
+ },
58
+ // 使用 cache 来提高性能
59
+ useTsconfigDeclarationDir: false,
60
+ // 忽略类型错误,只做转译(类型检查由 build:dts 步骤完成)
61
+ check: false
55
62
  }),
56
63
  terser({
57
64
  compress: {
@@ -1,20 +1,36 @@
1
1
 
2
2
  
3
- > koatty_router@2.0.6 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router
3
+ > koatty_router@2.1.0 build /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router
4
4
  > npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp
5
5
 
6
6
 
7
- > koatty_router@2.0.6 build:js
7
+ > koatty_router@2.1.0 build:js
8
8
  > npx rollup --bundleConfigAsCjs -c .rollup.config.js
9
9
 
10
- 
10
+ ⠙
11
11
  ./src/index.ts → ./dist/index.js, ./dist/index.mjs...
12
- created ./dist/index.js, ./dist/index.mjs in 17.6s
12
+ created ./dist/index.js, ./dist/index.mjs in 12.6s
13
13
  ⠙⠙
14
- > koatty_router@2.0.6 build:dts
15
- > npx tsc && npx api-extractor run --local --verbose
14
+ > koatty_router@2.1.0 build:dts
15
+ > bash ../../scripts/build-dts.sh
16
16
 
17
- ⠙⠙⠙
17
+ 🔨 Building type declarations for koatty-router...
18
+ ⏳ Waiting for dependencies to be ready...
19
+
20
+ 🔍 Checking dependencies: koatty_container, koatty_core, koatty_exception, koatty_graphql, koatty_lib, koatty_logger, koatty_proto, koatty_validation
21
+ ✓ koatty_container type declarations ready
22
+ ✓ koatty_core type declarations ready
23
+ ✓ koatty_exception type declarations ready
24
+ ✓ koatty_graphql type declarations ready
25
+ ✓ koatty_lib type declarations ready
26
+ ✓ koatty_logger type declarations ready
27
+ ✓ koatty_proto type declarations ready
28
+ ✓ koatty_validation type declarations ready
29
+
30
+ ✅ All dependencies ready (waited 2ms)
31
+ 📝 Running TypeScript compiler...
32
+ ⠙⠙📦 Running API Extractor...
33
+ 
18
34
  api-extractor 7.55.2  - https://api-extractor.com/
19
35
  
20
36
  Using configuration from ./api-extractor.json
@@ -22,6 +38,7 @@ Analysis will use the bundled TypeScript version 5.8.2
22
38
  *** The target project appears to use TypeScript 5.9.3 which is newer than the bundled compiler engine; consider upgrading API Extractor.
23
39
  Writing: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/temp/koatty_router.api.json
24
40
  Writing package typings: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/dist/index.d.ts
41
+ Warning: src/RouterComponent.ts:160:38 - (tsdoc-characters-after-block-tag) The token "@OnEvent" looks like a TSDoc tag but contains an invalid character "("; if it is not a tag, use a backslash to escape the "@"
25
42
  Warning: src/params/mapping.ts:33:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
26
43
  Warning: src/params/mapping.ts:34:4 - (tsdoc-undefined-tag) The TSDoc tag "@interface" is not defined in this configuration
27
44
  Warning: src/params/mapping.ts:47:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
@@ -96,17 +113,20 @@ Analysis will use the bundled TypeScript version 5.8.2
96
113
  Warning: src/router/router.ts:54:14 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
97
114
  Warning: src/router/router.ts:55:62 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
98
115
  Warning: src/router/router.ts:55:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
99
- Warning: src/router/router.ts:87:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
100
- Warning: src/router/router.ts:88:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
101
- Warning: src/router/router.ts:89:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
102
- Warning: src/router/router.ts:90:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
103
- Warning: src/router/router.ts:90:31 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
104
- Warning: src/router/router.ts:90:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
105
- Warning: src/router/router.ts:90:18 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
116
+ Warning: src/router/router.ts:89:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration
117
+ Warning: src/router/router.ts:90:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
118
+ Warning: src/router/router.ts:91:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'
119
+ Warning: src/router/router.ts:92:15 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
120
+ Warning: src/router/router.ts:92:66 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
121
+ Warning: src/router/router.ts:92:67 - (tsdoc-escape-right-brace) The "}" character should be escaped using a backslash to avoid confusion with a TSDoc inline tag
122
+ Warning: src/router/router.ts:92:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
123
+ Warning: src/router/router.ts:92:18 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
124
+ Warning: src/router/router.ts:92:19 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"
106
125
 
107
126
  API Extractor completed successfully
108
- ⠙⠙
109
- > koatty_router@2.0.6 build:doc
127
+ ⠙✅ Type declarations built successfully
128
+ ⠙
129
+ > koatty_router@2.1.0 build:doc
110
130
  > npx api-documenter markdown --input temp --output docs/api
111
131
 
112
132
  
@@ -149,17 +169,17 @@ Unsupported block tag: @interface
149
169
  Unsupported block tag: @RequestBody
150
170
  Unsupported block tag: @RequestParam
151
171
  ⠙⠙
152
- > koatty_router@2.0.6 build:cp
172
+ > koatty_router@2.1.0 build:cp
153
173
  > copyfiles package.json LICENSE README.md dist/ && node scripts/postBuild
154
174
 
155
- ✓ Fixed dependencies.koatty_container: workspace:* → ^1.17.1
156
- ✓ Fixed dependencies.koatty_core: workspace:* → ^2.0.11
157
- ✓ Fixed dependencies.koatty_exception: workspace:* → ^2.0.7
158
- ✓ Fixed dependencies.koatty_graphql: workspace:* → ^1.1.1
159
- ✓ Fixed dependencies.koatty_lib: workspace:* → ^1.4.2
160
- ✓ Fixed dependencies.koatty_logger: workspace:* → ^2.3.1
161
- ✓ Fixed dependencies.koatty_proto: workspace:* → ^1.3.2
162
- ✓ Fixed dependencies.koatty_validation: workspace:* → ^1.6.3
175
+ ✓ Fixed dependencies.koatty_container: workspace:* → ^2.0.0
176
+ ✓ Fixed dependencies.koatty_core: workspace:* → ^2.1.0
177
+ ✓ Fixed dependencies.koatty_exception: workspace:* → ^2.1.0
178
+ ✓ Fixed dependencies.koatty_graphql: workspace:* → ^1.1.4
179
+ ✓ Fixed dependencies.koatty_lib: workspace:* → ^1.4.5
180
+ ✓ Fixed dependencies.koatty_logger: workspace:* → ^2.4.0
181
+ ✓ Fixed dependencies.koatty_proto: workspace:* → ^1.3.5
182
+ ✓ Fixed dependencies.koatty_validation: workspace:* → ^2.0.0
163
183
  ✓ Fixed main: ./dist/... → ./index.js
164
184
  ✓ Fixed types: ./dist/... → ./index.d.ts
165
185
  ✓ Fixed exports.require: ./dist/index.js → ./index.js
package/CHANGELOG.md CHANGED
@@ -1,5 +1,64 @@
1
1
  # Changelog
2
2
 
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - build
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - koatty_container@2.0.0
13
+ - koatty_core@2.1.0
14
+ - koatty_exception@2.1.0
15
+ - koatty_logger@2.4.0
16
+ - koatty_validation@2.0.0
17
+
18
+ ## 2.0.9
19
+
20
+ ### Patch Changes
21
+
22
+ - build
23
+ - Updated dependencies
24
+ - koatty_container@1.17.4
25
+ - koatty_core@2.0.14
26
+ - koatty_exception@2.0.10
27
+ - koatty_graphql@1.1.4
28
+ - koatty_lib@1.4.5
29
+ - koatty_logger@2.3.4
30
+ - koatty_proto@1.3.5
31
+ - koatty_validation@1.6.6
32
+
33
+ ## 2.0.8
34
+
35
+ ### Patch Changes
36
+
37
+ - build
38
+ - Updated dependencies
39
+ - koatty_container@1.17.3
40
+ - koatty_core@2.0.13
41
+ - koatty_exception@2.0.9
42
+ - koatty_graphql@1.1.3
43
+ - koatty_lib@1.4.4
44
+ - koatty_logger@2.3.3
45
+ - koatty_proto@1.3.4
46
+ - koatty_validation@1.6.5
47
+
48
+ ## 2.0.7
49
+
50
+ ### Patch Changes
51
+
52
+ - Updated dependencies
53
+ - koatty_container@1.17.2
54
+ - koatty_graphql@1.1.2
55
+ - koatty_lib@1.4.3
56
+ - koatty_logger@2.3.2
57
+ - koatty_proto@1.3.3
58
+ - koatty_validation@1.6.4
59
+ - koatty_core@2.0.12
60
+ - koatty_exception@2.0.8
61
+
3
62
  ## 2.0.6
4
63
 
5
64
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,13 +1,12 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2026-01-28 16:08:27
3
+ * @Date: 2026-01-31 09:50:30
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
8
  import { Application } from 'koatty_container';
9
- import { IPlugin } from 'koatty_core';
10
- import { IPluginCapability } from 'koatty_core';
9
+ import { IComponent } from 'koatty_core';
11
10
  import { KoattyApplication } from 'koatty_core';
12
11
  import { KoattyContext } from 'koatty_core';
13
12
  import { KoattyNext } from 'koatty_core';
@@ -214,9 +213,12 @@ export declare type MiddlewareFunction = <T = unknown>(ctx: KoattyContext, next:
214
213
  * @export
215
214
  * @param {KoattyApplication} app
216
215
  * @param {RouterOptions} options
217
- * @returns {*} {KoattyRouter}
216
+ * @returns {*} {{ router: KoattyRouter, factory: RouterFactory }}
218
217
  */
219
- export declare function NewRouter(app: KoattyApplication, opt?: RouterOptions): KoattyRouter;
218
+ export declare function NewRouter(app: KoattyApplication, opt?: RouterOptions): {
219
+ router: KoattyRouter;
220
+ factory: RouterFactory;
221
+ };
220
222
 
221
223
  /**
222
224
  * Routes HTTP OPTIONS requests to the specified path.
@@ -359,6 +361,42 @@ export declare enum RequestMethod {
359
361
  */
360
362
  export declare function RequestParam(): ParameterDecorator;
361
363
 
364
+ /**
365
+ * Router Component
366
+ * Responsible for initializing and managing routing
367
+ *
368
+ * Implements IComponent interface (base interface)
369
+ *
370
+ * Event bindings:
371
+ * - loadRouter: Initialize router
372
+ * - appStop: Cleanup router resources
373
+ */
374
+ export declare class RouterComponent implements IComponent {
375
+ events: Record<string, any>;
376
+ /**
377
+ * Initialize router and load routes
378
+ *
379
+ * This method handles the complete router initialization:
380
+ * 1. Create router instance(s) for configured protocol(s)
381
+ * 2. Bind router to app.router
382
+ * 3. Load controller routes into router
383
+ */
384
+ initRouter(app: KoattyApplication): Promise<void>;
385
+ /**
386
+ * Load controller routes into router
387
+ *
388
+ * @param app - Koatty application instance
389
+ */
390
+ run(app: KoattyApplication): Promise<void>;
391
+ /**
392
+ * Cleanup router resources on app stop
393
+ *
394
+ * NOTE: Original app.once("appStop", ...) listener in router.ts
395
+ * is now unified to be handled by @OnEvent(AppEvent.appStop) decorator
396
+ */
397
+ cleanup(_app: KoattyApplication): Promise<void>;
398
+ }
399
+
362
400
  /**
363
401
  * Router constructor type
364
402
  */
@@ -614,38 +652,32 @@ export declare interface RouterOptions {
614
652
  *
615
653
  * @example
616
654
  * ```typescript
617
- * // WebSocket 配置
618
- * ext: {
619
- * maxFrameSize: 1024 * 1024,
620
- * heartbeatInterval: 15000,
621
- * maxConnections: 1000
622
- * }
623
- *
624
- * // gRPC 配置
625
655
  * ext: {
626
- * protoFile: "./proto/service.proto",
627
- * poolSize: 10,
628
- * streamConfig: { maxConcurrentStreams: 50 }
629
- * }
630
- *
631
- * // GraphQL 配置
632
- * ext: {
633
- * schemaFile: "./schema/schema.graphql",
634
- * playground: true
656
+ * http: {},
657
+ * grpc: {
658
+ * protoFile: "./proto/service.proto",
659
+ * poolSize: 10,
660
+ * streamConfig: { maxConcurrentStreams: 50 }
661
+ * },
662
+ * graphql: {
663
+ * schemaFile: "./resource/graphql/schema.graphql",
664
+ * // Optional: Enable HTTP/2 with SSL for GraphQL
665
+ * // keyFile: "./ssl/server.key",
666
+ * // crtFile: "./ssl/server.crt",
667
+ * // ssl: { mode: 'auto', allowHTTP1: true },
668
+ * // http2: { maxConcurrentStreams: 100 }
669
+ * },
670
+ * ws: {
671
+ * maxFrameSize: 1024 * 1024,
672
+ * heartbeatInterval: 15000,
673
+ * maxConnections: 1000
674
+ * }
635
675
  * }
636
676
  * ```
637
677
  */
638
678
  ext?: Record<string, any>;
639
679
  }
640
680
 
641
- export declare class RouterPlugin implements IPlugin {
642
- readonly provides: IPluginCapability[];
643
- readonly events: {
644
- beforeRouterLoad: (app: KoattyApplication) => Promise<void>;
645
- };
646
- uninstall(_app: KoattyApplication): Promise<void>;
647
- }
648
-
649
681
  /**
650
682
  * gRPC 流配置
651
683
  */