@fastcar/core 0.3.1 → 0.3.2
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/README.md +26 -0
- package/annotation.d.ts +5 -0
- package/package.json +1 -1
- package/src/FastCarApplication.ts +46 -1
- package/src/annotation/bind/AppEnv.ts +10 -0
- package/src/annotation/bind/BindValue.ts +16 -0
- package/src/annotation/bind/Value.ts +22 -0
- package/src/annotation.ts +4 -0
- package/src/constant/FastCarMetaData.ts +1 -0
- package/src/type/ComponentDesc.ts +6 -0
- package/target/FastCarApplication.js +41 -0
- package/target/annotation/bind/AppEnv.js +12 -0
- package/target/annotation/bind/BindValue.js +16 -0
- package/target/annotation/bind/Value.js +23 -0
- package/target/annotation.js +6 -2
- package/target/constant/FastCarMetaData.js +1 -0
- package/test/example/logs/fastcar-server.app.log +0 -0
- package/test/example/logs/fastcar-server.sys.log +11 -0
- package/test/example/logs/fastcar-server.sys1.log +10 -0
- package/test/example/logs/fastcar-server.sys2.log +10 -0
- package/test/example/logs/fastcar-server.sys3.log +10 -0
- package/test/example/logs/fastcar-server.sys4.log +10 -0
- package/test/example/resource/application.yml +4 -0
- package/test/example/resource/hello.yml +1 -0
- package/test/example/simple/app.ts +9 -0
- package/test/example/simple/service/TestValue.ts +20 -0
- package/src/annotation/stereotype/Value.ts +0 -5
- package/target/annotation/stereotype/Value.js +0 -5
- package/test/unit/sys2.log +0 -6
- package/test/unit/sys3.log +0 -6
- package/test/unit/sys4.log +0 -6
- package/test/unit/sys5.log +0 -6
- package/test/unit/sys6.log +0 -6
package/README.md
CHANGED
|
@@ -104,6 +104,10 @@ ApplicationSetting 应用内配置设置 具有最高等级
|
|
|
104
104
|
|
|
105
105
|
ResourcePath 自定义resource的位置
|
|
106
106
|
|
|
107
|
+
Value 获取自定义的配置 0.3.2版本开始
|
|
108
|
+
|
|
109
|
+
AppEnv 获取运行环境 0.3.2版本开始
|
|
110
|
+
|
|
107
111
|
## 约定
|
|
108
112
|
|
|
109
113
|
### 配置文件约定
|
|
@@ -373,6 +377,28 @@ class APP implements ApplicationHook {
|
|
|
373
377
|
}
|
|
374
378
|
```
|
|
375
379
|
|
|
380
|
+
```ts
|
|
381
|
+
//获取系统配置和第三方配置的key
|
|
382
|
+
@DemandInjection
|
|
383
|
+
export default class TestValue {
|
|
384
|
+
@Value("sys.test.a")
|
|
385
|
+
a!: any;
|
|
386
|
+
|
|
387
|
+
@Value("sys.test.a.b")
|
|
388
|
+
b!: any;
|
|
389
|
+
|
|
390
|
+
@Value("sys.test.a.b.c")
|
|
391
|
+
c!: string;
|
|
392
|
+
|
|
393
|
+
@AppEnv
|
|
394
|
+
env!: string;
|
|
395
|
+
|
|
396
|
+
@Value("a.b.c", HelloConfig)
|
|
397
|
+
hello_c!: string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
```
|
|
401
|
+
|
|
376
402
|
## 更多用法
|
|
377
403
|
|
|
378
404
|
参考项目git地址 @fastcar/core/test 下的simple内
|
package/annotation.d.ts
CHANGED
|
@@ -165,3 +165,8 @@ export function ResourcePath(name: string): Ret;
|
|
|
165
165
|
|
|
166
166
|
//自定义类型
|
|
167
167
|
export function CustomType(name: string): PMRet;
|
|
168
|
+
|
|
169
|
+
//获取自定义参数
|
|
170
|
+
export function Value(key: string, relayTarget?: Object): PMRet;
|
|
171
|
+
|
|
172
|
+
export function AppEnv(target: Object, propertyKey: string): void;
|
package/package.json
CHANGED
|
@@ -19,7 +19,7 @@ import Component from "./annotation/stereotype/Component";
|
|
|
19
19
|
import WinstonLogger from "./model/WinstonLogger";
|
|
20
20
|
import * as winston from "winston";
|
|
21
21
|
import Logger from "./interface/Logger";
|
|
22
|
-
import { ComponentDesc, InjectionMeta } from "./type/ComponentDesc";
|
|
22
|
+
import { ComponentDesc, InjectionMeta, InjectionValueMeta } from "./type/ComponentDesc";
|
|
23
23
|
import DateUtil from "./utils/DateUtil";
|
|
24
24
|
import { ProcessType } from "./type/ProcessType";
|
|
25
25
|
import { FileHotterDesc, HotReloadEnum } from "./type/FileHotterDesc";
|
|
@@ -536,6 +536,51 @@ class FastCarApplication extends Events {
|
|
|
536
536
|
});
|
|
537
537
|
});
|
|
538
538
|
}
|
|
539
|
+
|
|
540
|
+
let injectionValues: Array<InjectionValueMeta> = Reflect.getMetadata(FastCarMetaData.InjectionValue, instance);
|
|
541
|
+
if (Array.isArray(injectionValues) && injectionValues.length > 0) {
|
|
542
|
+
injectionValues.forEach((item) => {
|
|
543
|
+
Reflect.defineProperty(instance, item.propertyKey, {
|
|
544
|
+
get: () => {
|
|
545
|
+
let rootService = item.relayTarget || null;
|
|
546
|
+
let keys = item.key.split(".");
|
|
547
|
+
let first = keys[0];
|
|
548
|
+
|
|
549
|
+
switch (first) {
|
|
550
|
+
case "application": {
|
|
551
|
+
if (!rootService) {
|
|
552
|
+
rootService = this.getapplicationConfig();
|
|
553
|
+
}
|
|
554
|
+
keys.shift();
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
case "sys": {
|
|
558
|
+
rootService = this.getSetting(keys[1]);
|
|
559
|
+
keys.splice(0, 2);
|
|
560
|
+
break;
|
|
561
|
+
}
|
|
562
|
+
default: {
|
|
563
|
+
if (!item.relayTarget) {
|
|
564
|
+
return null;
|
|
565
|
+
}
|
|
566
|
+
rootService = this.getComponentByTarget(item.relayTarget);
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
let obj = rootService;
|
|
572
|
+
for (let key of keys) {
|
|
573
|
+
if (obj == null) {
|
|
574
|
+
break;
|
|
575
|
+
}
|
|
576
|
+
obj = Reflect.get(obj, key);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
return obj || null;
|
|
580
|
+
},
|
|
581
|
+
});
|
|
582
|
+
});
|
|
583
|
+
}
|
|
539
584
|
}
|
|
540
585
|
|
|
541
586
|
public loadLoggerIOC(instance: Object) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { FastCarMetaData } from "../../constant/FastCarMetaData";
|
|
2
|
+
import { InjectionValueMeta } from "../../type/ComponentDesc";
|
|
3
|
+
|
|
4
|
+
export default function BindValue({ key, relayTarget, target, propertyKey }: { relayTarget?: Object; key: string; target: Object; propertyKey: string }) {
|
|
5
|
+
let values: Array<InjectionValueMeta> = Reflect.getMetadata(FastCarMetaData.InjectionValue, target);
|
|
6
|
+
if (!values) {
|
|
7
|
+
values = [];
|
|
8
|
+
Reflect.defineMetadata(FastCarMetaData.InjectionValue, values, target);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
values.push({
|
|
12
|
+
key,
|
|
13
|
+
relayTarget,
|
|
14
|
+
propertyKey,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//获取原属性值
|
|
2
|
+
|
|
3
|
+
import BindValue from "./BindValue";
|
|
4
|
+
|
|
5
|
+
//application 代表系统参数
|
|
6
|
+
//sys 从设置中取参数
|
|
7
|
+
//其他默认第一个代表 资源路径下的地址
|
|
8
|
+
/**
|
|
9
|
+
* @since 3.0.2
|
|
10
|
+
* @version 1.0 获取系统配置参数根据
|
|
11
|
+
* @param key 根据application,setting进行,如果有target则优先根据target进行
|
|
12
|
+
*/
|
|
13
|
+
export default function Value(key: string, relayTarget?: Object) {
|
|
14
|
+
return function (target: Object, propertyKey: string) {
|
|
15
|
+
BindValue({
|
|
16
|
+
key,
|
|
17
|
+
relayTarget,
|
|
18
|
+
target,
|
|
19
|
+
propertyKey,
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
}
|
package/src/annotation.ts
CHANGED
|
@@ -51,6 +51,8 @@ import BaseName from "./annotation/env/BaseName";
|
|
|
51
51
|
import CustomType from "./annotation/valid/CustomType";
|
|
52
52
|
import ComponentScanMust from "./annotation/scan/ComponentScanMust";
|
|
53
53
|
import DemandInjection from "./annotation/bind/DemandInjection";
|
|
54
|
+
import Value from "./annotation/bind/Value";
|
|
55
|
+
import AppEnv from "./annotation/bind/AppEnv";
|
|
54
56
|
|
|
55
57
|
//注解暴露出去
|
|
56
58
|
export {
|
|
@@ -93,6 +95,8 @@ export {
|
|
|
93
95
|
Rule,
|
|
94
96
|
ResourcePath,
|
|
95
97
|
CustomType,
|
|
98
|
+
Value,
|
|
99
|
+
AppEnv,
|
|
96
100
|
};
|
|
97
101
|
|
|
98
102
|
export {
|
|
@@ -468,6 +468,47 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
|
|
|
468
468
|
});
|
|
469
469
|
});
|
|
470
470
|
}
|
|
471
|
+
let injectionValues = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionValue, instance);
|
|
472
|
+
if (Array.isArray(injectionValues) && injectionValues.length > 0) {
|
|
473
|
+
injectionValues.forEach((item) => {
|
|
474
|
+
Reflect.defineProperty(instance, item.propertyKey, {
|
|
475
|
+
get: () => {
|
|
476
|
+
let rootService = item.relayTarget || null;
|
|
477
|
+
let keys = item.key.split(".");
|
|
478
|
+
let first = keys[0];
|
|
479
|
+
switch (first) {
|
|
480
|
+
case "application": {
|
|
481
|
+
if (!rootService) {
|
|
482
|
+
rootService = this.getapplicationConfig();
|
|
483
|
+
}
|
|
484
|
+
keys.shift();
|
|
485
|
+
break;
|
|
486
|
+
}
|
|
487
|
+
case "sys": {
|
|
488
|
+
rootService = this.getSetting(keys[1]);
|
|
489
|
+
keys.splice(0, 2);
|
|
490
|
+
break;
|
|
491
|
+
}
|
|
492
|
+
default: {
|
|
493
|
+
if (!item.relayTarget) {
|
|
494
|
+
return null;
|
|
495
|
+
}
|
|
496
|
+
rootService = this.getComponentByTarget(item.relayTarget);
|
|
497
|
+
break;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
let obj = rootService;
|
|
501
|
+
for (let key of keys) {
|
|
502
|
+
if (obj == null) {
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
obj = Reflect.get(obj, key);
|
|
506
|
+
}
|
|
507
|
+
return obj || null;
|
|
508
|
+
},
|
|
509
|
+
});
|
|
510
|
+
});
|
|
511
|
+
}
|
|
471
512
|
}
|
|
472
513
|
loadLoggerIOC(instance) {
|
|
473
514
|
let logIds = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionLog, instance);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = AppEnv;
|
|
4
|
+
const BindValue_1 = require("./BindValue");
|
|
5
|
+
function AppEnv(target, propertyKey) {
|
|
6
|
+
// //反向找设计类型
|
|
7
|
+
(0, BindValue_1.default)({
|
|
8
|
+
key: "application.env",
|
|
9
|
+
target,
|
|
10
|
+
propertyKey,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.default = BindValue;
|
|
4
|
+
const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
|
|
5
|
+
function BindValue({ key, relayTarget, target, propertyKey }) {
|
|
6
|
+
let values = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionValue, target);
|
|
7
|
+
if (!values) {
|
|
8
|
+
values = [];
|
|
9
|
+
Reflect.defineMetadata(FastCarMetaData_1.FastCarMetaData.InjectionValue, values, target);
|
|
10
|
+
}
|
|
11
|
+
values.push({
|
|
12
|
+
key,
|
|
13
|
+
relayTarget,
|
|
14
|
+
propertyKey,
|
|
15
|
+
});
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
//获取原属性值
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.default = Value;
|
|
5
|
+
const BindValue_1 = require("./BindValue");
|
|
6
|
+
//application 代表系统参数
|
|
7
|
+
//sys 从设置中取参数
|
|
8
|
+
//其他默认第一个代表 资源路径下的地址
|
|
9
|
+
/**
|
|
10
|
+
* @since 3.0.2
|
|
11
|
+
* @version 1.0 获取系统配置参数根据
|
|
12
|
+
* @param key 根据application,setting进行,如果有target则优先根据target进行
|
|
13
|
+
*/
|
|
14
|
+
function Value(key, relayTarget) {
|
|
15
|
+
return function (target, propertyKey) {
|
|
16
|
+
(0, BindValue_1.default)({
|
|
17
|
+
key,
|
|
18
|
+
relayTarget,
|
|
19
|
+
target,
|
|
20
|
+
propertyKey,
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
}
|
package/target/annotation.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
exports.ApplicationSetting = exports.BaseName = exports.BasePath = void 0;
|
|
3
|
+
exports.Transactional = exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = exports.AppEnv = exports.Value = exports.CustomType = exports.ResourcePath = exports.Rule = exports.ValidForm = exports.ValidCustom = exports.Type = exports.Size = exports.NotNull = exports.DefaultVal = exports.AddChildValid = exports.AddRequireModule = exports.Log = exports.Readonly = exports.Override = exports.NotImplemented = exports.Deprecate = exports.ExceptionMonitor = exports.AliasInjection = exports.DemandInjection = exports.CallDependency = exports.Autowired = exports.Application = exports.Injection = exports.Repository = exports.Service = exports.Controller = exports.Configure = exports.BeanName = exports.Hotter = exports.ComponentScanMust = exports.ComponentInjection = exports.Component = exports.ComponentScanExclusion = exports.ComponentScan = exports.ApplicationDestory = exports.ApplicationInit = exports.ApplicationRunner = exports.ApplicationStop = exports.ApplicationStart = void 0;
|
|
4
|
+
exports.ApplicationSetting = exports.BaseName = exports.BasePath = exports.BaseFilePath = exports.ENV = void 0;
|
|
5
5
|
const Application_1 = require("./annotation/Application");
|
|
6
6
|
exports.Application = Application_1.default;
|
|
7
7
|
const Autowired_1 = require("./annotation/bind/Autowired");
|
|
@@ -108,3 +108,7 @@ const ComponentScanMust_1 = require("./annotation/scan/ComponentScanMust");
|
|
|
108
108
|
exports.ComponentScanMust = ComponentScanMust_1.default;
|
|
109
109
|
const DemandInjection_1 = require("./annotation/bind/DemandInjection");
|
|
110
110
|
exports.DemandInjection = DemandInjection_1.default;
|
|
111
|
+
const Value_1 = require("./annotation/bind/Value");
|
|
112
|
+
exports.Value = Value_1.default;
|
|
113
|
+
const AppEnv_1 = require("./annotation/bind/AppEnv");
|
|
114
|
+
exports.AppEnv = AppEnv_1.default;
|
|
@@ -30,4 +30,5 @@ var FastCarMetaData;
|
|
|
30
30
|
FastCarMetaData["ComponentScanMust"] = "ComponentScanMust";
|
|
31
31
|
FastCarMetaData["InjectionSingleInstance"] = "InjectionSingleInstance";
|
|
32
32
|
FastCarMetaData["InjectionLog"] = "InjectionLog";
|
|
33
|
+
FastCarMetaData["InjectionValue"] = "InjectionValue";
|
|
33
34
|
})(FastCarMetaData || (exports.FastCarMetaData = FastCarMetaData = {}));
|
|
File without changes
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
{"timestamp":"2024-12-09 15:03:04.199","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-09 15:03:04.437","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-09 15:03:04.439","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-09 15:03:04.441","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-09 15:03:04.442","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-09 15:03:58.880","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-09 15:06:04.17","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
8
|
+
{"timestamp":"2024-12-09 15:06:04.249","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
9
|
+
{"timestamp":"2024-12-09 15:06:04.251","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
10
|
+
{"timestamp":"2024-12-09 15:06:04.253","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
11
|
+
{"timestamp":"2024-12-09 15:06:04.254","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{"timestamp":"2024-12-09 15:07:12.204","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-09 15:07:12.536","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-09 15:07:12.539","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-09 15:07:12.541","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-09 15:07:12.542","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-09 15:07:35.539","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-09 15:07:35.916","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
+
{"timestamp":"2024-12-09 15:07:35.918","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
+
{"timestamp":"2024-12-09 15:07:35.921","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
+
{"timestamp":"2024-12-09 15:07:35.921","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{"timestamp":"2024-12-09 15:09:48.53","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-09 15:09:48.365","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-09 15:09:48.368","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-09 15:09:48.370","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-09 15:09:48.371","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-09 15:11:58.841","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-09 15:11:59.168","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
+
{"timestamp":"2024-12-09 15:11:59.170","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
+
{"timestamp":"2024-12-09 15:11:59.173","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
+
{"timestamp":"2024-12-09 15:11:59.173","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{"timestamp":"2024-12-09 15:15:25.814","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-09 15:15:26.25","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-09 15:15:26.27","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-09 15:15:26.29","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-09 15:15:26.30","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-09 15:16:30.883","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-09 15:16:31.207","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
+
{"timestamp":"2024-12-09 15:16:31.209","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
+
{"timestamp":"2024-12-09 15:16:31.211","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
+
{"timestamp":"2024-12-09 15:16:31.211","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{"timestamp":"2024-12-09 15:50:39.260","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
2
|
+
{"timestamp":"2024-12-09 15:50:39.595","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
3
|
+
{"timestamp":"2024-12-09 15:50:39.597","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
4
|
+
{"timestamp":"2024-12-09 15:50:39.600","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
5
|
+
{"timestamp":"2024-12-09 15:50:39.600","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
6
|
+
{"timestamp":"2024-12-09 15:51:13.373","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
|
|
7
|
+
{"timestamp":"2024-12-09 15:51:13.731","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
|
|
8
|
+
{"timestamp":"2024-12-09 15:51:13.733","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
|
|
9
|
+
{"timestamp":"2024-12-09 15:51:13.736","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
|
|
10
|
+
{"timestamp":"2024-12-09 15:51:13.737","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
|
|
@@ -53,6 +53,7 @@ import CallService from "./service/CallService";
|
|
|
53
53
|
import NotFoundController from "./controller/NotFoundController";
|
|
54
54
|
import HotConfig from "./config/HotConfig";
|
|
55
55
|
import HelloConfig from "./config/HelloConfig";
|
|
56
|
+
import TestValue from "./service/TestValue";
|
|
56
57
|
|
|
57
58
|
describe("程序应用测试", () => {
|
|
58
59
|
it("获取配置", () => {
|
|
@@ -109,4 +110,12 @@ describe("程序应用测试", () => {
|
|
|
109
110
|
console.log("不变的配置", helloConfig?.hello);
|
|
110
111
|
}, 1000);
|
|
111
112
|
});
|
|
113
|
+
it("注入值判断", () => {
|
|
114
|
+
let testValue = new TestValue();
|
|
115
|
+
console.log(JSON.stringify(testValue.a));
|
|
116
|
+
console.log(JSON.stringify(testValue.b));
|
|
117
|
+
console.log(testValue.c);
|
|
118
|
+
console.log(testValue.env);
|
|
119
|
+
console.log(testValue.hello_c);
|
|
120
|
+
});
|
|
112
121
|
});
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { DemandInjection, AppEnv, Value } from "../../../../src/annotation";
|
|
2
|
+
import HelloConfig from "../config/HelloConfig";
|
|
3
|
+
|
|
4
|
+
@DemandInjection
|
|
5
|
+
export default class TestValue {
|
|
6
|
+
@Value("sys.test.a")
|
|
7
|
+
a!: any;
|
|
8
|
+
|
|
9
|
+
@Value("sys.test.a.b")
|
|
10
|
+
b!: any;
|
|
11
|
+
|
|
12
|
+
@Value("sys.test.a.b.c")
|
|
13
|
+
c!: any;
|
|
14
|
+
|
|
15
|
+
@AppEnv
|
|
16
|
+
env!: string;
|
|
17
|
+
|
|
18
|
+
@Value("a.b.c", HelloConfig)
|
|
19
|
+
hello_c!: string;
|
|
20
|
+
}
|
package/test/unit/sys2.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-10-24 12:08:15.489","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
2
|
-
{"timestamp":"2024-10-24 12:08:15.491","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
3
|
-
{"timestamp":"2024-10-24 12:08:15.491","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
|
4
|
-
{"timestamp":"2024-10-24 12:09:57.471","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
5
|
-
{"timestamp":"2024-10-24 12:09:57.478","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
6
|
-
{"timestamp":"2024-10-24 12:09:57.480","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
package/test/unit/sys3.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-10-24 12:21:01.540","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
2
|
-
{"timestamp":"2024-10-24 12:21:01.543","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
3
|
-
{"timestamp":"2024-10-24 12:21:01.543","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
|
4
|
-
{"timestamp":"2024-10-24 12:21:41.837","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
5
|
-
{"timestamp":"2024-10-24 12:21:41.842","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
6
|
-
{"timestamp":"2024-10-24 12:21:41.843","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
package/test/unit/sys4.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-10-24 12:24:49.248","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
2
|
-
{"timestamp":"2024-10-24 12:24:49.251","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
3
|
-
{"timestamp":"2024-10-24 12:24:49.251","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
|
4
|
-
{"timestamp":"2024-10-24 12:26:25.128","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
5
|
-
{"timestamp":"2024-10-24 12:26:25.131","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
6
|
-
{"timestamp":"2024-10-24 12:26:25.131","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
package/test/unit/sys5.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-10-24 12:26:43.693","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
2
|
-
{"timestamp":"2024-10-24 12:26:43.704","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
3
|
-
{"timestamp":"2024-10-24 12:26:43.707","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
|
4
|
-
{"timestamp":"2024-10-24 12:27:17.478","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
5
|
-
{"timestamp":"2024-10-24 12:27:17.484","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
6
|
-
{"timestamp":"2024-10-24 12:27:17.486","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
package/test/unit/sys6.log
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
{"timestamp":"2024-10-24 13:40:21.334","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
2
|
-
{"timestamp":"2024-10-24 13:40:21.345","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
3
|
-
{"timestamp":"2024-10-24 13:40:21.346","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|
|
4
|
-
{"timestamp":"2024-10-24 13:43:54.361","level":"INFO","label":"sys","message":{"hello":"world"}}
|
|
5
|
-
{"timestamp":"2024-10-24 13:43:54.367","level":"INFO","label":"sys","message":"1","splat":"[\"2\",\"3\"]"}
|
|
6
|
-
{"timestamp":"2024-10-24 13:43:54.368","level":"ERROR","label":"sys","message":"error ~","stack":"Error: error ~\n at Object.<anonymous> (D:\\code\\fast-car\\fastcar-core\\test\\unit\\winston-test.js:15:11)\n at Module._compile (node:internal/modules/cjs/loader:1358:14)\n at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)\n at Module.load (node:internal/modules/cjs/loader:1208:32)\n at Module._load (node:internal/modules/cjs/loader:1024:12)\n at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:174:12)\n at node:internal/main/run_main_module:28:49"}
|