koatty 3.5.11 → 3.5.12-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.
Files changed (129) hide show
  1. package/.commitlintrc.js +3 -0
  2. package/.eslintignore +2 -0
  3. package/.huskyrc +5 -0
  4. package/.versionrc.js +16 -0
  5. package/CHANGELOG.md +1 -38
  6. package/README.md +4 -7
  7. package/api-extractor.json +345 -0
  8. package/dist/LICENSE +29 -0
  9. package/dist/README.md +147 -0
  10. package/dist/index.d.ts +363 -19
  11. package/dist/index.js +1266 -26
  12. package/dist/index.mjs +1197 -0
  13. package/dist/package.json +99 -0
  14. package/docs/api/index.md +12 -0
  15. package/docs/api/koatty.apiinput.code.md +11 -0
  16. package/docs/api/koatty.apiinput.data.md +11 -0
  17. package/docs/api/koatty.apiinput.md +22 -0
  18. package/docs/api/koatty.apiinput.message.md +11 -0
  19. package/docs/api/koatty.apioutput.code.md +11 -0
  20. package/docs/api/koatty.apioutput.data.md +11 -0
  21. package/docs/api/koatty.apioutput.md +22 -0
  22. package/docs/api/koatty.apioutput.message.md +11 -0
  23. package/docs/api/koatty.appreadyhookfunc.md +11 -0
  24. package/docs/api/koatty.basecontroller._constructor_.md +20 -0
  25. package/docs/api/koatty.basecontroller._options.md +11 -0
  26. package/docs/api/koatty.basecontroller.app.md +11 -0
  27. package/docs/api/koatty.basecontroller.ctx.md +11 -0
  28. package/docs/api/koatty.basecontroller.fail.md +28 -0
  29. package/docs/api/koatty.basecontroller.init.md +19 -0
  30. package/docs/api/koatty.basecontroller.md +39 -0
  31. package/docs/api/koatty.basecontroller.ok.md +28 -0
  32. package/docs/api/koatty.baseservice._constructor_.md +20 -0
  33. package/docs/api/koatty.baseservice._options.md +11 -0
  34. package/docs/api/koatty.baseservice.app.md +11 -0
  35. package/docs/api/koatty.baseservice.init.md +25 -0
  36. package/docs/api/koatty.baseservice.md +36 -0
  37. package/docs/api/koatty.bindappreadyhook.md +26 -0
  38. package/docs/api/koatty.bootstrap.md +27 -0
  39. package/docs/api/koatty.component.md +27 -0
  40. package/docs/api/koatty.componentscan.md +27 -0
  41. package/docs/api/koatty.configurationscan.md +27 -0
  42. package/docs/api/koatty.controller.md +27 -0
  43. package/docs/api/koatty.httpcontroller.body.md +28 -0
  44. package/docs/api/koatty.httpcontroller.deny.md +26 -0
  45. package/docs/api/koatty.httpcontroller.expires.md +26 -0
  46. package/docs/api/koatty.httpcontroller.fail.md +28 -0
  47. package/docs/api/koatty.httpcontroller.header.md +27 -0
  48. package/docs/api/koatty.httpcontroller.isget.md +19 -0
  49. package/docs/api/koatty.httpcontroller.ismethod.md +26 -0
  50. package/docs/api/koatty.httpcontroller.ispost.md +19 -0
  51. package/docs/api/koatty.httpcontroller.json.md +26 -0
  52. package/docs/api/koatty.httpcontroller.md +35 -0
  53. package/docs/api/koatty.httpcontroller.ok.md +28 -0
  54. package/docs/api/koatty.httpcontroller.param.md +26 -0
  55. package/docs/api/koatty.httpcontroller.redirect.md +27 -0
  56. package/docs/api/koatty.httpcontroller.type.md +27 -0
  57. package/docs/api/koatty.icontroller.__after.md +11 -0
  58. package/docs/api/koatty.icontroller.__befor.md +11 -0
  59. package/docs/api/koatty.icontroller.app.md +11 -0
  60. package/docs/api/koatty.icontroller.ctx.md +11 -0
  61. package/docs/api/koatty.icontroller.fail.md +11 -0
  62. package/docs/api/koatty.icontroller.md +25 -0
  63. package/docs/api/koatty.icontroller.ok.md +11 -0
  64. package/docs/api/koatty.imiddleware.md +20 -0
  65. package/docs/api/koatty.imiddleware.run.md +11 -0
  66. package/docs/api/koatty.iplugin.md +20 -0
  67. package/docs/api/koatty.iplugin.run.md +11 -0
  68. package/docs/api/koatty.iservice.app.md +11 -0
  69. package/docs/api/koatty.iservice.md +20 -0
  70. package/docs/api/koatty.logger.md +11 -0
  71. package/docs/api/koatty.md +51 -0
  72. package/docs/api/koatty.middleware.md +27 -0
  73. package/docs/api/koatty.plugin.md +27 -0
  74. package/docs/api/koatty.service.md +27 -0
  75. package/jest.config.js +0 -2
  76. package/jest_html_reporters.html +1 -1
  77. package/package.json +37 -35
  78. package/rollup.config.js +63 -0
  79. package/scripts/copyright.js +28 -0
  80. package/scripts/postBuild.js +10 -0
  81. package/tsconfig.json +4 -2
  82. package/babel.config.js +0 -21
  83. package/commitlint.config.js +0 -14
  84. package/dist/config/config.d.ts +0 -18
  85. package/dist/config/config.js +0 -25
  86. package/dist/config/config.js.map +0 -1
  87. package/dist/config/middleware.d.ts +0 -28
  88. package/dist/config/middleware.js +0 -32
  89. package/dist/config/middleware.js.map +0 -1
  90. package/dist/config/plugin.d.ts +0 -11
  91. package/dist/config/plugin.js +0 -15
  92. package/dist/config/plugin.js.map +0 -1
  93. package/dist/config/router.d.ts +0 -8
  94. package/dist/config/router.js +0 -32
  95. package/dist/config/router.js.map +0 -1
  96. package/dist/controller/BaseController.d.ts +0 -60
  97. package/dist/controller/BaseController.js +0 -137
  98. package/dist/controller/BaseController.js.map +0 -1
  99. package/dist/controller/HttpController.d.ts +0 -131
  100. package/dist/controller/HttpController.js +0 -214
  101. package/dist/controller/HttpController.js.map +0 -1
  102. package/dist/core/Bootstrap.d.ts +0 -50
  103. package/dist/core/Bootstrap.js +0 -218
  104. package/dist/core/Bootstrap.js.map +0 -1
  105. package/dist/core/Component.d.ts +0 -94
  106. package/dist/core/Component.js +0 -89
  107. package/dist/core/Component.js.map +0 -1
  108. package/dist/core/Constants.d.ts +0 -11
  109. package/dist/core/Constants.js +0 -24
  110. package/dist/core/Constants.js.map +0 -1
  111. package/dist/core/Loader.d.ts +0 -110
  112. package/dist/core/Loader.js +0 -394
  113. package/dist/core/Loader.js.map +0 -1
  114. package/dist/index.js.map +0 -1
  115. package/dist/middleware/PayloadMiddleware.d.ts +0 -11
  116. package/dist/middleware/PayloadMiddleware.js +0 -22
  117. package/dist/middleware/PayloadMiddleware.js.map +0 -1
  118. package/dist/middleware/TraceMiddleware.d.ts +0 -11
  119. package/dist/middleware/TraceMiddleware.js +0 -22
  120. package/dist/middleware/TraceMiddleware.js.map +0 -1
  121. package/dist/service/BaseService.d.ts +0 -33
  122. package/dist/service/BaseService.js +0 -32
  123. package/dist/service/BaseService.js.map +0 -1
  124. package/dist/util/Helper.d.ts +0 -25
  125. package/dist/util/Helper.js +0 -117
  126. package/dist/util/Helper.js.map +0 -1
  127. package/dist/util/Logger.d.ts +0 -27
  128. package/dist/util/Logger.js +0 -41
  129. package/dist/util/Logger.js.map +0 -1
@@ -1,218 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BindAppReadyHook = exports.ConfigurationScan = exports.ComponentScan = exports.Bootstrap = void 0;
4
- /**
5
- * @ author: richen
6
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
7
- * @ license: BSD (3-Clause)
8
- * @ version: 2020-07-06 11:22:58
9
- */
10
- // tslint:disable-next-line: no-import-side-effect
11
- require("reflect-metadata");
12
- const koatty_core_1 = require("koatty_core");
13
- const Loader_1 = require("./Loader");
14
- const Helper_1 = require("../util/Helper");
15
- const Logger_1 = require("../util/Logger");
16
- const koatty_container_1 = require("koatty_container");
17
- const koatty_serve_1 = require("koatty_serve");
18
- const Constants_1 = require("./Constants");
19
- const koatty_router_1 = require("koatty_router");
20
- const pkg = require("../../package.json");
21
- /**
22
- * execute bootstrap
23
- *
24
- * @param {*} target
25
- * @param {Function} bootFunc
26
- * @returns {Promise<void>}
27
- */
28
- const ExecBootstrap = async function (target, bootFunc) {
29
- // checked runtime
30
- (0, Helper_1.checkRuntime)();
31
- const app = Reflect.construct(target, []);
32
- try {
33
- console.log(Constants_1.LOGO);
34
- if (!(app instanceof koatty_core_1.Koatty)) {
35
- throw new Error(`class ${target.name} does not inherit from Koatty`);
36
- }
37
- // version
38
- Helper_1.Helper.define(app, "version", pkg.version);
39
- // Initialize env
40
- Loader_1.Loader.initialize(app);
41
- // exec bootFunc
42
- if (Helper_1.Helper.isFunction(bootFunc)) {
43
- Logger_1.Logger.Custom('think', '', 'Execute bootFunc ...');
44
- await bootFunc(app);
45
- }
46
- // Set IOC.app
47
- koatty_container_1.IOCContainer.setApp(app);
48
- Helper_1.Helper.define(app, "container", koatty_container_1.IOCContainer);
49
- Logger_1.Logger.Custom('think', '', 'ComponentScan ...');
50
- // Check all bean
51
- Loader_1.Loader.CheckAllComponents(app, target);
52
- // Load configuration
53
- Logger_1.Logger.Custom('think', '', 'Load Configurations ...');
54
- // configuration metadata
55
- const configurationMetas = Loader_1.Loader.GetConfigurationMetas(app, target);
56
- Loader_1.Loader.LoadConfigs(app, configurationMetas);
57
- // Load Plugin
58
- Logger_1.Logger.Custom('think', '', 'Load Plugins ...');
59
- await Loader_1.Loader.LoadPlugins(app);
60
- // Set Logger
61
- Loader_1.Loader.SetLogger(app);
62
- // app.emit("appBoot");
63
- await asyncEvent(app, 'appBoot');
64
- // Load App ready hooks
65
- Loader_1.Loader.LoadAppReadyHooks(app, target);
66
- // New router
67
- const KoattyRouter = newRouter(app);
68
- // Load Middleware
69
- Logger_1.Logger.Custom('think', '', 'Load Middlewares ...');
70
- await Loader_1.Loader.LoadMiddlewares(app);
71
- // Load Components
72
- Logger_1.Logger.Custom('think', '', 'Load Components ...');
73
- Loader_1.Loader.LoadComponents(app);
74
- // Load Services
75
- Logger_1.Logger.Custom('think', '', 'Load Services ...');
76
- Loader_1.Loader.LoadServices(app);
77
- // Load Controllers
78
- Logger_1.Logger.Custom('think', '', 'Load Controllers ...');
79
- Loader_1.Loader.LoadControllers(app);
80
- // Emit app ready event
81
- Logger_1.Logger.Custom('think', '', 'Emit App Ready ...');
82
- // app.emit("appReady");
83
- await asyncEvent(app, 'appReady');
84
- // Load Routers
85
- Logger_1.Logger.Custom('think', '', 'Load Routers ...');
86
- KoattyRouter.LoadRouter(app.getMetaData("_controllers"));
87
- // Emit app started event
88
- Logger_1.Logger.Custom('think', '', 'Emit App Start ...');
89
- // app.emit("appStart");
90
- const server = newServe(app);
91
- await asyncEvent(app, 'appStart');
92
- Logger_1.Logger.Custom('think', '', '====================================');
93
- // Start server
94
- app.listen(server);
95
- // binding event "appStop"
96
- (0, koatty_serve_1.BindProcessEvent)(app, 'appStop');
97
- }
98
- catch (err) {
99
- Logger_1.Logger.Error(err);
100
- process.exit();
101
- }
102
- };
103
- /**
104
- * create router
105
- *
106
- * @export
107
- * @param {Koatty} app
108
- * @returns {*}
109
- */
110
- const newRouter = function (app) {
111
- var _a;
112
- const protocol = app.config("protocol") || "http";
113
- const options = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
114
- const router = (0, koatty_router_1.NewRouter)(app, options, protocol);
115
- Helper_1.Helper.define(app, "router", router);
116
- return router;
117
- };
118
- /**
119
- * create serve
120
- *
121
- * @param {Koatty} app
122
- * @returns {*}
123
- */
124
- const newServe = function (app) {
125
- const protocol = app.config("protocol") || "http";
126
- const server = (0, koatty_serve_1.Serve)(app, protocol);
127
- Helper_1.Helper.define(app, "server", server);
128
- return server;
129
- };
130
- /**
131
- * Execute event as async
132
- *
133
- * @param {Koatty} event
134
- * @param {string} eventName
135
- */
136
- const asyncEvent = async function (event, eventName) {
137
- const ls = event.listeners(eventName);
138
- // eslint-disable-next-line no-restricted-syntax
139
- for await (const func of ls) {
140
- if (Helper_1.Helper.isFunction(func)) {
141
- func();
142
- }
143
- }
144
- return event.removeAllListeners(eventName);
145
- };
146
- /**
147
- * Bootstrap application
148
- *
149
- * @export
150
- * @param {Function} [bootFunc]
151
- * @returns {ClassDecorator}
152
- */
153
- function Bootstrap(bootFunc) {
154
- return function (target) {
155
- if (!(target.prototype instanceof koatty_core_1.Koatty)) {
156
- throw new Error(`class does not inherit from Koatty`);
157
- }
158
- ExecBootstrap(target, bootFunc);
159
- };
160
- }
161
- exports.Bootstrap = Bootstrap;
162
- /**
163
- * Define project scan path
164
- *
165
- * @export
166
- * @param {(string | string[])} [scanPath]
167
- * @returns {ClassDecorator}
168
- */
169
- function ComponentScan(scanPath) {
170
- Logger_1.Logger.Custom('think', '', 'ComponentScan');
171
- return (target) => {
172
- if (!(target.prototype instanceof koatty_core_1.Koatty)) {
173
- throw new Error(`class does not inherit from Koatty`);
174
- }
175
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
176
- koatty_container_1.IOCContainer.saveClassMetadata(koatty_container_1.TAGGED_CLS, Constants_1.COMPONENT_SCAN, scanPath, target);
177
- };
178
- }
179
- exports.ComponentScan = ComponentScan;
180
- /**
181
- * Define project configuration scan path
182
- *
183
- * @export
184
- * @param {(string | string[])} [scanPath]
185
- * @returns {ClassDecorator}
186
- */
187
- function ConfigurationScan(scanPath) {
188
- Logger_1.Logger.Custom('think', '', 'ConfigurationScan');
189
- return (target) => {
190
- if (!(target.prototype instanceof koatty_core_1.Koatty)) {
191
- throw new Error(`class does not inherit from Koatty`);
192
- }
193
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
194
- koatty_container_1.IOCContainer.saveClassMetadata(koatty_container_1.TAGGED_CLS, Constants_1.CONFIGURATION_SCAN, scanPath, target);
195
- };
196
- }
197
- exports.ConfigurationScan = ConfigurationScan;
198
- /**
199
- * bind AppReadyHookFunc
200
- * example:
201
- * export function TestDecorator(): ClassDecorator {
202
- * return (target: any) => {
203
- * BindAppReadyHook((app: Koatty) => {
204
- * // todo
205
- * return Promise.resolve();
206
- * }, target)
207
- * }
208
- * }
209
- *
210
- * @export
211
- * @param {AppReadyHookFunc} func
212
- * @param {*} target
213
- */
214
- function BindAppReadyHook(func, target) {
215
- koatty_container_1.IOCContainer.attachClassMetadata(koatty_container_1.TAGGED_CLS, Constants_1.APP_READY_HOOK, func, target);
216
- }
217
- exports.BindAppReadyHook = BindAppReadyHook;
218
- //# sourceMappingURL=Bootstrap.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Bootstrap.js","sourceRoot":"","sources":["../../src/core/Bootstrap.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,kDAAkD;AAClD,4BAA0B;AAE1B,6CAA0D;AAC1D,qCAAkC;AAClC,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,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACzD;QACD,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC;QAC1B,+BAAY,CAAC,iBAAiB,CAAC,6BAAU,EAAE,0BAAc,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACjF,CAAC,CAAC;AACN,CAAC;AAVD,sCAUC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,QAA4B;IAC1D,eAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,EAAE,mBAAmB,CAAC,CAAC;IAEhD,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,IAAI,CAAC,CAAC,MAAM,CAAC,SAAS,YAAY,oBAAM,CAAC,EAAE;YACvC,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;SACzD;QACD,QAAQ,GAAG,QAAQ,aAAR,QAAQ,cAAR,QAAQ,GAAI,EAAE,CAAC;QAC1B,+BAAY,CAAC,iBAAiB,CAAC,6BAAU,EAAE,8BAAkB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC;IACrF,CAAC,CAAC;AACN,CAAC;AAVD,8CAUC;AAKD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,gBAAgB,CAAC,IAAsB,EAAE,MAAW;IAChE,+BAAY,CAAC,mBAAmB,CAAC,6BAAU,EAAE,0BAAc,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC;AAC/E,CAAC;AAFD,4CAEC"}
@@ -1,94 +0,0 @@
1
- /**
2
- * @ author: richen
3
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
4
- * @ license: BSD (3-Clause)
5
- * @ version: 2020-05-10 11:32:45
6
- */
7
- import "reflect-metadata";
8
- import Koa from "koa";
9
- import { Koatty, KoattyContext } from 'koatty_core';
10
- /**
11
- * Indicates that an decorated class is a "component".
12
- *
13
- * @export
14
- * @param {string} [identifier] component name
15
- * @returns {ClassDecorator}
16
- */
17
- export declare function Component(identifier?: string): ClassDecorator;
18
- /**
19
- * Indicates that an decorated class is a "controller".
20
- *
21
- * @export
22
- * @param {string} [path] controller router path
23
- * @returns {ClassDecorator}
24
- */
25
- export declare function Controller(path?: string): ClassDecorator;
26
- /**
27
- * Interface for Api output
28
- */
29
- export interface ApiOutput {
30
- code: number;
31
- message: string;
32
- data: any;
33
- }
34
- /**
35
- * Interface for Api input
36
- */
37
- export interface ApiInput {
38
- code?: number;
39
- message?: string;
40
- data?: any;
41
- }
42
- /**
43
- * Interface for Controller
44
- */
45
- export interface IController {
46
- app: Koatty;
47
- ctx: KoattyContext;
48
- __befor?: () => Promise<any>;
49
- __after?: () => Promise<any>;
50
- readonly fail: (msg?: Error | string | ApiInput, data?: any, ret?: number) => Promise<ApiOutput>;
51
- readonly ok: (msg?: string | ApiInput, data?: any, ret?: number) => Promise<ApiOutput>;
52
- }
53
- /**
54
- * Indicates that an decorated class is a "middleware".
55
- *
56
- * @export
57
- * @param {string} [identifier] middleware name
58
- * @returns {ClassDecorator}
59
- */
60
- export declare function Middleware(identifier?: string): ClassDecorator;
61
- /**
62
- * Interface for Middleware
63
- */
64
- export interface IMiddleware {
65
- run: (options: any, app: Koatty) => Koa.Middleware;
66
- }
67
- /**
68
- * Indicates that an decorated class is a "service".
69
- *
70
- * @export
71
- * @param {string} [identifier] middleware name
72
- * @returns {ClassDecorator}
73
- */
74
- export declare function Service(identifier?: string): ClassDecorator;
75
- /**
76
- * Interface for Service
77
- */
78
- export interface IService {
79
- app: Koatty;
80
- }
81
- /**
82
- * Indicates that an decorated class is a "plugin".
83
- *
84
- * @export
85
- * @param {string} [identifier]
86
- * @returns {ClassDecorator}
87
- */
88
- export declare function Plugin(identifier?: string): ClassDecorator;
89
- /**
90
- * Interface for Plugin
91
- */
92
- export interface IPlugin {
93
- run: (options: any, app: Koatty) => Promise<any>;
94
- }
@@ -1,89 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Plugin = exports.Service = exports.Middleware = exports.Controller = exports.Component = void 0;
4
- /**
5
- * @ author: richen
6
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
7
- * @ license: BSD (3-Clause)
8
- * @ version: 2020-05-10 11:32:45
9
- */
10
- // tslint:disable-next-line: no-import-side-effect
11
- require("reflect-metadata");
12
- const koatty_container_1 = require("koatty_container");
13
- const koatty_router_1 = require("koatty_router");
14
- /**
15
- * Indicates that an decorated class is a "component".
16
- *
17
- * @export
18
- * @param {string} [identifier] component name
19
- * @returns {ClassDecorator}
20
- */
21
- function Component(identifier) {
22
- return (target) => {
23
- identifier = identifier || koatty_container_1.IOCContainer.getIdentifier(target);
24
- koatty_container_1.IOCContainer.saveClass("COMPONENT", target, identifier);
25
- };
26
- }
27
- exports.Component = Component;
28
- /**
29
- * Indicates that an decorated class is a "controller".
30
- *
31
- * @export
32
- * @param {string} [path] controller router path
33
- * @returns {ClassDecorator}
34
- */
35
- function Controller(path = "") {
36
- return (target) => {
37
- const identifier = koatty_container_1.IOCContainer.getIdentifier(target);
38
- koatty_container_1.IOCContainer.saveClass("CONTROLLER", target, identifier);
39
- koatty_container_1.IOCContainer.savePropertyData(koatty_router_1.CONTROLLER_ROUTER, path, target, identifier);
40
- };
41
- }
42
- exports.Controller = Controller;
43
- /**
44
- * Indicates that an decorated class is a "middleware".
45
- *
46
- * @export
47
- * @param {string} [identifier] middleware name
48
- * @returns {ClassDecorator}
49
- */
50
- function Middleware(identifier) {
51
- return (target) => {
52
- identifier = identifier || koatty_container_1.IOCContainer.getIdentifier(target);
53
- koatty_container_1.IOCContainer.saveClass("MIDDLEWARE", target, identifier);
54
- };
55
- }
56
- exports.Middleware = Middleware;
57
- /**
58
- * Indicates that an decorated class is a "service".
59
- *
60
- * @export
61
- * @param {string} [identifier] middleware name
62
- * @returns {ClassDecorator}
63
- */
64
- function Service(identifier) {
65
- return (target) => {
66
- identifier = identifier || koatty_container_1.IOCContainer.getIdentifier(target);
67
- koatty_container_1.IOCContainer.saveClass("SERVICE", target, identifier);
68
- };
69
- }
70
- exports.Service = Service;
71
- /**
72
- * Indicates that an decorated class is a "plugin".
73
- *
74
- * @export
75
- * @param {string} [identifier]
76
- * @returns {ClassDecorator}
77
- */
78
- function Plugin(identifier) {
79
- return (target) => {
80
- identifier = identifier || koatty_container_1.IOCContainer.getIdentifier(target);
81
- //
82
- if (!identifier.endsWith("Plugin")) {
83
- throw Error("Plugin class name must be 'Plugin' suffix.");
84
- }
85
- koatty_container_1.IOCContainer.saveClass("COMPONENT", target, `${identifier}`);
86
- };
87
- }
88
- exports.Plugin = Plugin;
89
- //# sourceMappingURL=Component.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Component.js","sourceRoot":"","sources":["../../src/core/Component.ts"],"names":[],"mappings":";;;AAAA;;;;;GAKG;AACH,kDAAkD;AAClD,4BAA0B;AAE1B,uDAAgD;AAEhD,iDAAkD;AAElD;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,UAAmB;IACzC,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,UAAU,GAAG,UAAU,IAAI,+BAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9D,+BAAY,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC,CAAC;AACN,CAAC;AALD,8BAKC;AAED;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,IAAI,GAAG,EAAE;IAChC,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,MAAM,UAAU,GAAG,+BAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QACtD,+BAAY,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;QACzD,+BAAY,CAAC,gBAAgB,CAAC,iCAAiB,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC/E,CAAC,CAAC;AACN,CAAC;AAND,gCAMC;AAiCD;;;;;;GAMG;AACH,SAAgB,UAAU,CAAC,UAAmB;IAC1C,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,UAAU,GAAG,UAAU,IAAI,+BAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9D,+BAAY,CAAC,SAAS,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC7D,CAAC,CAAC;AACN,CAAC;AALD,gCAKC;AASD;;;;;;GAMG;AACH,SAAgB,OAAO,CAAC,UAAmB;IACvC,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,UAAU,GAAG,UAAU,IAAI,+BAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9D,+BAAY,CAAC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC1D,CAAC,CAAC;AACN,CAAC;AALD,0BAKC;AAWD;;;;;;GAMG;AACH,SAAgB,MAAM,CAAC,UAAmB;IACtC,OAAO,CAAC,MAAW,EAAE,EAAE;QACnB,UAAU,GAAG,UAAU,IAAI,+BAAY,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9D,GAAG;QACH,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAChC,MAAM,KAAK,CAAC,4CAA4C,CAAC,CAAC;SAC7D;QACD,+BAAY,CAAC,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,UAAU,EAAE,CAAC,CAAC;IACjE,CAAC,CAAC;AACN,CAAC;AATD,wBASC"}
@@ -1,11 +0,0 @@
1
- /**
2
- * @ author: richen
3
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
4
- * @ license: BSD (3-Clause)
5
- * @ version: 2020-05-10 11:49:15
6
- */
7
- export declare const COMPONENT_SCAN = "COMPONENT_SCAN";
8
- export declare const CONFIGURATION_SCAN = "CONFIGURATION_SCAN";
9
- export declare const PRIORITY_KEY = "PRIORITY_KEY";
10
- export declare const APP_READY_HOOK = "APP_READY_HOOK";
11
- export declare const LOGO = "\n\n\u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\n\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2588\u2588\u2001\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2001\u2001\u2001\u2588\u2588\u2001\u2001\u2001\u2001\u2001\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\n\u2588\u2588\u2588\u2588\u2588\u2001\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001 \u2001\u2588\u2588\u2588\u2588\u2001\u2001 \n\u2588\u2588\u2001\u2001\u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001\u2588\u2588\u2001\u2001\u2001\u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001 \u2001\u2588\u2588\u2001\u2001 \n\u2588\u2588\u2001 \u2588\u2588\u2001\u2001\u2588\u2588\u2588\u2588\u2588\u2588\u2001\u2001\u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001 \u2588\u2588\u2001 \n https://github.com/koatty\n";
@@ -1,24 +0,0 @@
1
- "use strict";
2
- /**
3
- * @ author: richen
4
- * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
5
- * @ license: BSD (3-Clause)
6
- * @ version: 2020-05-10 11:49:15
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.LOGO = exports.APP_READY_HOOK = exports.PRIORITY_KEY = exports.CONFIGURATION_SCAN = exports.COMPONENT_SCAN = void 0;
10
- exports.COMPONENT_SCAN = 'COMPONENT_SCAN';
11
- exports.CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
12
- exports.PRIORITY_KEY = 'PRIORITY_KEY';
13
- exports.APP_READY_HOOK = "APP_READY_HOOK";
14
- // tslint:disable: no-irregular-whitespace
15
- exports.LOGO = `
16
-
17
- ██  ██  ██████  █████  ████████ ████████ ██  ██ 
18
- ██  ██  ██    ██ ██   ██    ██       ██     ██  ██  
19
- █████   ██  ██ ███████  ██  ██   ████  
20
- ██  ██  ██  ██ ██   ██  ██  ██   ██  
21
- ██  ██  ██████  ██  ██  ██  ██  ██ 
22
- https://github.com/koatty
23
- `;
24
- //# sourceMappingURL=Constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Constants.js","sourceRoot":"","sources":["../../src/core/Constants.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEU,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAClC,QAAA,kBAAkB,GAAG,oBAAoB,CAAC;AAC1C,QAAA,YAAY,GAAG,cAAc,CAAC;AAE9B,QAAA,cAAc,GAAG,gBAAgB,CAAC;AAE/C,0CAA0C;AAC7B,QAAA,IAAI,GAAG;;;;;;;;CAQnB,CAAC"}
@@ -1,110 +0,0 @@
1
- import { Koatty } from 'koatty_core';
2
- /**
3
- *
4
- */
5
- export declare class Loader {
6
- /**
7
- * initialize env
8
- *
9
- * @static
10
- * @param {Koatty} app
11
- * @memberof Loader
12
- */
13
- static initialize(app: Koatty): void;
14
- /**
15
- * Get component metadata
16
- *
17
- * @static
18
- * @param {Koatty} app
19
- * @param {*} target
20
- * @returns {*} {any[]}
21
- * @memberof Loader
22
- */
23
- static GetComponentMetas(app: Koatty, target: any): any[];
24
- /**
25
- * Load all bean, excepted config/*、App.ts
26
- *
27
- * @static
28
- * @param {Koatty} app
29
- * @param {*} target
30
- * @memberof Loader
31
- */
32
- static CheckAllComponents(app: Koatty, target: any): void;
33
- /**
34
- * Get configuration metadata
35
- *
36
- * @static
37
- * @param {Koatty} app
38
- * @param {*} target
39
- * @returns {*} {any[]}
40
- * @memberof Loader
41
- */
42
- static GetConfigurationMetas(app: Koatty, target: any): any[];
43
- /**
44
- * Set Logger level
45
- *
46
- * @static
47
- * @param {Koatty} app
48
- * @memberof Loader
49
- */
50
- static SetLogger(app: Koatty): void;
51
- /**
52
- * Load app ready hook funcs
53
- *
54
- * @static
55
- * @param {Koatty} app
56
- * @param {*} target
57
- * @memberof Loader
58
- */
59
- static LoadAppReadyHooks(app: Koatty, target: any): void;
60
- /**
61
- * Load configuration
62
- *
63
- * @static
64
- * @param {Koatty} app
65
- * @param {string[]} [loadPath]
66
- * @memberof Loader
67
- */
68
- static LoadConfigs(app: Koatty, loadPath?: string[]): void;
69
- /**
70
- * Load middlewares
71
- * [async]
72
- * @static
73
- * @param {*} app
74
- * @param {(string | string[])} [loadPath]
75
- * @memberof Loader
76
- */
77
- static LoadMiddlewares(app: Koatty, loadPath?: string[]): Promise<void>;
78
- /**
79
- * Load controllers
80
- *
81
- * @static
82
- * @param {*} app
83
- * @memberof Loader
84
- */
85
- static LoadControllers(app: Koatty): void;
86
- /**
87
- * Load services
88
- *
89
- * @static
90
- * @param {*} app
91
- * @memberof Loader
92
- */
93
- static LoadServices(app: Koatty): void;
94
- /**
95
- * Load components
96
- *
97
- * @static
98
- * @param {*} app
99
- * @memberof Loader
100
- */
101
- static LoadComponents(app: Koatty): void;
102
- /**
103
- * Load plugins
104
- *
105
- * @static
106
- * @param {*} app
107
- * @memberof Loader
108
- */
109
- static LoadPlugins(app: Koatty): Promise<void>;
110
- }