@fastcar/core 0.3.0 → 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.
Files changed (40) hide show
  1. package/README.md +26 -0
  2. package/annotation.d.ts +5 -0
  3. package/package.json +2 -2
  4. package/src/FastCarApplication.ts +50 -3
  5. package/src/annotation/Application.ts +2 -1
  6. package/src/annotation/bind/AppEnv.ts +10 -0
  7. package/src/annotation/bind/BindValue.ts +16 -0
  8. package/src/annotation/bind/DemandInjection.ts +1 -2
  9. package/src/annotation/bind/Value.ts +22 -0
  10. package/src/annotation.ts +4 -0
  11. package/src/constant/FastCarMetaData.ts +1 -0
  12. package/src/type/ComponentDesc.ts +6 -0
  13. package/target/FastCarApplication.js +44 -2
  14. package/target/annotation/Application.js +3 -3
  15. package/target/annotation/bind/AppEnv.js +12 -0
  16. package/target/annotation/bind/BindValue.js +16 -0
  17. package/target/annotation/bind/Value.js +23 -0
  18. package/target/annotation.js +6 -2
  19. package/target/constant/FastCarMetaData.js +1 -0
  20. package/test/example/logs/fastcar-server.sys.log +11 -10
  21. package/test/example/logs/fastcar-server.sys1.log +10 -8
  22. package/test/example/logs/fastcar-server.sys2.log +10 -11
  23. package/test/example/logs/fastcar-server.sys3.log +10 -0
  24. package/test/example/logs/fastcar-server.sys4.log +10 -0
  25. package/test/example/resource/application.yml +4 -0
  26. package/test/example/resource/hello.yml +1 -0
  27. package/test/example/simple/app.ts +9 -0
  28. package/test/example/simple/service/TestValue.ts +20 -0
  29. package/test/multi/app.ts +2 -2
  30. package/src/annotation/stereotype/Value.ts +0 -5
  31. package/target/annotation/stereotype/Value.js +0 -5
  32. package/test/example/logs/other-server.app.log +0 -0
  33. package/test/example/logs/other-server.sys.log +0 -5
  34. package/test/example/logs/sys.log +0 -0
  35. package/test/example/logs/sys1.log +0 -0
  36. package/test/unit/sys2.log +0 -6
  37. package/test/unit/sys3.log +0 -6
  38. package/test/unit/sys4.log +0 -6
  39. package/test/unit/sys5.log +0 -6
  40. 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -29,7 +29,7 @@
29
29
  "@fastcar/core"
30
30
  ],
31
31
  "engines": {
32
- "node": ">=20"
32
+ "node": ">=16"
33
33
  },
34
34
  "dependencies": {
35
35
  "reflect-metadata": "^0.2.2",
@@ -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";
@@ -27,7 +27,7 @@ import { LifeCycleType } from "./annotation/lifeCycle/AddLifeCycleItem";
27
27
  import { WinstonLoggerType } from "./type/WinstonLoggerType";
28
28
  import { ClassConstructor } from "./type/ClassConstructor";
29
29
  import ReflectUtil from "./utils/ReflectUtil";
30
- import { Log } from "./annotation";
30
+ import Log from "./annotation/stereotype/Log";
31
31
 
32
32
  @Component
33
33
  class FastCarApplication extends Events {
@@ -39,7 +39,7 @@ class FastCarApplication extends Events {
39
39
  protected applicationStatus: AppStatusEnum;
40
40
 
41
41
  @Log("sys")
42
- protected sysLogger!: Logger;
42
+ protected sysLogger: Logger;
43
43
 
44
44
  protected componentDeatils: Map<string | symbol, ComponentDesc>; //读取路径 名称
45
45
  protected liveTime: number;
@@ -65,6 +65,8 @@ class FastCarApplication extends Events {
65
65
  this.componentAliasMap = new Map();
66
66
  this.hotConfigure = new Map();
67
67
 
68
+ this.sysLogger = console;
69
+
68
70
  this.loadSelf();
69
71
  this.addHot();
70
72
  }
@@ -534,6 +536,51 @@ class FastCarApplication extends Events {
534
536
  });
535
537
  });
536
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
+ }
537
584
  }
538
585
 
539
586
  public loadLoggerIOC(instance: Object) {
@@ -1,4 +1,3 @@
1
- import FastCarApplication from "../FastCarApplication";
2
1
  import { ClassConstructor } from "../type/ClassConstructor";
3
2
  import ClassUtils from "../utils/ClassUtils";
4
3
  import TypeUtil from "../utils/TypeUtil";
@@ -7,6 +6,8 @@ import TypeUtil from "../utils/TypeUtil";
7
6
  export default function Application(target: any) {
8
7
  return new Proxy(target, {
9
8
  construct: (target: ClassConstructor<Object>, args: any) => {
9
+ const FastCarApplication = require("../FastCarApplication").default;
10
+
10
11
  let app = new FastCarApplication();
11
12
  let appProxy = new target(...args);
12
13
  Reflect.set(appProxy, "app", app);
@@ -0,0 +1,10 @@
1
+ import BindValue from "./BindValue";
2
+
3
+ export default function AppEnv(target: Object, propertyKey: string) {
4
+ // //反向找设计类型
5
+ BindValue({
6
+ key: "application.env",
7
+ target,
8
+ propertyKey,
9
+ });
10
+ }
@@ -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
+ }
@@ -1,13 +1,12 @@
1
1
  //延迟注入作用用于类上,用于没有初始时的依赖注入
2
2
  import { CommonConstant } from "../../constant/CommonConstant";
3
- import FastCarApplication from "../../FastCarApplication";
4
3
  import { ClassConstructor } from "../../type/ClassConstructor";
5
4
 
6
5
  export default function DemandInjection(Target: ClassConstructor<any>) {
7
6
  return new Proxy(Target, {
8
7
  construct: (Target: ClassConstructor<any>, args: any) => {
9
8
  let c = new Target(...args);
10
- let app: FastCarApplication = Reflect.get(global, CommonConstant.FastcarApp);
9
+ let app: any = Reflect.get(global, CommonConstant.FastcarApp);
11
10
 
12
11
  app?.loadInjectionService(c);
13
12
  return c;
@@ -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 {
@@ -26,4 +26,5 @@ export enum FastCarMetaData {
26
26
  ComponentScanMust = "ComponentScanMust", //扫描路径
27
27
  InjectionSingleInstance = "InjectionSingleInstance", //单个实例注入的服务
28
28
  InjectionLog = "InjectionLog", //反射的日志方法
29
+ InjectionValue = "InjectionValue", //反射注入值
29
30
  }
@@ -16,3 +16,9 @@ export type InjectionMeta = {
16
16
  kind: InjectionType;
17
17
  alias?: string;
18
18
  };
19
+
20
+ export type InjectionValueMeta = {
21
+ key: string;
22
+ propertyKey: string;
23
+ relayTarget?: Object;
24
+ };
@@ -31,7 +31,7 @@ const Logger_1 = require("./interface/Logger");
31
31
  const DateUtil_1 = require("./utils/DateUtil");
32
32
  const FileHotterDesc_1 = require("./type/FileHotterDesc");
33
33
  const ReflectUtil_1 = require("./utils/ReflectUtil");
34
- const annotation_1 = require("./annotation");
34
+ const Log_1 = require("./annotation/stereotype/Log");
35
35
  let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends Events {
36
36
  componentMap; //组件键值对
37
37
  sysConfig; //系统配置
@@ -61,6 +61,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
61
61
  this.reloadTimerId = null;
62
62
  this.componentAliasMap = new Map();
63
63
  this.hotConfigure = new Map();
64
+ this.sysLogger = console;
64
65
  this.loadSelf();
65
66
  this.addHot();
66
67
  }
@@ -467,6 +468,47 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
467
468
  });
468
469
  });
469
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
+ }
470
512
  }
471
513
  loadLoggerIOC(instance) {
472
514
  let logIds = Reflect.getMetadata(FastCarMetaData_1.FastCarMetaData.InjectionLog, instance);
@@ -754,7 +796,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
754
796
  }
755
797
  };
756
798
  __decorate([
757
- (0, annotation_1.Log)("sys"),
799
+ (0, Log_1.default)("sys"),
758
800
  __metadata("design:type", Logger_1.default)
759
801
  ], FastCarApplication.prototype, "sysLogger", void 0);
760
802
  FastCarApplication = FastCarApplication_1 = __decorate([
@@ -1,14 +1,14 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.default = Application;
4
- const FastCarApplication_1 = require("../FastCarApplication");
5
4
  const ClassUtils_1 = require("../utils/ClassUtils");
6
5
  const TypeUtil_1 = require("../utils/TypeUtil");
7
6
  //基础服务的应用
8
7
  function Application(target) {
9
8
  return new Proxy(target, {
10
9
  construct: (target, args) => {
11
- let app = new FastCarApplication_1.default();
10
+ const FastCarApplication = require("../FastCarApplication").default;
11
+ let app = new FastCarApplication();
12
12
  let appProxy = new target(...args);
13
13
  Reflect.set(appProxy, "app", app);
14
14
  let keys = ClassUtils_1.default.getProtoType(target);
@@ -16,7 +16,7 @@ function Application(target) {
16
16
  if (key != "constructor") {
17
17
  let desc = ClassUtils_1.default.getProtoDesc(target, key);
18
18
  if (desc) {
19
- let beforeFun = Object.getOwnPropertyDescriptor(FastCarApplication_1.default.prototype, key)?.value;
19
+ let beforeFun = Object.getOwnPropertyDescriptor(FastCarApplication.prototype, key)?.value;
20
20
  let afterFun = desc.value;
21
21
  if (Reflect.has(app, key) && TypeUtil_1.default.isFunction(afterFun) && TypeUtil_1.default.isFunction(beforeFun)) {
22
22
  let mixFn = async (...args) => {
@@ -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
+ }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BaseFilePath = exports.ENV = exports.Transactional = exports.SqlSession = exports.Entity = exports.Table = exports.PrimaryKey = exports.Field = exports.DBType = exports.DSIndex = exports.DS = 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 = 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 = {}));
@@ -1,10 +1,11 @@
1
- {"timestamp":"2024-12-03 21:04:11.499","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
2
- {"timestamp":"2024-12-03 21:04:11.802","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
3
- {"timestamp":"2024-12-03 21:04:11.805","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
- {"timestamp":"2024-12-03 21:04:11.808","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
- {"timestamp":"2024-12-03 21:04:11.809","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
- {"timestamp":"2024-12-04 10:41:41.933","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
7
- {"timestamp":"2024-12-04 10:41:42.256","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
8
- {"timestamp":"2024-12-04 10:41:42.258","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
9
- {"timestamp":"2024-12-04 10:41:42.260","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
10
- {"timestamp":"2024-12-04 10:41:42.260","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
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"}
@@ -1,8 +1,10 @@
1
- {"timestamp":"2024-12-04 10:46:19.406","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
2
- {"timestamp":"2024-12-04 10:46:19.697","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
3
- {"timestamp":"2024-12-04 10:46:19.700","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
- {"timestamp":"2024-12-04 10:46:19.701","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
- {"timestamp":"2024-12-04 10:46:19.702","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
- {"timestamp":"2024-12-04 10:46:32.426","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
7
- {"timestamp":"2024-12-04 10:46:37.328","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
8
- {"timestamp":"2024-12-04 10:46:39.653","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
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"}
@@ -1,11 +1,10 @@
1
- {"timestamp":"2024-12-04 10:49:26.216","level":"INFO","label":"fastcar-server.sys","message":"Start scanning component"}
2
- {"timestamp":"2024-12-04 10:49:26.499","level":"INFO","label":"fastcar-server.sys","message":"Complete component scan"}
3
- {"timestamp":"2024-12-04 10:49:26.502","level":"INFO","label":"fastcar-server.sys","message":"Call application initialization method"}
4
- {"timestamp":"2024-12-04 10:49:26.505","level":"INFO","label":"fastcar-server.sys","message":"start server app is run"}
5
- {"timestamp":"2024-12-04 10:49:26.506","level":"INFO","label":"fastcar-server.sys","message":"version 1.0.0"}
6
- {"timestamp":"2024-12-04 10:49:32.122","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
7
- {"timestamp":"2024-12-04 10:49:36.193","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
8
- {"timestamp":"2024-12-04 10:49:40.181","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
9
- {"timestamp":"2024-12-04 10:49:43.876","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
10
- {"timestamp":"2024-12-04 10:49:46.833","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
11
- {"timestamp":"2024-12-04 10:49:52.191","level":"INFO","label":"fastcar-server.sys","message":"hot update---D:\\code\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
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"}
@@ -1,4 +1,5 @@
1
1
  application:
2
+ env: dev
2
3
  scan:
3
4
  exclude: ["noclude"]
4
5
  settings:
@@ -10,3 +11,6 @@ settings:
10
11
  maxsize: 1024
11
12
  maxFiles: 10
12
13
  printConsole: true
14
+ test:
15
+ a:
16
+ b: { hello: "world", c: "c" }
@@ -1 +1,2 @@
1
1
  hello: "world"
2
+ a: { b: { c: c } }
@@ -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/multi/app.ts CHANGED
@@ -10,6 +10,6 @@ class APP {
10
10
 
11
11
  let instance = new APP();
12
12
  setTimeout(() => {
13
- let c: CService = instance.app.getComponentByTarget(CService);
14
- c.test();
13
+ let c = instance.app.getComponentByTarget<CService>(CService);
14
+ c?.test();
15
15
  }, 1000);
@@ -1,5 +0,0 @@
1
- //获取原属性值
2
-
3
- //application 代表系统参数
4
- //setting 代表系统其余参数
5
- //其他默认第一个代表 资源路径下的地址
@@ -1,5 +0,0 @@
1
- "use strict";
2
- //获取原属性值
3
- //application 代表系统参数
4
- //setting 代表系统其余参数
5
- //其他默认第一个代表 资源路径下的地址
File without changes
@@ -1,5 +0,0 @@
1
- {"timestamp":"2024-12-03 21:04:24.672","level":"INFO","label":"other-server.sys","message":"Start scanning component"}
2
- {"timestamp":"2024-12-03 21:04:25.431","level":"INFO","label":"other-server.sys","message":"Complete component scan"}
3
- {"timestamp":"2024-12-03 21:04:25.433","level":"INFO","label":"other-server.sys","message":"Call application initialization method"}
4
- {"timestamp":"2024-12-03 21:04:25.436","level":"INFO","label":"other-server.sys","message":"start server app is run"}
5
- {"timestamp":"2024-12-03 21:04:25.437","level":"INFO","label":"other-server.sys","message":"version 1.0.0"}
File without changes
File without changes
@@ -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"}
@@ -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"}
@@ -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"}
@@ -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"}
@@ -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"}