@platform-x/hep-push-notification-client 1.0.0 → 1.0.1
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 +39 -5
- package/dist/src/PushNotificationManager.d.ts +9 -9
- package/dist/src/PushNotificationManager.js +55 -55
- package/dist/src/common/util/commonUtil.d.ts +12 -6
- package/dist/src/common/util/commonUtil.js +67 -42
- package/dist/src/common/util/errorHandler.d.ts +41 -41
- package/dist/src/common/util/errorHandler.js +80 -80
- package/dist/src/common/util/logger.d.ts +68 -68
- package/dist/src/common/util/logger.js +192 -192
- package/dist/src/common/util/requestTracer.d.ts +2 -2
- package/dist/src/common/util/requestTracer.js +16 -16
- package/dist/src/config/index.d.ts +22 -22
- package/dist/src/config/index.js +31 -31
- package/dist/src/index.d.ts +4 -4
- package/dist/src/index.js +35 -33
- package/dist/src/platform-x/constants/index.d.ts +41 -41
- package/dist/src/platform-x/constants/index.js +44 -44
- package/dist/src/platform-x/database/connection.d.ts +10 -8
- package/dist/src/platform-x/database/connection.js +72 -53
- package/dist/src/platform-x/database/dao/site_domain.dao.d.ts +10 -10
- package/dist/src/platform-x/database/dao/site_domain.dao.js +44 -44
- package/dist/src/platform-x/database/index.d.ts +16 -14
- package/dist/src/platform-x/database/index.js +9 -9
- package/dist/src/platform-x/database/interfaces/site_domain.interface.d.ts +33 -33
- package/dist/src/platform-x/database/interfaces/site_domain.interface.js +2 -2
- package/dist/src/platform-x/database/models/site_domain.model.d.ts +9 -9
- package/dist/src/platform-x/database/models/site_domain.model.js +47 -47
- package/dist/src/platform-x/services/fcmservices.d.ts +18 -18
- package/dist/src/platform-x/services/fcmservices.js +187 -187
- package/package.json +1 -1
|
@@ -1,68 +1,68 @@
|
|
|
1
|
-
export interface payLoadInterface {
|
|
2
|
-
statusCode?: number;
|
|
3
|
-
data?: any;
|
|
4
|
-
}
|
|
5
|
-
export interface LoggerInterface {
|
|
6
|
-
info(message: string, method: string): void;
|
|
7
|
-
warn(message: string, method: string, payload?: object): void;
|
|
8
|
-
error(message: string, method: string, payload?: object): void;
|
|
9
|
-
debug(message: string, method: string, payload?: object): void;
|
|
10
|
-
}
|
|
11
|
-
export declare class LoggerClass implements LoggerInterface {
|
|
12
|
-
private logger;
|
|
13
|
-
private infoLevel;
|
|
14
|
-
private debugLevel;
|
|
15
|
-
private errorLevel;
|
|
16
|
-
private warnLevel;
|
|
17
|
-
private blockedKeywords;
|
|
18
|
-
constructor();
|
|
19
|
-
/**
|
|
20
|
-
* It's written to handle JSON.circular error
|
|
21
|
-
* @param obj
|
|
22
|
-
* @returns
|
|
23
|
-
*/
|
|
24
|
-
customstringify(obj: any): string;
|
|
25
|
-
/**
|
|
26
|
-
* for info log
|
|
27
|
-
* @param message
|
|
28
|
-
* @param payload
|
|
29
|
-
* @param method
|
|
30
|
-
* @returns
|
|
31
|
-
*/
|
|
32
|
-
info(message: string, method: string): void;
|
|
33
|
-
/**
|
|
34
|
-
* for warn log
|
|
35
|
-
* @param message
|
|
36
|
-
* @param payload
|
|
37
|
-
* @param method
|
|
38
|
-
* @returns
|
|
39
|
-
*/
|
|
40
|
-
warn(message: string, method: string, payload?: any): void;
|
|
41
|
-
/**
|
|
42
|
-
* for error log
|
|
43
|
-
* @param message
|
|
44
|
-
* @param payload
|
|
45
|
-
* @param method
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
|
-
error(message: string, method: string, payload?: any): void;
|
|
49
|
-
/**
|
|
50
|
-
* for debug log
|
|
51
|
-
* @param message
|
|
52
|
-
* @param payload
|
|
53
|
-
* @param method
|
|
54
|
-
* @returns
|
|
55
|
-
*/
|
|
56
|
-
debug(message: string, method: string, payload?: any): void;
|
|
57
|
-
/**
|
|
58
|
-
* to map log levels and handle from config
|
|
59
|
-
*/
|
|
60
|
-
private mapLogLevels;
|
|
61
|
-
/**
|
|
62
|
-
* to sanitize logs from unwanted fields to be shown
|
|
63
|
-
* @param request
|
|
64
|
-
* @returns
|
|
65
|
-
*/
|
|
66
|
-
private sanitizeLog;
|
|
67
|
-
}
|
|
68
|
-
export declare const Logger: LoggerClass;
|
|
1
|
+
export interface payLoadInterface {
|
|
2
|
+
statusCode?: number;
|
|
3
|
+
data?: any;
|
|
4
|
+
}
|
|
5
|
+
export interface LoggerInterface {
|
|
6
|
+
info(message: string, method: string): void;
|
|
7
|
+
warn(message: string, method: string, payload?: object): void;
|
|
8
|
+
error(message: string, method: string, payload?: object): void;
|
|
9
|
+
debug(message: string, method: string, payload?: object): void;
|
|
10
|
+
}
|
|
11
|
+
export declare class LoggerClass implements LoggerInterface {
|
|
12
|
+
private logger;
|
|
13
|
+
private infoLevel;
|
|
14
|
+
private debugLevel;
|
|
15
|
+
private errorLevel;
|
|
16
|
+
private warnLevel;
|
|
17
|
+
private blockedKeywords;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* It's written to handle JSON.circular error
|
|
21
|
+
* @param obj
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
customstringify(obj: any): string;
|
|
25
|
+
/**
|
|
26
|
+
* for info log
|
|
27
|
+
* @param message
|
|
28
|
+
* @param payload
|
|
29
|
+
* @param method
|
|
30
|
+
* @returns
|
|
31
|
+
*/
|
|
32
|
+
info(message: string, method: string): void;
|
|
33
|
+
/**
|
|
34
|
+
* for warn log
|
|
35
|
+
* @param message
|
|
36
|
+
* @param payload
|
|
37
|
+
* @param method
|
|
38
|
+
* @returns
|
|
39
|
+
*/
|
|
40
|
+
warn(message: string, method: string, payload?: any): void;
|
|
41
|
+
/**
|
|
42
|
+
* for error log
|
|
43
|
+
* @param message
|
|
44
|
+
* @param payload
|
|
45
|
+
* @param method
|
|
46
|
+
* @returns
|
|
47
|
+
*/
|
|
48
|
+
error(message: string, method: string, payload?: any): void;
|
|
49
|
+
/**
|
|
50
|
+
* for debug log
|
|
51
|
+
* @param message
|
|
52
|
+
* @param payload
|
|
53
|
+
* @param method
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
debug(message: string, method: string, payload?: any): void;
|
|
57
|
+
/**
|
|
58
|
+
* to map log levels and handle from config
|
|
59
|
+
*/
|
|
60
|
+
private mapLogLevels;
|
|
61
|
+
/**
|
|
62
|
+
* to sanitize logs from unwanted fields to be shown
|
|
63
|
+
* @param request
|
|
64
|
+
* @returns
|
|
65
|
+
*/
|
|
66
|
+
private sanitizeLog;
|
|
67
|
+
}
|
|
68
|
+
export declare const Logger: LoggerClass;
|
|
@@ -1,193 +1,193 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.Logger = exports.LoggerClass = void 0;
|
|
7
|
-
const bunyan_1 = __importDefault(require("bunyan"));
|
|
8
|
-
const index_1 = __importDefault(require("../../config/index"));
|
|
9
|
-
const bunyan_format_1 = __importDefault(require("bunyan-format"));
|
|
10
|
-
const requestTracer_1 = require("./requestTracer");
|
|
11
|
-
class LoggerClass {
|
|
12
|
-
constructor() {
|
|
13
|
-
this.infoLevel = false;
|
|
14
|
-
this.debugLevel = false;
|
|
15
|
-
this.errorLevel = false;
|
|
16
|
-
this.warnLevel = false;
|
|
17
|
-
this.blockedKeywords = ['currentPassword', 'clientSecret', 'newPassword'];
|
|
18
|
-
this.mapLogLevels();
|
|
19
|
-
this.logger = bunyan_1.default.createLogger({
|
|
20
|
-
name: index_1.default.APP_NAME,
|
|
21
|
-
level: 'trace', // by default enabling all levels, controlled through env separately
|
|
22
|
-
stream: (0, bunyan_format_1.default)({
|
|
23
|
-
outputMode: index_1.default.NODE_ENV === 'development' ? 'short' : 'bunyan',
|
|
24
|
-
levelInString: true,
|
|
25
|
-
color: true,
|
|
26
|
-
}),
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* It's written to handle JSON.circular error
|
|
31
|
-
* @param obj
|
|
32
|
-
* @returns
|
|
33
|
-
*/
|
|
34
|
-
customstringify(obj) {
|
|
35
|
-
let cache = [];
|
|
36
|
-
let str = JSON.stringify(obj, (key, value) => {
|
|
37
|
-
{
|
|
38
|
-
if (typeof value === 'object' && value !== null) {
|
|
39
|
-
if (cache.indexOf(value) !== -1) {
|
|
40
|
-
// Circular reference found, discard key
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
// Store value in our collection
|
|
44
|
-
cache.push(value);
|
|
45
|
-
}
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
cache = null; // reset the cache
|
|
50
|
-
return str;
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* for info log
|
|
54
|
-
* @param message
|
|
55
|
-
* @param payload
|
|
56
|
-
* @param method
|
|
57
|
-
* @returns
|
|
58
|
-
*/
|
|
59
|
-
info(message, method) {
|
|
60
|
-
if (!this.infoLevel) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
let loggerParams = {
|
|
64
|
-
message,
|
|
65
|
-
method,
|
|
66
|
-
traceId: (0, requestTracer_1.getTraceId)(),
|
|
67
|
-
};
|
|
68
|
-
this.logger.info(` start ${JSON.stringify(loggerParams)} ==end`);
|
|
69
|
-
}
|
|
70
|
-
/**
|
|
71
|
-
* for warn log
|
|
72
|
-
* @param message
|
|
73
|
-
* @param payload
|
|
74
|
-
* @param method
|
|
75
|
-
* @returns
|
|
76
|
-
*/
|
|
77
|
-
warn(message, method, payload) {
|
|
78
|
-
if (!this.warnLevel) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
let loggerParams = {
|
|
82
|
-
message,
|
|
83
|
-
method,
|
|
84
|
-
traceId: (0, requestTracer_1.getTraceId)(),
|
|
85
|
-
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
86
|
-
};
|
|
87
|
-
let finalPayload = payload !== undefined ? payload : {};
|
|
88
|
-
this.logger.warn(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
89
|
-
}
|
|
90
|
-
/**
|
|
91
|
-
* for error log
|
|
92
|
-
* @param message
|
|
93
|
-
* @param payload
|
|
94
|
-
* @param method
|
|
95
|
-
* @returns
|
|
96
|
-
*/
|
|
97
|
-
error(message, method, payload) {
|
|
98
|
-
if (!this.errorLevel) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (payload instanceof Error) {
|
|
102
|
-
payload = {
|
|
103
|
-
message,
|
|
104
|
-
method,
|
|
105
|
-
traceId: (0, requestTracer_1.getTraceId)(),
|
|
106
|
-
stack: payload === null || payload === void 0 ? void 0 : payload.stack,
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
let loggerParams = {
|
|
110
|
-
message,
|
|
111
|
-
method,
|
|
112
|
-
traceId: (0, requestTracer_1.getTraceId)(),
|
|
113
|
-
spanId: (0, requestTracer_1.getSpanId)(),
|
|
114
|
-
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
115
|
-
};
|
|
116
|
-
let finalPayload = payload !== undefined ? payload : {};
|
|
117
|
-
this.logger.error(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* for debug log
|
|
121
|
-
* @param message
|
|
122
|
-
* @param payload
|
|
123
|
-
* @param method
|
|
124
|
-
* @returns
|
|
125
|
-
*/
|
|
126
|
-
debug(message, method, payload) {
|
|
127
|
-
if (!this.debugLevel) {
|
|
128
|
-
return;
|
|
129
|
-
}
|
|
130
|
-
let loggerParams = {
|
|
131
|
-
message,
|
|
132
|
-
method,
|
|
133
|
-
traceId: (0, requestTracer_1.getTraceId)(),
|
|
134
|
-
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
135
|
-
};
|
|
136
|
-
let finalPayload = payload !== undefined ? payload : {};
|
|
137
|
-
this.logger.debug(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
138
|
-
}
|
|
139
|
-
/**
|
|
140
|
-
* to map log levels and handle from config
|
|
141
|
-
*/
|
|
142
|
-
mapLogLevels() {
|
|
143
|
-
if (index_1.default.LOG_LEVELS.length) {
|
|
144
|
-
index_1.default.LOG_LEVELS.forEach((element) => {
|
|
145
|
-
const logLevel = element.trim();
|
|
146
|
-
if (logLevel === 'info') {
|
|
147
|
-
this.infoLevel = true;
|
|
148
|
-
}
|
|
149
|
-
else if (logLevel === 'debug') {
|
|
150
|
-
this.debugLevel = true;
|
|
151
|
-
}
|
|
152
|
-
else if (logLevel === 'error') {
|
|
153
|
-
this.errorLevel = true;
|
|
154
|
-
}
|
|
155
|
-
else if (logLevel === 'warn') {
|
|
156
|
-
this.warnLevel = true;
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
/**
|
|
162
|
-
* to sanitize logs from unwanted fields to be shown
|
|
163
|
-
* @param request
|
|
164
|
-
* @returns
|
|
165
|
-
*/
|
|
166
|
-
sanitizeLog(request) {
|
|
167
|
-
try {
|
|
168
|
-
if (request) {
|
|
169
|
-
Object.keys(request).forEach((key) => {
|
|
170
|
-
let value = request[key];
|
|
171
|
-
if (request[key] === 'options') {
|
|
172
|
-
delete request.options;
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
if (this.blockedKeywords.find((blockedKey) => key.toLowerCase() === blockedKey.toLowerCase())) {
|
|
176
|
-
request[key] = 'XXXXXXXXXX';
|
|
177
|
-
}
|
|
178
|
-
else {
|
|
179
|
-
request[key] = value;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
});
|
|
183
|
-
return request;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
catch (err) {
|
|
187
|
-
this.error('Logger sanitize error', err);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
exports.LoggerClass = LoggerClass;
|
|
192
|
-
exports.Logger = new LoggerClass();
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Logger = exports.LoggerClass = void 0;
|
|
7
|
+
const bunyan_1 = __importDefault(require("bunyan"));
|
|
8
|
+
const index_1 = __importDefault(require("../../config/index"));
|
|
9
|
+
const bunyan_format_1 = __importDefault(require("bunyan-format"));
|
|
10
|
+
const requestTracer_1 = require("./requestTracer");
|
|
11
|
+
class LoggerClass {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.infoLevel = false;
|
|
14
|
+
this.debugLevel = false;
|
|
15
|
+
this.errorLevel = false;
|
|
16
|
+
this.warnLevel = false;
|
|
17
|
+
this.blockedKeywords = ['currentPassword', 'clientSecret', 'newPassword'];
|
|
18
|
+
this.mapLogLevels();
|
|
19
|
+
this.logger = bunyan_1.default.createLogger({
|
|
20
|
+
name: index_1.default.APP_NAME,
|
|
21
|
+
level: 'trace', // by default enabling all levels, controlled through env separately
|
|
22
|
+
stream: (0, bunyan_format_1.default)({
|
|
23
|
+
outputMode: index_1.default.NODE_ENV === 'development' ? 'short' : 'bunyan',
|
|
24
|
+
levelInString: true,
|
|
25
|
+
color: true,
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* It's written to handle JSON.circular error
|
|
31
|
+
* @param obj
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
customstringify(obj) {
|
|
35
|
+
let cache = [];
|
|
36
|
+
let str = JSON.stringify(obj, (key, value) => {
|
|
37
|
+
{
|
|
38
|
+
if (typeof value === 'object' && value !== null) {
|
|
39
|
+
if (cache.indexOf(value) !== -1) {
|
|
40
|
+
// Circular reference found, discard key
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
// Store value in our collection
|
|
44
|
+
cache.push(value);
|
|
45
|
+
}
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
cache = null; // reset the cache
|
|
50
|
+
return str;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* for info log
|
|
54
|
+
* @param message
|
|
55
|
+
* @param payload
|
|
56
|
+
* @param method
|
|
57
|
+
* @returns
|
|
58
|
+
*/
|
|
59
|
+
info(message, method) {
|
|
60
|
+
if (!this.infoLevel) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
let loggerParams = {
|
|
64
|
+
message,
|
|
65
|
+
method,
|
|
66
|
+
traceId: (0, requestTracer_1.getTraceId)(),
|
|
67
|
+
};
|
|
68
|
+
this.logger.info(` start ${JSON.stringify(loggerParams)} ==end`);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* for warn log
|
|
72
|
+
* @param message
|
|
73
|
+
* @param payload
|
|
74
|
+
* @param method
|
|
75
|
+
* @returns
|
|
76
|
+
*/
|
|
77
|
+
warn(message, method, payload) {
|
|
78
|
+
if (!this.warnLevel) {
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
let loggerParams = {
|
|
82
|
+
message,
|
|
83
|
+
method,
|
|
84
|
+
traceId: (0, requestTracer_1.getTraceId)(),
|
|
85
|
+
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
86
|
+
};
|
|
87
|
+
let finalPayload = payload !== undefined ? payload : {};
|
|
88
|
+
this.logger.warn(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* for error log
|
|
92
|
+
* @param message
|
|
93
|
+
* @param payload
|
|
94
|
+
* @param method
|
|
95
|
+
* @returns
|
|
96
|
+
*/
|
|
97
|
+
error(message, method, payload) {
|
|
98
|
+
if (!this.errorLevel) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (payload instanceof Error) {
|
|
102
|
+
payload = {
|
|
103
|
+
message,
|
|
104
|
+
method,
|
|
105
|
+
traceId: (0, requestTracer_1.getTraceId)(),
|
|
106
|
+
stack: payload === null || payload === void 0 ? void 0 : payload.stack,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
let loggerParams = {
|
|
110
|
+
message,
|
|
111
|
+
method,
|
|
112
|
+
traceId: (0, requestTracer_1.getTraceId)(),
|
|
113
|
+
spanId: (0, requestTracer_1.getSpanId)(),
|
|
114
|
+
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
115
|
+
};
|
|
116
|
+
let finalPayload = payload !== undefined ? payload : {};
|
|
117
|
+
this.logger.error(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* for debug log
|
|
121
|
+
* @param message
|
|
122
|
+
* @param payload
|
|
123
|
+
* @param method
|
|
124
|
+
* @returns
|
|
125
|
+
*/
|
|
126
|
+
debug(message, method, payload) {
|
|
127
|
+
if (!this.debugLevel) {
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
let loggerParams = {
|
|
131
|
+
message,
|
|
132
|
+
method,
|
|
133
|
+
traceId: (0, requestTracer_1.getTraceId)(),
|
|
134
|
+
statusCode: payload === null || payload === void 0 ? void 0 : payload.statusCode,
|
|
135
|
+
};
|
|
136
|
+
let finalPayload = payload !== undefined ? payload : {};
|
|
137
|
+
this.logger.debug(` start ${JSON.stringify(loggerParams)} payload: ${this.customstringify(this.sanitizeLog(finalPayload))}==end`);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* to map log levels and handle from config
|
|
141
|
+
*/
|
|
142
|
+
mapLogLevels() {
|
|
143
|
+
if (index_1.default.LOG_LEVELS.length) {
|
|
144
|
+
index_1.default.LOG_LEVELS.forEach((element) => {
|
|
145
|
+
const logLevel = element.trim();
|
|
146
|
+
if (logLevel === 'info') {
|
|
147
|
+
this.infoLevel = true;
|
|
148
|
+
}
|
|
149
|
+
else if (logLevel === 'debug') {
|
|
150
|
+
this.debugLevel = true;
|
|
151
|
+
}
|
|
152
|
+
else if (logLevel === 'error') {
|
|
153
|
+
this.errorLevel = true;
|
|
154
|
+
}
|
|
155
|
+
else if (logLevel === 'warn') {
|
|
156
|
+
this.warnLevel = true;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* to sanitize logs from unwanted fields to be shown
|
|
163
|
+
* @param request
|
|
164
|
+
* @returns
|
|
165
|
+
*/
|
|
166
|
+
sanitizeLog(request) {
|
|
167
|
+
try {
|
|
168
|
+
if (request) {
|
|
169
|
+
Object.keys(request).forEach((key) => {
|
|
170
|
+
let value = request[key];
|
|
171
|
+
if (request[key] === 'options') {
|
|
172
|
+
delete request.options;
|
|
173
|
+
}
|
|
174
|
+
else {
|
|
175
|
+
if (this.blockedKeywords.find((blockedKey) => key.toLowerCase() === blockedKey.toLowerCase())) {
|
|
176
|
+
request[key] = 'XXXXXXXXXX';
|
|
177
|
+
}
|
|
178
|
+
else {
|
|
179
|
+
request[key] = value;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
return request;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (err) {
|
|
187
|
+
this.error('Logger sanitize error', err);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
exports.LoggerClass = LoggerClass;
|
|
192
|
+
exports.Logger = new LoggerClass();
|
|
193
193
|
//# sourceMappingURL=logger.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const getTraceId: () => any;
|
|
2
|
-
export declare const getSpanId: () => any;
|
|
1
|
+
export declare const getTraceId: () => any;
|
|
2
|
+
export declare const getSpanId: () => any;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getSpanId = exports.getTraceId = void 0;
|
|
7
|
-
const cls_hooked_1 = __importDefault(require("cls-hooked"));
|
|
8
|
-
const uuid_1 = require("uuid");
|
|
9
|
-
const nsid = `rtracer:${(0, uuid_1.v4)()}`;
|
|
10
|
-
const ns = cls_hooked_1.default.createNamespace(nsid);
|
|
11
|
-
const traceIdKey = 'traceId';
|
|
12
|
-
const spanIdKey = 'spanId';
|
|
13
|
-
const getTraceId = () => ns.get(traceIdKey);
|
|
14
|
-
exports.getTraceId = getTraceId;
|
|
15
|
-
const getSpanId = () => ns.get(spanIdKey);
|
|
16
|
-
exports.getSpanId = getSpanId;
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getSpanId = exports.getTraceId = void 0;
|
|
7
|
+
const cls_hooked_1 = __importDefault(require("cls-hooked"));
|
|
8
|
+
const uuid_1 = require("uuid");
|
|
9
|
+
const nsid = `rtracer:${(0, uuid_1.v4)()}`;
|
|
10
|
+
const ns = cls_hooked_1.default.createNamespace(nsid);
|
|
11
|
+
const traceIdKey = 'traceId';
|
|
12
|
+
const spanIdKey = 'spanId';
|
|
13
|
+
const getTraceId = () => ns.get(traceIdKey);
|
|
14
|
+
exports.getTraceId = getTraceId;
|
|
15
|
+
const getSpanId = () => ns.get(spanIdKey);
|
|
16
|
+
exports.getSpanId = getSpanId;
|
|
17
17
|
//# sourceMappingURL=requestTracer.js.map
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
declare const _default: {
|
|
2
|
-
LOG_LEVELS: string[];
|
|
3
|
-
APP_NAME: string;
|
|
4
|
-
NODE_ENV: string | undefined;
|
|
5
|
-
MONGO: {
|
|
6
|
-
HOST: string | undefined;
|
|
7
|
-
PORT: string | undefined;
|
|
8
|
-
DB_NAME: string | undefined;
|
|
9
|
-
USER: string | undefined;
|
|
10
|
-
PASS: string | undefined;
|
|
11
|
-
};
|
|
12
|
-
FCM: {
|
|
13
|
-
PROJECT: string | undefined;
|
|
14
|
-
TYPE: string | undefined;
|
|
15
|
-
AUTH_URI: string | undefined;
|
|
16
|
-
TOKEN_URI: string | undefined;
|
|
17
|
-
AUTH_PROVIDER_X509_CERT_URL: string | undefined;
|
|
18
|
-
UNIVERSE_DOMAIN: string | undefined;
|
|
19
|
-
};
|
|
20
|
-
SECRET_MODE: string;
|
|
21
|
-
};
|
|
22
|
-
export default _default;
|
|
1
|
+
declare const _default: {
|
|
2
|
+
LOG_LEVELS: string[];
|
|
3
|
+
APP_NAME: string;
|
|
4
|
+
NODE_ENV: string | undefined;
|
|
5
|
+
MONGO: {
|
|
6
|
+
HOST: string | undefined;
|
|
7
|
+
PORT: string | undefined;
|
|
8
|
+
DB_NAME: string | undefined;
|
|
9
|
+
USER: string | undefined;
|
|
10
|
+
PASS: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
FCM: {
|
|
13
|
+
PROJECT: string | undefined;
|
|
14
|
+
TYPE: string | undefined;
|
|
15
|
+
AUTH_URI: string | undefined;
|
|
16
|
+
TOKEN_URI: string | undefined;
|
|
17
|
+
AUTH_PROVIDER_X509_CERT_URL: string | undefined;
|
|
18
|
+
UNIVERSE_DOMAIN: string | undefined;
|
|
19
|
+
};
|
|
20
|
+
SECRET_MODE: string;
|
|
21
|
+
};
|
|
22
|
+
export default _default;
|
package/dist/src/config/index.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
-
const constants_1 = require("../platform-x/constants");
|
|
9
|
-
dotenv_1.default.config();
|
|
10
|
-
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
11
|
-
exports.default = {
|
|
12
|
-
LOG_LEVELS: ((_a = process.env.LOG_LEVELS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
|
|
13
|
-
APP_NAME: process.env.npm_package_name || constants_1.DEFAULT_APP_NAME,
|
|
14
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
-
MONGO: {
|
|
16
|
-
HOST: process.env.MONGO_HOST,
|
|
17
|
-
PORT: process.env.MONGO_PORT,
|
|
18
|
-
DB_NAME: process.env.MONGO_DB,
|
|
19
|
-
USER: process.env.MONGO_USER,
|
|
20
|
-
PASS: process.env.MONGO_PASS,
|
|
21
|
-
},
|
|
22
|
-
FCM: {
|
|
23
|
-
PROJECT: process.env.FCM_PROJECT,
|
|
24
|
-
TYPE: process.env.FCM_TYPE,
|
|
25
|
-
AUTH_URI: process.env.FCM_AUTH_URI,
|
|
26
|
-
TOKEN_URI: process.env.FCM_TOKEN_URI,
|
|
27
|
-
AUTH_PROVIDER_X509_CERT_URL: process.env.FCM_AUTH_PROVIDER_X509_CERT_URL,
|
|
28
|
-
UNIVERSE_DOMAIN: process.env.FCM_UNIVERSE_DOMAIN,
|
|
29
|
-
},
|
|
30
|
-
SECRET_MODE: process.env.SECRET_MODE || 'gsm',
|
|
31
|
-
};
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
var _a;
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
const dotenv_1 = __importDefault(require("dotenv"));
|
|
8
|
+
const constants_1 = require("../platform-x/constants");
|
|
9
|
+
dotenv_1.default.config();
|
|
10
|
+
process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
|
11
|
+
exports.default = {
|
|
12
|
+
LOG_LEVELS: ((_a = process.env.LOG_LEVELS) === null || _a === void 0 ? void 0 : _a.split(',')) || [],
|
|
13
|
+
APP_NAME: process.env.npm_package_name || constants_1.DEFAULT_APP_NAME,
|
|
14
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
15
|
+
MONGO: {
|
|
16
|
+
HOST: process.env.MONGO_HOST,
|
|
17
|
+
PORT: process.env.MONGO_PORT,
|
|
18
|
+
DB_NAME: process.env.MONGO_DB,
|
|
19
|
+
USER: process.env.MONGO_USER,
|
|
20
|
+
PASS: process.env.MONGO_PASS,
|
|
21
|
+
},
|
|
22
|
+
FCM: {
|
|
23
|
+
PROJECT: process.env.FCM_PROJECT,
|
|
24
|
+
TYPE: process.env.FCM_TYPE,
|
|
25
|
+
AUTH_URI: process.env.FCM_AUTH_URI,
|
|
26
|
+
TOKEN_URI: process.env.FCM_TOKEN_URI,
|
|
27
|
+
AUTH_PROVIDER_X509_CERT_URL: process.env.FCM_AUTH_PROVIDER_X509_CERT_URL,
|
|
28
|
+
UNIVERSE_DOMAIN: process.env.FCM_UNIVERSE_DOMAIN,
|
|
29
|
+
},
|
|
30
|
+
SECRET_MODE: process.env.SECRET_MODE || 'gsm',
|
|
31
|
+
};
|
|
32
32
|
//# sourceMappingURL=index.js.map
|