koatty 3.11.0 → 3.11.1
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 +7 -0
- package/README.md +12 -8
- package/dist/README.md +12 -8
- package/dist/index.d.ts +11 -3
- package/dist/index.js +19 -4
- package/dist/index.mjs +19 -5
- package/dist/package.json +1 -1
- package/package.json +1 -1
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
|
+
### [3.11.1](https://github.com/thinkkoa/koatty/compare/v3.11.0...v3.11.1) (2024-01-03)
|
6
|
+
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* aspect interface ([03b1884](https://github.com/thinkkoa/koatty/commit/03b188401d694ca116c58c71fc0270da8c163cc1))
|
11
|
+
|
5
12
|
## [3.11.0](https://github.com/thinkkoa/koatty/compare/v3.10.4...v3.11.0) (2024-01-03)
|
6
13
|
|
7
14
|
|
package/README.md
CHANGED
@@ -57,37 +57,41 @@ npm start
|
|
57
57
|
default Controller:
|
58
58
|
|
59
59
|
```javascript
|
60
|
-
import { Controller,
|
61
|
-
PostMapping, RequestMapping, RequestMethod, Valid } from "koatty";
|
60
|
+
import { Controller, Autowired, GetMapping, RequestBody, PathVariable,
|
61
|
+
PostMapping, RequestMapping, RequestMethod, Valid, Output } from "koatty";
|
62
62
|
import { TestDTO } from "../model/dto/TestDTO";
|
63
63
|
import { TestService } from "../service/TestService";
|
64
64
|
import { App } from "../App";
|
65
65
|
|
66
66
|
@Controller()
|
67
|
-
export class IndexController
|
67
|
+
export class IndexController {
|
68
68
|
app: App;
|
69
69
|
|
70
70
|
@Autowired()
|
71
71
|
private testService: TestService;
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
/**
|
74
|
+
* constructor
|
75
|
+
*
|
76
|
+
*/
|
77
|
+
constructor(ctx: KoattyContext) {
|
78
|
+
this.ctx = ctx;
|
75
79
|
}
|
76
80
|
|
77
81
|
@RequestMapping("/:name", RequestMethod.ALL)
|
78
82
|
async default(@PathVariable("name") @Valid("IsNotEmpty") name: string) {
|
79
83
|
try {
|
80
84
|
const info = await this.testService.sayHello(name);
|
81
|
-
return
|
85
|
+
return Output.ok(this.ctx, "success", info);
|
82
86
|
} catch (err: Error) {
|
83
|
-
return
|
87
|
+
return Output.fail(this.ctx, err.message));
|
84
88
|
}
|
85
89
|
}
|
86
90
|
|
87
91
|
@PostMapping("/test")
|
88
92
|
@Validated() //need DTOClass
|
89
93
|
test(@RequestParam() params: TestDTO) {
|
90
|
-
return
|
94
|
+
return Output.ok(this.ctx, "test", params);
|
91
95
|
}
|
92
96
|
}
|
93
97
|
```
|
package/dist/README.md
CHANGED
@@ -57,37 +57,41 @@ npm start
|
|
57
57
|
default Controller:
|
58
58
|
|
59
59
|
```javascript
|
60
|
-
import { Controller,
|
61
|
-
PostMapping, RequestMapping, RequestMethod, Valid } from "koatty";
|
60
|
+
import { Controller, Autowired, GetMapping, RequestBody, PathVariable,
|
61
|
+
PostMapping, RequestMapping, RequestMethod, Valid, Output } from "koatty";
|
62
62
|
import { TestDTO } from "../model/dto/TestDTO";
|
63
63
|
import { TestService } from "../service/TestService";
|
64
64
|
import { App } from "../App";
|
65
65
|
|
66
66
|
@Controller()
|
67
|
-
export class IndexController
|
67
|
+
export class IndexController {
|
68
68
|
app: App;
|
69
69
|
|
70
70
|
@Autowired()
|
71
71
|
private testService: TestService;
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
/**
|
74
|
+
* constructor
|
75
|
+
*
|
76
|
+
*/
|
77
|
+
constructor(ctx: KoattyContext) {
|
78
|
+
this.ctx = ctx;
|
75
79
|
}
|
76
80
|
|
77
81
|
@RequestMapping("/:name", RequestMethod.ALL)
|
78
82
|
async default(@PathVariable("name") @Valid("IsNotEmpty") name: string) {
|
79
83
|
try {
|
80
84
|
const info = await this.testService.sayHello(name);
|
81
|
-
return
|
85
|
+
return Output.ok(this.ctx, "success", info);
|
82
86
|
} catch (err: Error) {
|
83
|
-
return
|
87
|
+
return Output.fail(this.ctx, err.message));
|
84
88
|
}
|
85
89
|
}
|
86
90
|
|
87
91
|
@PostMapping("/test")
|
88
92
|
@Validated() //need DTOClass
|
89
93
|
test(@RequestParam() params: TestDTO) {
|
90
|
-
return
|
94
|
+
return Output.ok(this.ctx, "test", params);
|
91
95
|
}
|
92
96
|
}
|
93
97
|
```
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2024-01-
|
3
|
+
* @Date: 2024-01-04 07:59:26
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -9,10 +9,12 @@ import { AppEvent } from 'koatty_core';
|
|
9
9
|
import { Config } from 'koatty_config';
|
10
10
|
import { EventHookFunc } from 'koatty_core';
|
11
11
|
import { Helper } from 'koatty_lib';
|
12
|
+
import { IAspect } from 'koatty_container';
|
12
13
|
import { Koatty } from 'koatty_core';
|
13
14
|
import { KoattyContext } from 'koatty_core';
|
14
15
|
import { Logger as Logger_2 } from 'koatty_logger';
|
15
16
|
import { Middleware as Middleware_2 } from 'koa';
|
17
|
+
import { Next } from 'koa';
|
16
18
|
import { Value } from 'koatty_config';
|
17
19
|
|
18
20
|
/**
|
@@ -192,9 +194,16 @@ export declare interface IController {
|
|
192
194
|
* Interface for Middleware
|
193
195
|
*/
|
194
196
|
export declare interface IMiddleware {
|
195
|
-
run: (options: any, app: Koatty) =>
|
197
|
+
run: (options: any, app: Koatty) => (ctx: KoattyContext, next: Next) => Promise<any>;
|
196
198
|
}
|
197
199
|
|
200
|
+
/**
|
201
|
+
* check is implements Aspect Interface
|
202
|
+
* @param cls
|
203
|
+
* @returns
|
204
|
+
*/
|
205
|
+
export declare function implementsAspectInterface(cls: any): cls is IAspect;
|
206
|
+
|
198
207
|
/**
|
199
208
|
* check is implements Controller Interface
|
200
209
|
* @param cls
|
@@ -235,7 +244,6 @@ export declare interface IPlugin {
|
|
235
244
|
*/
|
236
245
|
export declare interface IService {
|
237
246
|
readonly app: Koatty;
|
238
|
-
init(...arg: any[]): void;
|
239
247
|
}
|
240
248
|
|
241
249
|
/**
|
package/dist/index.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2024-01-
|
3
|
+
* @Date: 2024-01-04 07:59:12
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -171,7 +171,7 @@ function SetLogger(app, config) {
|
|
171
171
|
* @Usage:
|
172
172
|
* @Author: richen
|
173
173
|
* @Date: 2023-12-09 21:56:32
|
174
|
-
* @LastEditTime: 2024-01-
|
174
|
+
* @LastEditTime: 2024-01-04 07:43:03
|
175
175
|
* @License: BSD (3-Clause)
|
176
176
|
* @Copyright (c): <richenlin(at)gmail.com>
|
177
177
|
*/
|
@@ -278,6 +278,14 @@ function implementsServiceInterface(cls) {
|
|
278
278
|
function implementsPluginInterface(cls) {
|
279
279
|
return 'run' in cls && koatty_lib.Helper.isFunction(cls.run);
|
280
280
|
}
|
281
|
+
/**
|
282
|
+
* check is implements Aspect Interface
|
283
|
+
* @param cls
|
284
|
+
* @returns
|
285
|
+
*/
|
286
|
+
function implementsAspectInterface(cls) {
|
287
|
+
return 'app' in cls && 'run' in cls && koatty_lib.Helper.isFunction(cls.run);
|
288
|
+
}
|
281
289
|
|
282
290
|
/*
|
283
291
|
* @Description: framework constants
|
@@ -305,7 +313,7 @@ https://github.com/koatty
|
|
305
313
|
* @Usage:
|
306
314
|
* @Author: richen
|
307
315
|
* @Date: 2023-12-09 22:55:49
|
308
|
-
* @LastEditTime: 2024-01-
|
316
|
+
* @LastEditTime: 2024-01-04 05:52:31
|
309
317
|
* @License: BSD (3-Clause)
|
310
318
|
* @Copyright (c): <richenlin(at)gmail.com>
|
311
319
|
*/
|
@@ -675,6 +683,12 @@ class Loader {
|
|
675
683
|
}
|
676
684
|
pluginList.push(item.id);
|
677
685
|
}
|
686
|
+
if (item.id && (item.id).endsWith("Aspect")) {
|
687
|
+
const ctl = koatty_container.IOCContainer.getInsByClass(item.target);
|
688
|
+
if (!implementsAspectInterface(ctl)) {
|
689
|
+
throw Error(`The aspect ${item.id} must implements interface 'IAspect'.`);
|
690
|
+
}
|
691
|
+
}
|
678
692
|
}
|
679
693
|
});
|
680
694
|
// load plugin config
|
@@ -702,7 +716,7 @@ class Loader {
|
|
702
716
|
}
|
703
717
|
}
|
704
718
|
|
705
|
-
var version = "3.11.
|
719
|
+
var version = "3.11.1";
|
706
720
|
var engines = {
|
707
721
|
node: ">12.0.0"
|
708
722
|
};
|
@@ -1156,6 +1170,7 @@ exports.Middleware = Middleware;
|
|
1156
1170
|
exports.Output = Output;
|
1157
1171
|
exports.Plugin = Plugin;
|
1158
1172
|
exports.Service = Service;
|
1173
|
+
exports.implementsAspectInterface = implementsAspectInterface;
|
1159
1174
|
exports.implementsControllerInterface = implementsControllerInterface;
|
1160
1175
|
exports.implementsMiddlewareInterface = implementsMiddlewareInterface;
|
1161
1176
|
exports.implementsPluginInterface = implementsPluginInterface;
|
package/dist/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2024-01-
|
3
|
+
* @Date: 2024-01-04 07:59:12
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -156,7 +156,7 @@ function SetLogger(app, config) {
|
|
156
156
|
* @Usage:
|
157
157
|
* @Author: richen
|
158
158
|
* @Date: 2023-12-09 21:56:32
|
159
|
-
* @LastEditTime: 2024-01-
|
159
|
+
* @LastEditTime: 2024-01-04 07:43:03
|
160
160
|
* @License: BSD (3-Clause)
|
161
161
|
* @Copyright (c): <richenlin(at)gmail.com>
|
162
162
|
*/
|
@@ -263,6 +263,14 @@ function implementsServiceInterface(cls) {
|
|
263
263
|
function implementsPluginInterface(cls) {
|
264
264
|
return 'run' in cls && Helper.isFunction(cls.run);
|
265
265
|
}
|
266
|
+
/**
|
267
|
+
* check is implements Aspect Interface
|
268
|
+
* @param cls
|
269
|
+
* @returns
|
270
|
+
*/
|
271
|
+
function implementsAspectInterface(cls) {
|
272
|
+
return 'app' in cls && 'run' in cls && Helper.isFunction(cls.run);
|
273
|
+
}
|
266
274
|
|
267
275
|
/*
|
268
276
|
* @Description: framework constants
|
@@ -290,7 +298,7 @@ https://github.com/koatty
|
|
290
298
|
* @Usage:
|
291
299
|
* @Author: richen
|
292
300
|
* @Date: 2023-12-09 22:55:49
|
293
|
-
* @LastEditTime: 2024-01-
|
301
|
+
* @LastEditTime: 2024-01-04 05:52:31
|
294
302
|
* @License: BSD (3-Clause)
|
295
303
|
* @Copyright (c): <richenlin(at)gmail.com>
|
296
304
|
*/
|
@@ -660,6 +668,12 @@ class Loader {
|
|
660
668
|
}
|
661
669
|
pluginList.push(item.id);
|
662
670
|
}
|
671
|
+
if (item.id && (item.id).endsWith("Aspect")) {
|
672
|
+
const ctl = IOCContainer.getInsByClass(item.target);
|
673
|
+
if (!implementsAspectInterface(ctl)) {
|
674
|
+
throw Error(`The aspect ${item.id} must implements interface 'IAspect'.`);
|
675
|
+
}
|
676
|
+
}
|
663
677
|
}
|
664
678
|
});
|
665
679
|
// load plugin config
|
@@ -687,7 +701,7 @@ class Loader {
|
|
687
701
|
}
|
688
702
|
}
|
689
703
|
|
690
|
-
var version = "3.11.
|
704
|
+
var version = "3.11.1";
|
691
705
|
var engines = {
|
692
706
|
node: ">12.0.0"
|
693
707
|
};
|
@@ -1115,4 +1129,4 @@ class Output {
|
|
1115
1129
|
}
|
1116
1130
|
}
|
1117
1131
|
|
1118
|
-
export { BaseController, BaseService, BindEventHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, Output, Plugin, Service, implementsControllerInterface, implementsMiddlewareInterface, implementsPluginInterface, implementsServiceInterface };
|
1132
|
+
export { BaseController, BaseService, BindEventHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, Output, Plugin, Service, implementsAspectInterface, implementsControllerInterface, implementsMiddlewareInterface, implementsPluginInterface, implementsServiceInterface };
|
package/dist/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "koatty",
|
3
|
-
"version": "3.11.
|
3
|
+
"version": "3.11.1",
|
4
4
|
"description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
|
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",
|
3
|
-
"version": "3.11.
|
3
|
+
"version": "3.11.1",
|
4
4
|
"description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
|
5
5
|
"scripts": {
|
6
6
|
"build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
|