@fastcar/core 0.2.38 → 0.2.40

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 CHANGED
@@ -20,7 +20,7 @@
20
20
 
21
21
  ## 快速安装
22
22
 
23
- npm install fastcar-core
23
+ npm install fastcar@core
24
24
 
25
25
  ## 常用注解引用
26
26
 
@@ -135,7 +135,7 @@ ResourcePath 自定义resource的位置
135
135
 
136
136
  ```ts
137
137
  //声明一个组件
138
- import { Service } from "fastcar-core/annotation";
138
+ import { Service } from "@fastcar/core/annotation";
139
139
 
140
140
  @Service
141
141
  class HelloService {
@@ -149,7 +149,7 @@ export default HelloService;
149
149
 
150
150
  ```ts
151
151
  //声明一个别名组件
152
- import { Service, BeanName } from "fastcar-core/annotation";
152
+ import { Service, BeanName } from "@fastcar/core/annotation";
153
153
 
154
154
  @Service
155
155
  @BeanName("HelloService")
@@ -164,7 +164,7 @@ export default HelloService;
164
164
 
165
165
  ```ts
166
166
  //引入依赖组件
167
- import { Controller, Autowired } from "fastcar-core/annotation";
167
+ import { Controller, Autowired } from "@fastcar/core/annotation";
168
168
 
169
169
  @Controller
170
170
  class HelloController {
@@ -181,7 +181,7 @@ class HelloController {
181
181
 
182
182
  ```ts
183
183
  //生命周期内运行
184
- import { ApplicationStart } from "fastcar-core/annotation";
184
+ import { ApplicationStart } from "@fastcar/core/annotation";
185
185
 
186
186
  @ApplicationStart()
187
187
  export default class StartRunner {
@@ -204,8 +204,8 @@ export default class StartRunner {
204
204
 
205
205
  ```ts
206
206
  //声明入口应用 这边有个约定 启动后会自动扫描所在文件夹下的文件 并进行注入
207
- import { FastCarApplication } from "fastcar-core";
208
- import { Application } from "fastcar-core/annotation";
207
+ import { FastCarApplication } from "@fastcar/core";
208
+ import { Application } from "@fastcar/core/annotation";
209
209
 
210
210
  @Application //声明是一个应用
211
211
  @ENV("TEST") //声明为TEST环境或者在resource下的application.yml内声明
@@ -217,7 +217,7 @@ class APP {
217
217
 
218
218
  ```ts
219
219
  //表单示例
220
- import { NotNull, Size, Rule, ValidForm } from "fastcar-core/annotation";
220
+ import { NotNull, Size, Rule, ValidForm } from "@fastcar/core/annotation";
221
221
 
222
222
  class B {
223
223
  @NotNull
@@ -241,7 +241,7 @@ instance.test("a", { c: "c", d: 13 }); //校验失败
241
241
 
242
242
  ```ts
243
243
  //本地配置映射示例
244
- import { Configure } from "fastcar-core/annotation";
244
+ import { Configure } from "@fastcar/core/annotation";
245
245
 
246
246
  //读取resource下的配置 如hello.yml中为hello: "world"
247
247
  @Configure("hello.yml")
@@ -259,7 +259,7 @@ class HelloConfig {
259
259
  ```ts
260
260
  //调用依赖版本示例
261
261
  import HelloService from "./HelloService";
262
- import { CallDependency } from "fastcar-core/annotation";
262
+ import { CallDependency } from "@fastcar/core/annotation";
263
263
 
264
264
  export default class CallService {
265
265
 
@@ -290,7 +290,7 @@ export default class IndexController {
290
290
 
291
291
  ```ts
292
292
  //改造一个好用的map-list数据链表
293
- import { DataMap } from "fastcar-core";
293
+ import { DataMap } from "@fastcar/core";
294
294
 
295
295
  describe("数据集合测试", () => {
296
296
  it("数据集合", () => {
@@ -340,8 +340,8 @@ describe("数据集合测试", () => {
340
340
 
341
341
  ```ts
342
342
  //根据启动应用的时机 加载自定义方法
343
- import { ApplicationHook, FastCarApplication, Logger } from "fastcar-core";
344
- import { Application } from "fastcar-core/annotation";
343
+ import { ApplicationHook, FastCarApplication, Logger } from "@fastcar/core";
344
+ import { Application } from "@fastcar/core/annotation";
345
345
 
346
346
  @Application
347
347
  class APP implements ApplicationHook {
@@ -370,7 +370,7 @@ class APP implements ApplicationHook {
370
370
 
371
371
  ## 更多用法
372
372
 
373
- 参考项目git地址 fastcar-core/test 下的simple内
373
+ 参考项目git地址 @fastcar/core/test 下的simple内
374
374
 
375
375
  ## 项目开源地址
376
376
 
package/index.d.ts CHANGED
@@ -149,6 +149,11 @@ export class FastCarApplication extends Events {
149
149
  */
150
150
  getComponentDetailsList(): ComponentDesc[];
151
151
 
152
+ /**
153
+ * @version 1.0 判断组件是否存在
154
+ */
155
+ hasComponentByName(name: string | symbol): boolean;
156
+
152
157
  /**
153
158
  * @version 1.0 开启日志系统
154
159
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fastcar/core",
3
- "version": "0.2.38",
3
+ "version": "0.2.40",
4
4
  "homepage": "https://github.com/williamDazhangyu/fast-car",
5
5
  "main": "target/index.js",
6
6
  "author": "william_zhong",
@@ -26,7 +26,7 @@
26
26
  "ioc",
27
27
  "spring",
28
28
  "node",
29
- "fastcar-core"
29
+ "@fastcar/core"
30
30
  ],
31
31
  "engines": {
32
32
  "node": ">=16"
@@ -1,4 +1,5 @@
1
1
  import "reflect-metadata";
2
+ import * as fs from "fs";
2
3
  import * as process from "process";
3
4
  import * as Events from "events";
4
5
  import * as path from "path";
@@ -12,7 +13,6 @@ import { ApplicationConfig } from "./config/ApplicationConfig";
12
13
  import { ComponentKind } from "./constant/ComponentKind";
13
14
  import { CommonConstant } from "./constant/CommonConstant";
14
15
  import { LifeCycleModule } from "./constant/LifeCycleModule";
15
- import * as fs from "fs";
16
16
  import { AppStatusEnum } from "./constant/AppStatusEnum";
17
17
  import ValidationUtil from "./utils/ValidationUtil";
18
18
  import Component from "./annotation/stereotype/Component";
@@ -25,6 +25,7 @@ import { ProcessType } from "./type/ProcessType";
25
25
  import { FileHotterDesc } from "./type/FileHotterDesc";
26
26
  import { LifeCycleType } from "./annotation/lifeCycle/AddLifeCycleItem";
27
27
  import { WinstonLoggerType } from "./type/WinstonLoggerType";
28
+ import { Log } from "./annotation";
28
29
 
29
30
  @Component
30
31
  class FastCarApplication extends Events {
@@ -34,7 +35,10 @@ class FastCarApplication extends Events {
34
35
  protected baseFileName!: string; //入口文件路径
35
36
  protected loggerFactory!: WinstonLogger;
36
37
  protected applicationStatus: AppStatusEnum;
38
+
39
+ @Log("sys")
37
40
  protected sysLogger!: winston.Logger;
41
+
38
42
  protected componentDeatils: Map<string | symbol, ComponentDesc>; //读取路径 名称
39
43
  protected liveTime: number;
40
44
  protected watchFiles: Map<string, FileHotterDesc[]>;
@@ -168,7 +172,7 @@ class FastCarApplication extends Events {
168
172
  loadSysConfig() {
169
173
  this.sysConfig = FileUtil.getApplicationConfig(this.getResourcePath(), CommonConstant.Application, this.sysConfig);
170
174
 
171
- let env = Reflect.get(this, CommonConstant.ENV) || this.sysConfig.application.env;
175
+ let env = (Reflect.get(this, CommonConstant.ENV) || this.sysConfig.application.env || "devlopment") as string;
172
176
 
173
177
  this.sysConfig = FileUtil.getApplicationConfig(this.getResourcePath(), `${CommonConstant.Application}-${env}`, this.sysConfig);
174
178
 
@@ -241,7 +245,7 @@ class FastCarApplication extends Events {
241
245
  loadClass() {
242
246
  //加载文件扫描下的bean
243
247
  let tmpFilePath: string[] = Array.of();
244
- let includeList: string[] = Reflect.get(this, FastCarMetaData.ComponentScan);
248
+ let includeList: string[] = Reflect.get(this, FastCarMetaData.ComponentScan) as string[];
245
249
 
246
250
  if (includeList) {
247
251
  includeList.forEach((item) => {
@@ -254,7 +258,7 @@ class FastCarApplication extends Events {
254
258
  filePathList = tmpFilePath.concat(filePathList);
255
259
  filePathList = [...new Set(filePathList)];
256
260
 
257
- let excludeList: string[] = Reflect.get(this, FastCarMetaData.ComponentScanExclusion);
261
+ let excludeList: string[] = Reflect.get(this, FastCarMetaData.ComponentScanExclusion) as string[];
258
262
  if (excludeList) {
259
263
  let excludAllPath: string[] = [];
260
264
  excludeList.forEach((item) => {
@@ -469,7 +473,7 @@ class FastCarApplication extends Events {
469
473
  /***
470
474
  * @version 1.0 判断是否拥有组件名称
471
475
  */
472
- hasComponentByName(name: string | symbol): any {
476
+ hasComponentByName(name: string | symbol): boolean {
473
477
  return this.componentMap.has(name);
474
478
  }
475
479
 
@@ -519,7 +523,7 @@ class FastCarApplication extends Events {
519
523
 
520
524
  this.loggerFactory = new WinstonLogger(defaultConfig);
521
525
  //添加系统日志
522
- this.sysLogger = this.loggerFactory.addLogger(CommonConstant.SYSLOGGER);
526
+ // this.sysLogger = this.loggerFactory.addLogger(CommonConstant.SYSLOGGER);
523
527
  }
524
528
 
525
529
  /***
@@ -527,8 +531,8 @@ class FastCarApplication extends Events {
527
531
  */
528
532
  init() {
529
533
  //加载配置
530
- this.basePath = Reflect.get(this, CommonConstant.BasePath) || require.main?.path || module.path;
531
- this.baseFileName = Reflect.get(this, CommonConstant.BaseFileName) || require.main?.filename || module.filename;
534
+ this.basePath = (Reflect.get(this, CommonConstant.BasePath) || require.main?.path || module.path) as string;
535
+ this.baseFileName = (Reflect.get(this, CommonConstant.BaseFileName) || require.main?.filename || module.filename) as string;
532
536
 
533
537
  this.beforeStartServer();
534
538
  this.startServer();
@@ -1,5 +1,5 @@
1
1
  import { CommonConstant } from "../../constant/CommonConstant";
2
- import FastCarApplication from "../../FastCarApplication";
2
+ import ApplicationInterface from "../../interface/ApplicationInterface";
3
3
 
4
4
  /***
5
5
  * @version 1.0 根据别名注入依赖
@@ -9,7 +9,7 @@ export default function AliasInjection(alias: string) {
9
9
  return function (target: any, propertyKey: string) {
10
10
  Reflect.defineProperty(target, propertyKey, {
11
11
  get: () => {
12
- let app: FastCarApplication = Reflect.get(global, CommonConstant.FastcarApp);
12
+ let app: ApplicationInterface = Reflect.get(global, CommonConstant.FastcarApp);
13
13
 
14
14
  if (!app.hasComponentByName(alias)) {
15
15
  //找不到依赖组件异常
@@ -1,6 +1,6 @@
1
1
  import "reflect-metadata";
2
2
  import { CommonConstant } from "../../constant/CommonConstant";
3
- import FastCarApplication from "../../FastCarApplication";
3
+ import ApplicationInterface from "../../interface/ApplicationInterface";
4
4
  import DataSourceManager from "../../interface/DataSourceManager";
5
5
  import Logger from "../../interface/Logger";
6
6
  import { DesignMeta } from "../../type/DesignMeta";
@@ -11,7 +11,7 @@ import SqlError from "../../type/SqlError";
11
11
  * */
12
12
  export default function Transactional(driver: string = "MysqlDataSourceManager") {
13
13
  return function (target: any, methodName: string, descriptor: PropertyDescriptor) {
14
- const orignFunction = descriptor.value;
14
+ const orignFunction: Function = descriptor.value;
15
15
 
16
16
  //在初始化时就应该检测是否注入了sessionID
17
17
  const paramsIndex = Reflect.getOwnMetadata(DesignMeta.sqlSession, target, methodName);
@@ -22,7 +22,7 @@ export default function Transactional(driver: string = "MysqlDataSourceManager")
22
22
  descriptor.value = async function (...args: any[]) {
23
23
  //创建会话id
24
24
 
25
- let app: FastCarApplication = Reflect.get(global, CommonConstant.FastcarApp);
25
+ let app: ApplicationInterface = Reflect.get(global, CommonConstant.FastcarApp);
26
26
 
27
27
  let sysLogger: Logger = app.getSysLogger() || console;
28
28
  let dsm: DataSourceManager = app.getComponentByName(driver);
@@ -1,10 +1,10 @@
1
1
  import "reflect-metadata";
2
- import CryptoUtil from "../../utils/CryptoUtil";
3
2
  import { FastCarMetaData } from "../../constant/FastCarMetaData";
3
+ import { id } from "../../utils/Id";
4
4
 
5
5
  export default function Injection(target: any, name: string) {
6
6
  //生成别名 避免名称重复的情况
7
- let key = `${name}:${CryptoUtil.getHashStr()}`;
7
+ let key = `${name}:${id()}`;
8
8
  Reflect.defineMetadata(name, true, target.prototype);
9
9
  Reflect.defineMetadata(FastCarMetaData.InjectionUniqueKey, key, target); //放入至原型中
10
10
  }
@@ -1,5 +1,5 @@
1
1
  import { CommonConstant } from "../../constant/CommonConstant";
2
- import FastCarApplication from "../../FastCarApplication";
2
+ import ApplicationInterface from "../../interface/ApplicationInterface";
3
3
  import Logger from "../../interface/Logger";
4
4
 
5
5
  //日志实例
@@ -9,8 +9,9 @@ export default function Log(category?: string) {
9
9
 
10
10
  Reflect.defineProperty(target, propertyKey, {
11
11
  get: (): Logger => {
12
- let app: FastCarApplication = Reflect.get(global, CommonConstant.FastcarApp);
13
- return app ? app.getLogger(m) : console;
12
+ let app: ApplicationInterface = Reflect.get(global, CommonConstant.FastcarApp);
13
+ let appid = app.getSetting(CommonConstant.APPId) || ""; //进行差异化区分
14
+ return app ? app.getLogger(appid ? `[${appid}] ${m}` : m) : console;
14
15
  },
15
16
  });
16
17
  };
@@ -1,5 +1,4 @@
1
1
  import AddChildValid from "./AddChildValid";
2
- import ValidationUtil from "../../utils/ValidationUtil";
3
2
 
4
3
  //是否为非空字段
5
4
  export default function NotNull(target: any, propertyKey: string, index?: number) {
@@ -9,6 +9,7 @@ export const CommonConstant = {
9
9
  FastcarApp: Symbol("FastcarApp"), //应用app
10
10
  FastcarSetting: Symbol("FastcarSetting"),
11
11
  ResourcePath: "resourcePath",
12
+ APPId: "appid",
12
13
  };
13
14
 
14
15
  export const FileResSuffix = ["json", "yml", "js"];
@@ -0,0 +1,206 @@
1
+ import { ApplicationConfig } from "../config/ApplicationConfig";
2
+ import { ComponentKind } from "../constant/ComponentKind";
3
+ import { LifeCycleModule } from "../constant/LifeCycleModule";
4
+ import { ComponentDesc } from "../type/ComponentDesc";
5
+ import { ProcessType } from "../type/ProcessType";
6
+ import Logger from "./Logger";
7
+
8
+ export default interface ApplicationInterface {
9
+ /***
10
+ * @version 1.0 根据原型加载注入的方法
11
+ *
12
+ */
13
+ getInjectionUniqueKey(target: Object): string;
14
+
15
+ /**
16
+ * @version 1.0 自身作为一个组件注入进去
17
+ */
18
+ loadSelf(): void;
19
+
20
+ /***
21
+ * @version 1.0 热更新组件
22
+ */
23
+ addHot(): void;
24
+
25
+ /**
26
+ * @version 1.0 获取资源路径
27
+ */
28
+ getResourcePath(): string;
29
+
30
+ /***
31
+ * @version 1.0 获取项目的基本路径
32
+ *
33
+ */
34
+ getBasePath(): string;
35
+
36
+ /**
37
+ * @version 1.0 加载系统配置 加载顺序为 default json < yaml < env
38
+ *
39
+ */
40
+ loadSysConfig(): void;
41
+
42
+ setSetting(key: string | symbol, value: any): void;
43
+
44
+ /**
45
+ * @version 1.0 获取自定义设置 设置优先级 配置自定义>系统配置>初始化
46
+ * @param key
47
+ */
48
+ getSetting(key: string | symbol): any;
49
+
50
+ /**
51
+ * @version 1.0 获取应用配置
52
+ * @return
53
+ */
54
+ getapplicationConfig(): ApplicationConfig;
55
+
56
+ /**
57
+ * @version 1.0 扫描组件
58
+ */
59
+ loadClass(): void;
60
+
61
+ /***
62
+ * @version 1.0 装配单个模块
63
+ * @deprecated 修改为主动查找时装配
64
+ */
65
+ injectionModule(instance: any, instanceName: string | symbol): void;
66
+
67
+ /***
68
+ * @version 1.0 根据名称获取组件的加载情况
69
+ *
70
+ */
71
+ getComponentDetailByName(name: string | symbol): ComponentDesc | undefined;
72
+
73
+ /***
74
+ * @version 1.0 根据原型获取组件的加载信息
75
+ *
76
+ */
77
+ getComponentDetailByTarget(target: Object): ComponentDesc | undefined;
78
+
79
+ /**
80
+ * @version 1.0 加载需要注入的类
81
+ * @deprecated 修改为主动查找时装配
82
+ */
83
+ loadInjectionModule(): void;
84
+
85
+ /**
86
+ * @version 1.0 根据类型获取组件
87
+ * @param name
88
+ * @return
89
+ */
90
+ getComponentByType(name: ComponentKind): any[];
91
+
92
+ /**
93
+ * @version 1.0 获取全部的组件列表
94
+ * @return
95
+ */
96
+ getComponentList(): any[];
97
+
98
+ /**
99
+ * @version 1.0 根据名称组件
100
+ * @param name
101
+ */
102
+ getComponentByName(name: string | symbol): any;
103
+
104
+ /***
105
+ * @version 1.0 根据原型获取实例
106
+ */
107
+ getComponentByTarget(target: Object): any;
108
+
109
+ /**
110
+ * @version 1.0 获取组件详情列表
111
+ *
112
+ */
113
+ getComponentDetailsList(): ComponentDesc[];
114
+
115
+ /**
116
+ * @version 1.0 判断组件是否存在
117
+ */
118
+ hasComponentByName(name: string | symbol): boolean;
119
+
120
+ /**
121
+ * @version 1.0 开启日志系统
122
+ */
123
+ startLog(): void;
124
+
125
+ /**
126
+ * @version 1.0 初始化应用
127
+ */
128
+ init(): void;
129
+
130
+ /***
131
+ * @version 1.0 退出事件监听
132
+ *
133
+ */
134
+ addExitEvent(): void;
135
+
136
+ /***
137
+ * @version 1.0 异常事件进行监听 不至于程序异常直接退出
138
+ */
139
+ addExecptionEvent(): void;
140
+
141
+ /**
142
+ * @version 1.0 自动调用方法
143
+ * @param name
144
+ */
145
+ automaticRun(name: LifeCycleModule): void;
146
+
147
+ /**
148
+ * @version 1.0 开启应用前执行的操作 加载配置,扫描组件,注入依赖组件
149
+ */
150
+ beforeStartServer(): void;
151
+
152
+ /**
153
+ * @version 1.0 启动服务
154
+ */
155
+ startServer(): void;
156
+
157
+ /**
158
+ * @version 1.0 停止服务前自动调用服务
159
+ */
160
+ beforeStopServer(): void;
161
+
162
+ /**
163
+ * @version 1.0 停止服务
164
+ */
165
+ stopServer(): void;
166
+
167
+ /**
168
+ * @version 1.0 获取app名称
169
+ */
170
+ getApplicationName(): string;
171
+
172
+ /***
173
+ * @version 1.0 获取系统日志
174
+ *
175
+ */
176
+ getSysLogger(): Logger;
177
+
178
+ /***
179
+ * @version 0.2.11 根据名称获取logger
180
+ *
181
+ */
182
+ getLogger(category?: string): Logger;
183
+
184
+ /***
185
+ * @version 1.0 获取文件内容
186
+ */
187
+ getFileContent(fp: string): string;
188
+
189
+ /***
190
+ * @version 1.0 是否支持热更
191
+ *
192
+ */
193
+ isHotter(): boolean;
194
+
195
+ /**
196
+ * @version 1.0 指定热更新文件
197
+ *
198
+ */
199
+ specifyHotUpdate(fp: string): void;
200
+
201
+ /***
202
+ * @version 1.0 获取进程的信息
203
+ *
204
+ */
205
+ getMemoryUsage(): ProcessType;
206
+ }
@@ -0,0 +1,8 @@
1
+ //生成唯一ID
2
+ let idCounter = 0;
3
+
4
+ function id(): number {
5
+ return ++idCounter;
6
+ }
7
+
8
+ export { id };
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
11
11
  var FastCarApplication_1;
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  require("reflect-metadata");
14
+ const fs = require("fs");
14
15
  const process = require("process");
15
16
  const Events = require("events");
16
17
  const path = require("path");
@@ -22,12 +23,13 @@ const SysConfig_1 = require("./config/SysConfig");
22
23
  const FastCarMetaData_1 = require("./constant/FastCarMetaData");
23
24
  const CommonConstant_1 = require("./constant/CommonConstant");
24
25
  const LifeCycleModule_1 = require("./constant/LifeCycleModule");
25
- const fs = require("fs");
26
26
  const AppStatusEnum_1 = require("./constant/AppStatusEnum");
27
27
  const ValidationUtil_1 = require("./utils/ValidationUtil");
28
28
  const Component_1 = require("./annotation/stereotype/Component");
29
29
  const WinstonLogger_1 = require("./model/WinstonLogger");
30
+ const winston = require("winston");
30
31
  const DateUtil_1 = require("./utils/DateUtil");
32
+ const annotation_1 = require("./annotation");
31
33
  let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends Events {
32
34
  constructor() {
33
35
  super();
@@ -142,7 +144,7 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
142
144
  */
143
145
  loadSysConfig() {
144
146
  this.sysConfig = FileUtil_1.default.getApplicationConfig(this.getResourcePath(), CommonConstant_1.CommonConstant.Application, this.sysConfig);
145
- let env = Reflect.get(this, CommonConstant_1.CommonConstant.ENV) || this.sysConfig.application.env;
147
+ let env = (Reflect.get(this, CommonConstant_1.CommonConstant.ENV) || this.sysConfig.application.env || "devlopment");
146
148
  this.sysConfig = FileUtil_1.default.getApplicationConfig(this.getResourcePath(), `${CommonConstant_1.CommonConstant.Application}-${env}`, this.sysConfig);
147
149
  //自定义环境变量设置
148
150
  process.env.NODE_ENV = env;
@@ -450,15 +452,15 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
450
452
  }
451
453
  this.loggerFactory = new WinstonLogger_1.default(defaultConfig);
452
454
  //添加系统日志
453
- this.sysLogger = this.loggerFactory.addLogger(CommonConstant_1.CommonConstant.SYSLOGGER);
455
+ // this.sysLogger = this.loggerFactory.addLogger(CommonConstant.SYSLOGGER);
454
456
  }
455
457
  /***
456
458
  * @version 1.0 初始化应用
457
459
  */
458
460
  init() {
459
461
  //加载配置
460
- this.basePath = Reflect.get(this, CommonConstant_1.CommonConstant.BasePath) || require.main?.path || module.path;
461
- this.baseFileName = Reflect.get(this, CommonConstant_1.CommonConstant.BaseFileName) || require.main?.filename || module.filename;
462
+ this.basePath = (Reflect.get(this, CommonConstant_1.CommonConstant.BasePath) || require.main?.path || module.path);
463
+ this.baseFileName = (Reflect.get(this, CommonConstant_1.CommonConstant.BaseFileName) || require.main?.filename || module.filename);
462
464
  this.beforeStartServer();
463
465
  this.startServer();
464
466
  this.addExitEvent();
@@ -654,6 +656,10 @@ let FastCarApplication = FastCarApplication_1 = class FastCarApplication extends
654
656
  return logger;
655
657
  }
656
658
  };
659
+ __decorate([
660
+ (0, annotation_1.Log)("sys"),
661
+ __metadata("design:type", Object)
662
+ ], FastCarApplication.prototype, "sysLogger", void 0);
657
663
  FastCarApplication = FastCarApplication_1 = __decorate([
658
664
  Component_1.default,
659
665
  __metadata("design:paramtypes", [])
@@ -1,11 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  require("reflect-metadata");
4
- const CryptoUtil_1 = require("../../utils/CryptoUtil");
5
4
  const FastCarMetaData_1 = require("../../constant/FastCarMetaData");
5
+ const Id_1 = require("../../utils/Id");
6
6
  function Injection(target, name) {
7
7
  //生成别名 避免名称重复的情况
8
- let key = `${name}:${CryptoUtil_1.default.getHashStr()}`;
8
+ let key = `${name}:${(0, Id_1.id)()}`;
9
9
  Reflect.defineMetadata(name, true, target.prototype);
10
10
  Reflect.defineMetadata(FastCarMetaData_1.FastCarMetaData.InjectionUniqueKey, key, target); //放入至原型中
11
11
  }
@@ -8,7 +8,8 @@ function Log(category) {
8
8
  Reflect.defineProperty(target, propertyKey, {
9
9
  get: () => {
10
10
  let app = Reflect.get(global, CommonConstant_1.CommonConstant.FastcarApp);
11
- return app ? app.getLogger(m) : console;
11
+ let appid = app.getSetting(CommonConstant_1.CommonConstant.APPId) || ""; //进行差异化区分
12
+ return app ? app.getLogger(appid ? `[${appid}] ${m}` : m) : console;
12
13
  },
13
14
  });
14
15
  };
@@ -12,5 +12,6 @@ exports.CommonConstant = {
12
12
  FastcarApp: Symbol("FastcarApp"),
13
13
  FastcarSetting: Symbol("FastcarSetting"),
14
14
  ResourcePath: "resourcePath",
15
+ APPId: "appid",
15
16
  };
16
17
  exports.FileResSuffix = ["json", "yml", "js"];
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.id = void 0;
4
+ //生成唯一ID
5
+ let idCounter = 0;
6
+ function id() {
7
+ return ++idCounter;
8
+ }
9
+ exports.id = id;
File without changes
@@ -0,0 +1,9 @@
1
+ {"timestamp":"2022-12-21 17:57:11.546","level":"INFO","label":"[fastcar-server] logger","message":"自定义的日志输出"}
2
+ {"timestamp":"2022-12-21 17:57:11.547","level":"WARN","label":"[fastcar-server] logger","message":"自定义警告"}
3
+ {"timestamp":"2022-12-21 17:57:11.548","level":"ERROR","label":"[fastcar-server] logger","message":"自定义报错"}
4
+ {"timestamp":"2022-12-21 18:00:16.672","level":"INFO","label":"[fastcar-server] logger","message":"自定义的日志输出"}
5
+ {"timestamp":"2022-12-21 18:00:16.673","level":"WARN","label":"[fastcar-server] logger","message":"自定义警告"}
6
+ {"timestamp":"2022-12-21 18:00:16.674","level":"ERROR","label":"[fastcar-server] logger","message":"自定义报错"}
7
+ {"timestamp":"2023-01-04 16:48:09.670","level":"INFO","label":"[fastcar-server] logger","message":"自定义的日志输出"}
8
+ {"timestamp":"2023-01-04 16:48:09.671","level":"WARN","label":"[fastcar-server] logger","message":"自定义警告"}
9
+ {"timestamp":"2023-01-04 16:48:09.672","level":"ERROR","label":"[fastcar-server] logger","message":"自定义报错"}
@@ -0,0 +1,8 @@
1
+ {"timestamp":"2022-12-21 18:00:16.571","level":"INFO","label":"[fastcar-server] sys","message":"Start scanning component"}
2
+ {"timestamp":"2022-12-21 18:00:16.660","level":"INFO","label":"[fastcar-server] sys","message":"Complete component scan"}
3
+ {"timestamp":"2022-12-21 18:00:16.662","level":"INFO","label":"[fastcar-server] sys","message":"Call application initialization method"}
4
+ {"timestamp":"2022-12-21 18:00:16.664","level":"INFO","label":"[fastcar-server] sys","message":"start server app is run"}
5
+ {"timestamp":"2022-12-21 18:00:16.665","level":"INFO","label":"[fastcar-server] sys","message":"version 1.0.0"}
6
+ {"timestamp":"2022-12-21 18:00:18.691","level":"INFO","label":"[fastcar-server] sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
7
+ {"timestamp":"2022-12-21 18:00:18.692","level":"INFO","label":"[fastcar-server] sys","message":"Call the method before the application stops"}
8
+ {"timestamp":"2022-12-21 18:00:23.695","level":"INFO","label":"[fastcar-server] sys","message":"application stop"}
@@ -0,0 +1,8 @@
1
+ {"timestamp":"2023-01-04 16:48:09.561","level":"INFO","label":"[fastcar-server] sys","message":"Start scanning component"}
2
+ {"timestamp":"2023-01-04 16:48:09.655","level":"INFO","label":"[fastcar-server] sys","message":"Complete component scan"}
3
+ {"timestamp":"2023-01-04 16:48:09.657","level":"INFO","label":"[fastcar-server] sys","message":"Call application initialization method"}
4
+ {"timestamp":"2023-01-04 16:48:09.660","level":"INFO","label":"[fastcar-server] sys","message":"start server app is run"}
5
+ {"timestamp":"2023-01-04 16:48:09.660","level":"INFO","label":"[fastcar-server] sys","message":"version 1.0.0"}
6
+ {"timestamp":"2023-01-04 16:48:11.690","level":"INFO","label":"[fastcar-server] sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
7
+ {"timestamp":"2023-01-04 16:48:11.691","level":"INFO","label":"[fastcar-server] sys","message":"Call the method before the application stops"}
8
+ {"timestamp":"2023-01-04 16:48:16.703","level":"INFO","label":"[fastcar-server] sys","message":"application stop"}
@@ -4,3 +4,9 @@
4
4
  {"timestamp":"2022-09-22 14:05:29.436","level":"INFO","label":"logger","message":"自定义的日志输出"}
5
5
  {"timestamp":"2022-09-22 14:05:29.437","level":"WARN","label":"logger","message":"自定义警告"}
6
6
  {"timestamp":"2022-09-22 14:05:29.438","level":"ERROR","label":"logger","message":"自定义报错"}
7
+ {"timestamp":"2022-12-13 17:56:56.447","level":"INFO","label":"logger","message":"自定义的日志输出"}
8
+ {"timestamp":"2022-12-13 17:56:56.448","level":"WARN","label":"logger","message":"自定义警告"}
9
+ {"timestamp":"2022-12-13 17:56:56.449","level":"ERROR","label":"logger","message":"自定义报错"}
10
+ {"timestamp":"2022-12-13 17:57:38.950","level":"INFO","label":"logger","message":"自定义的日志输出"}
11
+ {"timestamp":"2022-12-13 17:57:38.952","level":"WARN","label":"logger","message":"自定义警告"}
12
+ {"timestamp":"2022-12-13 17:57:38.953","level":"ERROR","label":"logger","message":"自定义报错"}
@@ -0,0 +1,6 @@
1
+ {"timestamp":"2022-12-13 17:59:51.490","level":"INFO","label":"logger","message":"自定义的日志输出"}
2
+ {"timestamp":"2022-12-13 17:59:51.491","level":"WARN","label":"logger","message":"自定义警告"}
3
+ {"timestamp":"2022-12-13 17:59:51.492","level":"ERROR","label":"logger","message":"自定义报错"}
4
+ {"timestamp":"2022-12-13 18:00:45.217","level":"INFO","label":"logger","message":"自定义的日志输出"}
5
+ {"timestamp":"2022-12-13 18:00:45.218","level":"WARN","label":"logger","message":"自定义警告"}
6
+ {"timestamp":"2022-12-13 18:00:45.219","level":"ERROR","label":"logger","message":"自定义报错"}
@@ -3,3 +3,6 @@
3
3
  {"timestamp":"2022-09-13 09:54:18.555","level":"INFO","label":"sys","message":"application stop"}
4
4
  {"timestamp":"2022-09-16 10:15:27.08","level":"INFO","label":"sys","message":"hot update---D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
5
5
  {"timestamp":"2022-09-16 10:15:27.12","level":"INFO","label":"sys","message":"hot update---D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\service\\HelloService.ts"}
6
+ {"timestamp":"2022-12-13 17:56:58.473","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
7
+ {"timestamp":"2022-12-13 17:56:58.474","level":"INFO","label":"sys","message":"Call the method before the application stops"}
8
+ {"timestamp":"2022-12-13 17:57:03.482","level":"INFO","label":"sys","message":"application stop"}
@@ -0,0 +1,3 @@
1
+ {"timestamp":"2022-12-21 17:57:13.569","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
2
+ {"timestamp":"2022-12-21 17:57:13.570","level":"INFO","label":"sys","message":"Call the method before the application stops"}
3
+ {"timestamp":"2022-12-21 17:57:18.583","level":"INFO","label":"sys","message":"application stop"}
@@ -1,7 +1,13 @@
1
- {"timestamp":"2022-09-22 14:03:17.119","level":"INFO","label":"sys","message":"Start scanning component"}
2
- {"timestamp":"2022-09-22 14:03:17.212","level":"INFO","label":"sys","message":"Complete component scan"}
3
- {"timestamp":"2022-09-22 14:03:17.214","level":"INFO","label":"sys","message":"Call application initialization method"}
4
- {"timestamp":"2022-09-22 14:03:17.217","level":"INFO","label":"sys","message":"start server app is run"}
5
- {"timestamp":"2022-09-22 14:03:17.217","level":"INFO","label":"sys","message":"version 1.0.0"}
6
- {"timestamp":"2022-09-22 14:03:17.236","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [notFound] ","stack":"Error: Unsatisfied dependency expressed through [notFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\AliasInjection.ts:16:27)\n at NotFoundController.getNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:14:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:93:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
7
- {"timestamp":"2022-09-22 14:03:17.244","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [autoNotFound] ","stack":"Error: Unsatisfied dependency expressed through [autoNotFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\CallDependency.ts:17:26)\n at NotFoundController.getAutoNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:18:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:99:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
1
+ {"timestamp":"2022-12-13 17:59:53.504","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
2
+ {"timestamp":"2022-12-13 17:59:53.505","level":"INFO","label":"sys","message":"Call the method before the application stops"}
3
+ {"timestamp":"2022-12-13 17:59:58.508","level":"INFO","label":"sys","message":"application stop"}
4
+ {"timestamp":"2022-12-13 18:00:47.239","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
5
+ {"timestamp":"2022-12-13 18:00:47.240","level":"INFO","label":"sys","message":"Call the method before the application stops"}
6
+ {"timestamp":"2022-12-13 18:00:52.243","level":"INFO","label":"sys","message":"application stop"}
7
+ {"timestamp":"2022-12-21 17:57:11.428","level":"INFO","label":"sys","message":"Start scanning component"}
8
+ {"timestamp":"2022-12-21 17:57:11.531","level":"INFO","label":"sys","message":"Complete component scan"}
9
+ {"timestamp":"2022-12-21 17:57:11.533","level":"INFO","label":"sys","message":"Call application initialization method"}
10
+ {"timestamp":"2022-12-21 17:57:11.535","level":"INFO","label":"sys","message":"start server app is run"}
11
+ {"timestamp":"2022-12-21 17:57:11.535","level":"INFO","label":"sys","message":"version 1.0.0"}
12
+ {"timestamp":"2022-12-21 17:57:11.567","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [notFound] ","stack":"Error: Unsatisfied dependency expressed through [notFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\AliasInjection.ts:16:27)\n at NotFoundController.getNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:14:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:89:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
13
+ {"timestamp":"2022-12-21 17:57:11.583","level":"ERROR","label":"sys","message":"Unsatisfied dependency expressed through [autoNotFound] ","stack":"Error: Unsatisfied dependency expressed through [autoNotFound] \n at NotFoundController.get (D:\\code\\fast-car\\fast-car\\fastcar-core\\src\\annotation\\bind\\CallDependency.ts:17:26)\n at NotFoundController.getAutoNotFound (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\controller\\NotFoundController.ts:18:15)\n at Context.<anonymous> (D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\simple\\app.ts:95:13)\n at callFn (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:366:21)\n at Test.Runnable.run (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runnable.js:354:5)\n at Runner.runTest (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:678:10)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:801:12\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:593:14)\n at D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:603:7\n at next (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:486:14)\n at Immediate._onImmediate (D:\\code\\fast-car\\fast-car\\node_modules\\mocha\\lib\\runner.js:571:5)\n at processImmediate (node:internal/timers:466:21)\n at process.topLevelDomainCallback (node:domain:152:15)\n at process.callbackTrampoline (node:internal/async_hooks:128:24)"}
@@ -17,6 +17,7 @@ import ApplicationSetting from "../../../src/annotation/env/ApplicationSetting";
17
17
  @BaseFilePath(__filename)
18
18
  @ApplicationSetting({
19
19
  customHello: "customHello",
20
+ appid: "fastcar-server",
20
21
  })
21
22
  class APP implements ApplicationHook {
22
23
  app!: FastCarApplication;
@@ -1,14 +0,0 @@
1
- {"timestamp":"2022-09-22 14:03:39.499","level":"INFO","label":"sys","message":"Start scanning component"}
2
- {"timestamp":"2022-09-22 14:03:39.584","level":"INFO","label":"sys","message":"Complete component scan"}
3
- {"timestamp":"2022-09-22 14:03:39.586","level":"INFO","label":"sys","message":"Call application initialization method"}
4
- {"timestamp":"2022-09-22 14:03:39.588","level":"INFO","label":"sys","message":"start server app is run"}
5
- {"timestamp":"2022-09-22 14:03:39.588","level":"INFO","label":"sys","message":"version 1.0.0"}
6
- {"timestamp":"2022-09-22 14:03:41.624","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
7
- {"timestamp":"2022-09-22 14:03:41.626","level":"INFO","label":"sys","message":"Call the method before the application stops"}
8
- {"timestamp":"2022-09-22 14:03:46.642","level":"INFO","label":"sys","message":"application stop"}
9
- {"timestamp":"2022-09-22 14:05:29.335","level":"INFO","label":"sys","message":"Start scanning component"}
10
- {"timestamp":"2022-09-22 14:05:29.424","level":"INFO","label":"sys","message":"Complete component scan"}
11
- {"timestamp":"2022-09-22 14:05:29.426","level":"INFO","label":"sys","message":"Call application initialization method"}
12
- {"timestamp":"2022-09-22 14:05:29.428","level":"INFO","label":"sys","message":"start server app is run"}
13
- {"timestamp":"2022-09-22 14:05:29.428","level":"INFO","label":"sys","message":"version 1.0.0"}
14
- {"timestamp":"2022-09-22 14:05:41.112","level":"INFO","label":"sys","message":"sysConfig hot update----D:\\code\\fast-car\\fast-car\\fastcar-core\\test\\example\\resource\\application.yml"}
@@ -1,3 +0,0 @@
1
- {"timestamp":"2022-09-22 14:03:19.246","level":"INFO","label":"sys","message":"exit reason","splat":"[\"beforeExit exit\"]"}
2
- {"timestamp":"2022-09-22 14:03:19.247","level":"INFO","label":"sys","message":"Call the method before the application stops"}
3
- {"timestamp":"2022-09-22 14:03:24.263","level":"INFO","label":"sys","message":"application stop"}