@xrystal/core 3.17.5 → 3.17.8
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/package.json +1 -1
- package/source/loader/configs/index.d.ts +1 -0
- package/source/loader/configs/index.js +4 -1
- package/source/loader/logger/index.d.ts +3 -1
- package/source/loader/logger/index.js +8 -10
- package/source/project/index.js +2 -5
- package/source/utils/constants/index.d.ts +1 -1
- package/source/utils/constants/index.js +1 -1
- package/source/utils/index.d.ts +3 -3
- package/source/utils/index.js +3 -3
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import { publicFolderName } from '../../utils';
|
|
2
|
+
import { kafkaLogsTopic, publicFolderName } from '../../utils';
|
|
3
3
|
export default class ConfigsService {
|
|
4
4
|
config = {};
|
|
5
5
|
publicFolderName = publicFolderName;
|
|
6
|
+
kafkaLogsTopic = kafkaLogsTopic;
|
|
6
7
|
#systemService;
|
|
7
8
|
constructor({ systemService }) {
|
|
8
9
|
this.#systemService = systemService;
|
|
@@ -26,6 +27,8 @@ export default class ConfigsService {
|
|
|
26
27
|
projectNameSuffixEnv: process.env.PROJECT_NAME_SUFFIX || '',
|
|
27
28
|
systemStaticFolderPath: path.resolve(rawConfigs.rootFolderPath, this.publicFolderName),
|
|
28
29
|
systemLoggerLayer: process.env.SYSTEM_LOGGER_LAYER,
|
|
30
|
+
kafkaBrokers: process.env?.KAFKA_BROKERS,
|
|
31
|
+
kafkaLogsTopic: kafkaLogsTopic,
|
|
29
32
|
baseApiUri: process.env.HTTPS === 'true' ? process.env.SYSTEM_HTTPS_BASE_API_URI : process.env.SYSTEM_BASE_API_URI,
|
|
30
33
|
port: process.env.PORT || rawConfigs.port || 3000,
|
|
31
34
|
internalSecret: process.env.INTERNAL_SECRET,
|
|
@@ -20,7 +20,9 @@ export default class LoggerService implements IService {
|
|
|
20
20
|
private kafkaTopic;
|
|
21
21
|
private isKafkaReady;
|
|
22
22
|
winston: CustomLogger;
|
|
23
|
-
constructor(
|
|
23
|
+
constructor({ configsService }: {
|
|
24
|
+
configsService: any;
|
|
25
|
+
});
|
|
24
26
|
load: (config: Record<string, any>) => Promise<void>;
|
|
25
27
|
winstonLoader: ({ loadPath, loggerLevel }: {
|
|
26
28
|
loadPath: string;
|
|
@@ -39,23 +39,20 @@ export default class LoggerService {
|
|
|
39
39
|
isKafkaReady = false;
|
|
40
40
|
winston;
|
|
41
41
|
#configsService;
|
|
42
|
-
constructor(
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
this.#configsService = deps.configsService;
|
|
42
|
+
constructor({ configsService }) {
|
|
43
|
+
this.#configsService = configsService;
|
|
44
|
+
this.kafkaTopic = this.#configsService?.all.kafkaTopic;
|
|
47
45
|
winston.addColors(customColors);
|
|
48
46
|
this.winston = winston.createLogger({
|
|
49
|
-
level: this.#configsService.all.systemLoggerLayer
|
|
47
|
+
level: this.#configsService.all.systemLoggerLayer,
|
|
50
48
|
levels: customLevels,
|
|
51
49
|
format: this.getConsoleFormat(),
|
|
52
50
|
transports: [new winston.transports.Console()]
|
|
53
51
|
});
|
|
54
52
|
}
|
|
55
53
|
load = async (config) => {
|
|
56
|
-
this.serviceName = config?.serviceName
|
|
57
|
-
|
|
58
|
-
const rawBrokers = config?.kafkaBrokers;
|
|
54
|
+
this.serviceName = config?.serviceName;
|
|
55
|
+
const rawBrokers = this.#configsService.all.kafkaBrokers;
|
|
59
56
|
const brokers = rawBrokers ? String(rawBrokers).split(",").map((b) => b.trim()) : [];
|
|
60
57
|
if (brokers.length > 0) {
|
|
61
58
|
const kafka = new Kafka({
|
|
@@ -171,7 +168,8 @@ export default class LoggerService {
|
|
|
171
168
|
id: id || null,
|
|
172
169
|
env: this.#configsService.all.env
|
|
173
170
|
}, this.safeReplacer)
|
|
174
|
-
}]
|
|
171
|
+
}],
|
|
172
|
+
acks: 0
|
|
175
173
|
});
|
|
176
174
|
}
|
|
177
175
|
catch (err) {
|
package/source/project/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// => import dependencies
|
|
2
1
|
import path from 'path';
|
|
3
2
|
import { SystemService, ConfigsService, LoggerService, EventsService, LocalizationsService, ClientsService, ControllerService } from '../loader/index';
|
|
4
|
-
import { packageName, x,
|
|
3
|
+
import { packageName, x, getTmp, } from '../utils/index';
|
|
5
4
|
//
|
|
6
5
|
let coreHasRun = false;
|
|
7
6
|
export const core = getTmp();
|
|
@@ -38,10 +37,8 @@ const coreLoader = async ({}) => {
|
|
|
38
37
|
service: LoggerService,
|
|
39
38
|
props: {
|
|
40
39
|
loadPath: path.join(rootFolderPath, configs.loaders.loggers.loadPath),
|
|
41
|
-
loggerLevel:
|
|
40
|
+
loggerLevel: configs.loaders.loggers.logLevel,
|
|
42
41
|
serviceName: configs.service,
|
|
43
|
-
kafkaBrokers: kafkaBrokers ?? "",
|
|
44
|
-
kafkaTopic: configs.loaders.loggers.topic
|
|
45
42
|
}
|
|
46
43
|
},
|
|
47
44
|
{
|
|
@@ -5,5 +5,5 @@ export declare const tmpFileDefaultExt = ".yml";
|
|
|
5
5
|
export declare const defaultTmpFilePath: string;
|
|
6
6
|
export declare const defaultOwnerTmpFilePath: string;
|
|
7
7
|
export declare const systemLoggerLayer: string;
|
|
8
|
-
export declare const kafkaBrokers: string;
|
|
9
8
|
export declare const publicFolderName = "public";
|
|
9
|
+
export declare const kafkaLogsTopic = "logs";
|
|
@@ -7,5 +7,5 @@ export const tmpFileDefaultExt = '.yml';
|
|
|
7
7
|
export const defaultTmpFilePath = path.resolve(__dirname(import.meta.url), `../../${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`);
|
|
8
8
|
export const defaultOwnerTmpFilePath = path.resolve(`./${tmpFileDefaultMainFolderName}/${tmpFileDefaultName}.yml`);
|
|
9
9
|
export const systemLoggerLayer = process.env.SYSTEM_LOGGER_LAYER;
|
|
10
|
-
export const kafkaBrokers = process.env?.KAFKA_BROKERS;
|
|
11
10
|
export const publicFolderName = 'public';
|
|
11
|
+
export const kafkaLogsTopic = 'logs';
|
package/source/utils/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './helpers
|
|
3
|
-
export * from './models
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './helpers';
|
|
3
|
+
export * from './models';
|
package/source/utils/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './constants
|
|
2
|
-
export * from './helpers
|
|
3
|
-
export * from './models
|
|
1
|
+
export * from './constants';
|
|
2
|
+
export * from './helpers';
|
|
3
|
+
export * from './models';
|