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 +9 -2
- package/.turbo/turbo-build.log +45 -25
- package/CHANGELOG.md +59 -0
- package/dist/index.d.ts +62 -30
- package/dist/index.js +1918 -1869
- package/dist/index.mjs +2157 -2108
- package/dist/package.json +10 -10
- package/package.json +3 -3
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: {
|
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,20 +1,36 @@
|
|
|
1
1
|
|
|
2
2
|
|
|
3
|
-
> koatty_router@2.0
|
|
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
|
|
7
|
+
> koatty_router@2.1.0 build:js
|
|
8
8
|
> npx rollup --bundleConfigAsCjs -c .rollup.config.js
|
|
9
9
|
|
|
10
|
-
[1G[0K[1G[0K[36m
|
|
10
|
+
[1G[0K[1G[0K⠙[1G[0K[36m
|
|
11
11
|
[1m./src/index.ts[22m → [1m./dist/index.js, ./dist/index.mjs[22m...[39m
|
|
12
|
-
[32mcreated [1m./dist/index.js, ./dist/index.mjs[22m in [
|
|
12
|
+
[32mcreated [1m./dist/index.js, ./dist/index.mjs[22m in [1m12.6s[22m[39m
|
|
13
13
|
[1G[0K⠙[1G[0K[1G[0K⠙[1G[0K
|
|
14
|
-
> koatty_router@2.0
|
|
15
|
-
>
|
|
14
|
+
> koatty_router@2.1.0 build:dts
|
|
15
|
+
> bash ../../scripts/build-dts.sh
|
|
16
16
|
|
|
17
|
-
[1G[0K
|
|
17
|
+
[1G[0K🔨 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
|
+
[1G[0K⠙[1G[0K[1G[0K⠙[1G[0K📦 Running API Extractor...
|
|
33
|
+
[1G[0K
|
|
18
34
|
[1mapi-extractor 7.55.2 [36m - https://api-extractor.com/[39m
|
|
19
35
|
[22m
|
|
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
|
[36mWriting: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/temp/koatty_router.api.json[39m
|
|
24
40
|
[36mWriting package typings: /Users/richen/Workspace/nodejs/koatty-monorepo/packages/koatty-router/dist/index.d.ts[39m
|
|
41
|
+
[33mWarning: 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 "@"[39m
|
|
25
42
|
[33mWarning: src/params/mapping.ts:33:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration[39m
|
|
26
43
|
[33mWarning: src/params/mapping.ts:34:4 - (tsdoc-undefined-tag) The TSDoc tag "@interface" is not defined in this configuration[39m
|
|
27
44
|
[33mWarning: src/params/mapping.ts:47:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration[39m
|
|
@@ -96,17 +113,20 @@ Analysis will use the bundled TypeScript version 5.8.2
|
|
|
96
113
|
[33mWarning: src/router/router.ts:54:14 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"[39m
|
|
97
114
|
[33mWarning: 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[39m
|
|
98
115
|
[33mWarning: src/router/router.ts:55:17 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"[39m
|
|
99
|
-
[33mWarning: src/router/router.ts:
|
|
100
|
-
[33mWarning: src/router/router.ts:
|
|
101
|
-
[33mWarning: src/router/router.ts:
|
|
102
|
-
[33mWarning: src/router/router.ts:
|
|
103
|
-
[33mWarning: src/router/router.ts:
|
|
104
|
-
[33mWarning: src/router/router.ts:
|
|
105
|
-
[33mWarning: src/router/router.ts:
|
|
116
|
+
[33mWarning: src/router/router.ts:89:4 - (tsdoc-undefined-tag) The TSDoc tag "@export" is not defined in this configuration[39m
|
|
117
|
+
[33mWarning: src/router/router.ts:90:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'[39m
|
|
118
|
+
[33mWarning: src/router/router.ts:91:11 - (tsdoc-param-tag-with-invalid-type) The @param block should not include a JSDoc-style '{type}'[39m
|
|
119
|
+
[33mWarning: 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[39m
|
|
120
|
+
[33mWarning: 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[39m
|
|
121
|
+
[33mWarning: 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[39m
|
|
122
|
+
[33mWarning: src/router/router.ts:92:13 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"[39m
|
|
123
|
+
[33mWarning: src/router/router.ts:92:18 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"[39m
|
|
124
|
+
[33mWarning: src/router/router.ts:92:19 - (tsdoc-malformed-inline-tag) Expecting a TSDoc tag starting with "{@"[39m
|
|
106
125
|
|
|
107
126
|
API Extractor completed successfully
|
|
108
|
-
[1G[0K⠙[1G[0K
|
|
109
|
-
|
|
127
|
+
[1G[0K⠙[1G[0K✅ Type declarations built successfully
|
|
128
|
+
[1G[0K⠙[1G[0K
|
|
129
|
+
> koatty_router@2.1.0 build:doc
|
|
110
130
|
> npx api-documenter markdown --input temp --output docs/api
|
|
111
131
|
|
|
112
132
|
[1G[0K[1G[0K
|
|
@@ -149,17 +169,17 @@ Unsupported block tag: @interface
|
|
|
149
169
|
Unsupported block tag: @RequestBody
|
|
150
170
|
Unsupported block tag: @RequestParam
|
|
151
171
|
[1G[0K⠙[1G[0K[1G[0K⠙[1G[0K
|
|
152
|
-
> koatty_router@2.0
|
|
172
|
+
> koatty_router@2.1.0 build:cp
|
|
153
173
|
> copyfiles package.json LICENSE README.md dist/ && node scripts/postBuild
|
|
154
174
|
|
|
155
|
-
[1G[0K✓ Fixed dependencies.koatty_container: workspace:* → ^
|
|
156
|
-
✓ Fixed dependencies.koatty_core: workspace:* → ^2.0
|
|
157
|
-
✓ Fixed dependencies.koatty_exception: workspace:* → ^2.0
|
|
158
|
-
✓ Fixed dependencies.koatty_graphql: workspace:* → ^1.1.
|
|
159
|
-
✓ Fixed dependencies.koatty_lib: workspace:* → ^1.4.
|
|
160
|
-
✓ Fixed dependencies.koatty_logger: workspace:* → ^2.
|
|
161
|
-
✓ Fixed dependencies.koatty_proto: workspace:* → ^1.3.
|
|
162
|
-
✓ Fixed dependencies.koatty_validation: workspace:* → ^
|
|
175
|
+
[1G[0K✓ 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-
|
|
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 {
|
|
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):
|
|
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
|
-
*
|
|
627
|
-
*
|
|
628
|
-
*
|
|
629
|
-
*
|
|
630
|
-
*
|
|
631
|
-
*
|
|
632
|
-
*
|
|
633
|
-
*
|
|
634
|
-
*
|
|
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
|
*/
|