koatty 3.11.2 → 3.11.3

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
+ ### [3.11.3](https://github.com/thinkkoa/koatty/compare/v3.11.2...v3.11.3) (2024-03-15)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * output迁移到exception库 ([e59428e](https://github.com/thinkkoa/koatty/commit/e59428e11687c0388089b82e80d6dece17fe7b07))
11
+
5
12
  ### [3.11.2](https://github.com/thinkkoa/koatty/compare/v3.11.2-8...v3.11.2) (2024-02-02)
6
13
 
7
14
 
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2024-02-02 15:35:00
3
+ * @Date: 2024-03-15 10:55:35
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -17,24 +17,6 @@ import { Middleware as Middleware_2 } from 'koa';
17
17
  import { Next } from 'koa';
18
18
  import { Value } from 'koatty_config';
19
19
 
20
- /**
21
- * Interface for Api input
22
- */
23
- declare interface ApiInput {
24
- code?: number;
25
- message?: string;
26
- data?: any;
27
- }
28
-
29
- /**
30
- * Interface for Api output
31
- */
32
- declare interface ApiOutput {
33
- code: number;
34
- message: string;
35
- data: any;
36
- }
37
-
38
20
  /**
39
21
  * @description: bind App event hook func
40
22
  * example:
@@ -192,31 +174,6 @@ export declare const Logger: Logger_2;
192
174
  */
193
175
  export declare function Middleware(identifier?: string): ClassDecorator;
194
176
 
195
- export declare class Output {
196
- /**
197
- * Response to normalize json format content for success
198
- *
199
- * @param {KoattyContext} ctx
200
- * @param {(string | ApiInput)} msg 待处理的message消息
201
- * @param {*} [data] 待处理的数据
202
- * @param {number} [code=200] 错误码,默认0
203
- * @returns {*}
204
- * @memberof BaseController
205
- */
206
- static ok(ctx: KoattyContext, msg: string | ApiInput, data?: any, code?: number): Promise<ApiOutput>;
207
- /**
208
- * Response to normalize json format content for fail
209
- *
210
- * @param {KoattyContext} ctx
211
- * @param {(string | ApiInput)} msg
212
- * @param {*} [data]
213
- * @param {number} [code=1]
214
- * @returns {*}
215
- * @memberof BaseController
216
- */
217
- static fail(ctx: KoattyContext, msg: Error | string | ApiInput, data?: any, code?: number): void;
218
- }
219
-
220
177
  /**
221
178
  * Indicates that an decorated class is a "plugin".
222
179
  *
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2024-02-02 15:34:49
3
+ * @Date: 2024-03-15 10:55:22
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -669,7 +669,7 @@ class Loader {
669
669
  }
670
670
  }
671
671
 
672
- var version = "3.11.2";
672
+ var version = "3.11.3";
673
673
  var engines = {
674
674
  node: ">12.0.0"
675
675
  };
@@ -931,77 +931,6 @@ function BindEventHook(eventName, eventFunc, target) {
931
931
  koatty_container.IOCContainer.attachClassMetadata(koatty_container.TAGGED_CLS, eventName, eventFunc, target);
932
932
  }
933
933
 
934
- /*
935
- * @Description: output data
936
- * @Usage:
937
- * @Author: richen
938
- * @Date: 2024-01-03 22:03:34
939
- * @LastEditTime: 2024-01-16 01:20:36
940
- * @License: BSD (3-Clause)
941
- * @Copyright (c): <richenlin(at)gmail.com>
942
- */
943
- class Output {
944
- /**
945
- * Response to normalize json format content for success
946
- *
947
- * @param {KoattyContext} ctx
948
- * @param {(string | ApiInput)} msg 待处理的message消息
949
- * @param {*} [data] 待处理的数据
950
- * @param {number} [code=200] 错误码,默认0
951
- * @returns {*}
952
- * @memberof BaseController
953
- */
954
- static ok(ctx, msg, data, code = 0) {
955
- const obj = formatApiData(msg, data, code);
956
- return Promise.resolve(obj);
957
- }
958
- /**
959
- * Response to normalize json format content for fail
960
- *
961
- * @param {KoattyContext} ctx
962
- * @param {(string | ApiInput)} msg
963
- * @param {*} [data]
964
- * @param {number} [code=1]
965
- * @returns {*}
966
- * @memberof BaseController
967
- */
968
- static fail(ctx, msg, data, code = 1) {
969
- const obj = formatApiData(msg, data, code);
970
- ctx.body = obj.data;
971
- ctx.throw(obj.message, obj.code, 200);
972
- }
973
- }
974
- /**
975
- * Format api interface data format
976
- *
977
- * @private
978
- * @param {Error | string | ApiInput} msg 待处理的接口数据信息|接口msg
979
- * @param {*} data 待返回的数据
980
- * @param {number} defaultCode 默认错误码
981
- * @returns {ApiOutput} 格式化之后的接口数据
982
- * @memberof BaseController
983
- */
984
- function formatApiData(msg, data, defaultCode) {
985
- let obj = {
986
- code: defaultCode,
987
- message: '',
988
- data: null,
989
- };
990
- if (koatty_lib.Helper.isError(msg)) {
991
- const { code, message } = msg;
992
- obj.code = code || defaultCode;
993
- obj.message = message;
994
- }
995
- else if (koatty_lib.Helper.isObject(msg)) {
996
- obj = { ...obj, ...msg };
997
- }
998
- else {
999
- obj.message = msg;
1000
- obj.data = data;
1001
- }
1002
- return obj;
1003
- }
1004
-
1005
934
  Object.defineProperty(exports, 'Config', {
1006
935
  enumerable: true,
1007
936
  get: function () { return koatty_config.Config; }
@@ -1023,7 +952,6 @@ exports.Controller = Controller;
1023
952
  exports.ExecBootStrap = ExecBootStrap;
1024
953
  exports.Logger = Logger;
1025
954
  exports.Middleware = Middleware;
1026
- exports.Output = Output;
1027
955
  exports.Plugin = Plugin;
1028
956
  exports.Service = Service;
1029
957
  exports.implementsAspectInterface = implementsAspectInterface;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2024-02-02 15:34:49
3
+ * @Date: 2024-03-15 10:55:22
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -655,7 +655,7 @@ class Loader {
655
655
  }
656
656
  }
657
657
 
658
- var version = "3.11.2";
658
+ var version = "3.11.3";
659
659
  var engines = {
660
660
  node: ">12.0.0"
661
661
  };
@@ -917,75 +917,4 @@ function BindEventHook(eventName, eventFunc, target) {
917
917
  IOCContainer.attachClassMetadata(TAGGED_CLS, eventName, eventFunc, target);
918
918
  }
919
919
 
920
- /*
921
- * @Description: output data
922
- * @Usage:
923
- * @Author: richen
924
- * @Date: 2024-01-03 22:03:34
925
- * @LastEditTime: 2024-01-16 01:20:36
926
- * @License: BSD (3-Clause)
927
- * @Copyright (c): <richenlin(at)gmail.com>
928
- */
929
- class Output {
930
- /**
931
- * Response to normalize json format content for success
932
- *
933
- * @param {KoattyContext} ctx
934
- * @param {(string | ApiInput)} msg 待处理的message消息
935
- * @param {*} [data] 待处理的数据
936
- * @param {number} [code=200] 错误码,默认0
937
- * @returns {*}
938
- * @memberof BaseController
939
- */
940
- static ok(ctx, msg, data, code = 0) {
941
- const obj = formatApiData(msg, data, code);
942
- return Promise.resolve(obj);
943
- }
944
- /**
945
- * Response to normalize json format content for fail
946
- *
947
- * @param {KoattyContext} ctx
948
- * @param {(string | ApiInput)} msg
949
- * @param {*} [data]
950
- * @param {number} [code=1]
951
- * @returns {*}
952
- * @memberof BaseController
953
- */
954
- static fail(ctx, msg, data, code = 1) {
955
- const obj = formatApiData(msg, data, code);
956
- ctx.body = obj.data;
957
- ctx.throw(obj.message, obj.code, 200);
958
- }
959
- }
960
- /**
961
- * Format api interface data format
962
- *
963
- * @private
964
- * @param {Error | string | ApiInput} msg 待处理的接口数据信息|接口msg
965
- * @param {*} data 待返回的数据
966
- * @param {number} defaultCode 默认错误码
967
- * @returns {ApiOutput} 格式化之后的接口数据
968
- * @memberof BaseController
969
- */
970
- function formatApiData(msg, data, defaultCode) {
971
- let obj = {
972
- code: defaultCode,
973
- message: '',
974
- data: null,
975
- };
976
- if (Helper.isError(msg)) {
977
- const { code, message } = msg;
978
- obj.code = code || defaultCode;
979
- obj.message = message;
980
- }
981
- else if (Helper.isObject(msg)) {
982
- obj = { ...obj, ...msg };
983
- }
984
- else {
985
- obj.message = msg;
986
- obj.data = data;
987
- }
988
- return obj;
989
- }
990
-
991
- export { BindEventHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, Output, Plugin, Service, implementsAspectInterface, implementsControllerInterface, implementsMiddlewareInterface, implementsPluginInterface, implementsServiceInterface };
920
+ export { BindEventHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, 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.2",
3
+ "version": "3.11.3",
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",
@@ -86,14 +86,14 @@
86
86
  "koatty_config": "~1.1.6",
87
87
  "koatty_container": "~1.8.10",
88
88
  "koatty_core": "~1.9.0",
89
- "koatty_exception": "~1.3.2",
89
+ "koatty_exception": "~1.4.2",
90
90
  "koatty_lib": "~1.3.4",
91
91
  "koatty_loader": "~1.1.0",
92
92
  "koatty_logger": "~2.1.4",
93
93
  "koatty_proto": "~1.1.12",
94
- "koatty_router": "~1.9.0",
94
+ "koatty_router": "~1.9.1",
95
95
  "koatty_serve": "~2.1.2",
96
- "koatty_trace": "~1.12.2",
96
+ "koatty_trace": "~1.12.3",
97
97
  "koatty_validation": "~1.3.2"
98
98
  }
99
99
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.11.2",
3
+ "version": "3.11.3",
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",
@@ -86,14 +86,14 @@
86
86
  "koatty_config": "~1.1.6",
87
87
  "koatty_container": "~1.8.10",
88
88
  "koatty_core": "~1.9.0",
89
- "koatty_exception": "~1.3.2",
89
+ "koatty_exception": "~1.4.2",
90
90
  "koatty_lib": "~1.3.4",
91
91
  "koatty_loader": "~1.1.0",
92
92
  "koatty_logger": "~2.1.4",
93
93
  "koatty_proto": "~1.1.12",
94
- "koatty_router": "~1.9.0",
94
+ "koatty_router": "~1.9.1",
95
95
  "koatty_serve": "~2.1.2",
96
- "koatty_trace": "~1.12.2",
96
+ "koatty_trace": "~1.12.3",
97
97
  "koatty_validation": "~1.3.2"
98
98
  }
99
99
  }