koatty 3.12.0 → 3.13.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 +27 -12
- package/CHANGELOG.md +1871 -185
- package/README.md +15 -4
- package/dist/README.md +15 -4
- package/dist/index.d.ts +56 -26
- package/dist/index.js +465 -750
- package/dist/index.mjs +405 -708
- package/dist/package.json +10 -11
- package/package.json +10 -11
package/README.md
CHANGED
@@ -24,8 +24,11 @@ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework
|
|
24
24
|
* `@ExceptionHandler()` Register global exception handling.✔️
|
25
25
|
* Graceful shutdown and pre-exit event.✔️
|
26
26
|
* Supports custom decorators, bound to app events for execution.✔️
|
27
|
-
* GraphQL
|
28
|
-
* OpenTelemetry .
|
27
|
+
* GraphQL integration is available. ✔️
|
28
|
+
* Full-stack tracing capability through OpenTelemetry . ✔️
|
29
|
+
* Middleware can be bound to controllers and their method routes.✔️
|
30
|
+
* gRPC streaming is now supported. ✔️
|
31
|
+
* Added support for Swagger OpenAPI 3.0. 💪
|
29
32
|
|
30
33
|
|
31
34
|
## Core Features ✨
|
@@ -35,7 +38,7 @@ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework
|
|
35
38
|
// config/config.ts
|
36
39
|
export default {
|
37
40
|
...
|
38
|
-
protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
|
41
|
+
protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss' | 'graphql'
|
39
42
|
...
|
40
43
|
}
|
41
44
|
```
|
@@ -53,6 +56,8 @@ export class UserService {
|
|
53
56
|
export class IndexController {
|
54
57
|
app: App;
|
55
58
|
ctx: KoattyContext;
|
59
|
+
@Config("protocol")
|
60
|
+
conf: { protocol: string };
|
56
61
|
...
|
57
62
|
|
58
63
|
@Autowired()
|
@@ -79,7 +84,13 @@ export class LogAspect implements IAspect {
|
|
79
84
|
// Apply aspect to controller
|
80
85
|
@Controller()
|
81
86
|
@BeforeEach(LogAspect)
|
82
|
-
export class UserController {
|
87
|
+
export class UserController {
|
88
|
+
...
|
89
|
+
@After(LogAspect)
|
90
|
+
test() {
|
91
|
+
...
|
92
|
+
}
|
93
|
+
}
|
83
94
|
```
|
84
95
|
|
85
96
|
### 🔌 Plugin System
|
package/dist/README.md
CHANGED
@@ -24,8 +24,11 @@ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework
|
|
24
24
|
* `@ExceptionHandler()` Register global exception handling.✔️
|
25
25
|
* Graceful shutdown and pre-exit event.✔️
|
26
26
|
* Supports custom decorators, bound to app events for execution.✔️
|
27
|
-
* GraphQL
|
28
|
-
* OpenTelemetry .
|
27
|
+
* GraphQL integration is available. ✔️
|
28
|
+
* Full-stack tracing capability through OpenTelemetry . ✔️
|
29
|
+
* Middleware can be bound to controllers and their method routes.✔️
|
30
|
+
* gRPC streaming is now supported. ✔️
|
31
|
+
* Added support for Swagger OpenAPI 3.0. 💪
|
29
32
|
|
30
33
|
|
31
34
|
## Core Features ✨
|
@@ -35,7 +38,7 @@ Koa2 + Typescript + IOC = koatty. **Koatty** is a progressive Node.js framework
|
|
35
38
|
// config/config.ts
|
36
39
|
export default {
|
37
40
|
...
|
38
|
-
protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss'
|
41
|
+
protocol: "grpc", // Server protocol 'http' | 'https' | 'http2' | 'grpc' | 'ws' | 'wss' | 'graphql'
|
39
42
|
...
|
40
43
|
}
|
41
44
|
```
|
@@ -53,6 +56,8 @@ export class UserService {
|
|
53
56
|
export class IndexController {
|
54
57
|
app: App;
|
55
58
|
ctx: KoattyContext;
|
59
|
+
@Config("protocol")
|
60
|
+
conf: { protocol: string };
|
56
61
|
...
|
57
62
|
|
58
63
|
@Autowired()
|
@@ -79,7 +84,13 @@ export class LogAspect implements IAspect {
|
|
79
84
|
// Apply aspect to controller
|
80
85
|
@Controller()
|
81
86
|
@BeforeEach(LogAspect)
|
82
|
-
export class UserController {
|
87
|
+
export class UserController {
|
88
|
+
...
|
89
|
+
@After(LogAspect)
|
90
|
+
test() {
|
91
|
+
...
|
92
|
+
}
|
93
|
+
}
|
83
94
|
```
|
84
95
|
|
85
96
|
### 🔌 Plugin System
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2025-
|
3
|
+
* @Date: 2025-04-19 23:06:57
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -13,58 +13,88 @@ import { KoattyApplication } from 'koatty_core';
|
|
13
13
|
import { Logger as Logger_2 } from 'koatty_logger';
|
14
14
|
|
15
15
|
/**
|
16
|
-
*
|
17
|
-
*
|
16
|
+
* Bind event hook to target class.
|
17
|
+
*
|
18
|
+
* @param eventName - The application event name to bind
|
19
|
+
* @param eventFunc - The event hook function to be executed
|
20
|
+
* @param target - The target class to bind the event hook
|
21
|
+
* @returns {*}
|
22
|
+
* @throws Error if the decorated class does not inherit from Koatty.
|
23
|
+
* @example
|
24
|
+
* ```typescript
|
18
25
|
* export function TestDecorator(): ClassDecorator {
|
19
|
-
*
|
20
|
-
*
|
26
|
+
* return (target: Function) => {
|
27
|
+
* BindEventHook(AppEvent.appBoot, (app: KoattyApplication) => {
|
21
28
|
* // todo
|
22
29
|
* return Promise.resolve();
|
23
30
|
* }, target)
|
24
31
|
* }
|
25
32
|
* }
|
26
|
-
* @param {AppEvent} eventName
|
27
|
-
* @param {EventHookFunc} eventFunc
|
28
|
-
* @param {any} target
|
29
|
-
* @return {*}
|
30
33
|
*/
|
31
34
|
export declare function BindEventHook(eventName: AppEvent, eventFunc: EventHookFunc, target: any): void;
|
32
35
|
|
33
36
|
/**
|
34
|
-
* Bootstrap application
|
37
|
+
* Bootstrap decorator for Koatty application class.
|
38
|
+
*
|
39
|
+
* @param bootFunc Optional function to execute during bootstrap process
|
40
|
+
* @returns ClassDecorator
|
41
|
+
* @throws Error if target class does not inherit from Koatty
|
35
42
|
*
|
36
|
-
* @
|
37
|
-
*
|
38
|
-
* @
|
43
|
+
* @example
|
44
|
+
* ```ts
|
45
|
+
* @Bootstrap()
|
46
|
+
* export class App extends Koatty {
|
47
|
+
* // ...
|
48
|
+
* }
|
49
|
+
* ```
|
39
50
|
*/
|
40
51
|
export declare function Bootstrap(bootFunc?: Function): ClassDecorator;
|
41
52
|
|
42
53
|
/**
|
43
|
-
*
|
54
|
+
* Component scan decorator for Koatty application.
|
55
|
+
* Scans the specified path(s) for components and registers them in the IOC container.
|
44
56
|
*
|
45
|
-
* @
|
46
|
-
* @
|
47
|
-
* @
|
57
|
+
* @param {string | string[]} [scanPath] - The path or array of paths to scan for components
|
58
|
+
* @returns {ClassDecorator} A class decorator that enables component scanning
|
59
|
+
* @throws {Error} If the decorated class does not inherit from Koatty
|
60
|
+
* @example
|
61
|
+
* ```typescript
|
62
|
+
* @ComponentScan()
|
63
|
+
* export class App extends Koatty {
|
64
|
+
* // ...
|
65
|
+
* }
|
66
|
+
* ```
|
48
67
|
*/
|
49
68
|
export declare function ComponentScan(scanPath?: string | string[]): ClassDecorator;
|
50
69
|
|
51
70
|
export { Config }
|
52
71
|
|
53
72
|
/**
|
54
|
-
*
|
73
|
+
* Configuration scan decorator, used to scan and load configuration files.
|
55
74
|
*
|
56
|
-
* @
|
57
|
-
* @
|
58
|
-
* @
|
75
|
+
* @param scanPath - The path or array of paths to scan for configuration files. If not provided, defaults to empty string.
|
76
|
+
* @returns A class decorator function that registers configuration scan metadata.
|
77
|
+
* @throws Error if the decorated class does not inherit from Koatty.
|
78
|
+
* @example
|
79
|
+
* ```typescript
|
80
|
+
* @ConfigurationScan()
|
81
|
+
* export class App extends Koatty {
|
82
|
+
* // ...
|
83
|
+
* }
|
59
84
|
*/
|
60
85
|
export declare function ConfigurationScan(scanPath?: string | string[]): ClassDecorator;
|
61
86
|
|
62
87
|
/**
|
63
|
-
*
|
64
|
-
*
|
65
|
-
* @
|
66
|
-
* @
|
67
|
-
* @
|
88
|
+
* Decorator function for bootstrapping a Koatty application.
|
89
|
+
*
|
90
|
+
* @param bootFunc Optional function to be executed during bootstrap process
|
91
|
+
* @returns A decorator function that validates and executes the bootstrap process
|
92
|
+
* @throws Error if the target class does not inherit from Koatty
|
93
|
+
*
|
94
|
+
* @example
|
95
|
+
* ```typescript
|
96
|
+
* app = await ExecBootStrap()(App);
|
97
|
+
* ```
|
68
98
|
*/
|
69
99
|
export declare function ExecBootStrap(bootFunc?: Function): (target: any) => Promise<KoattyApplication>;
|
70
100
|
|