@saultechitsolutions/gighub-shared-core 1.0.3 → 1.0.5
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/dist/elk/elk.module.d.ts +9 -0
- package/dist/elk/elk.module.js +47 -0
- package/dist/elk/elk.module.js.map +1 -0
- package/dist/elk/elk.service.d.ts +27 -0
- package/dist/elk/elk.service.js +181 -0
- package/dist/elk/elk.service.js.map +1 -0
- package/dist/elk/interceptors/elk-logging.interceptor.d.ts +10 -0
- package/dist/elk/interceptors/elk-logging.interceptor.js +82 -0
- package/dist/elk/interceptors/elk-logging.interceptor.js.map +1 -0
- package/dist/elk/interfaces/elk-config.interface.d.ts +32 -0
- package/dist/elk/interfaces/elk-config.interface.js +3 -0
- package/dist/elk/interfaces/elk-config.interface.js.map +1 -0
- package/dist/eureka/eureka.module.d.ts +11 -0
- package/dist/eureka/eureka.module.js +100 -0
- package/dist/eureka/eureka.module.js.map +1 -0
- package/dist/eureka/eureka.service.d.ts +0 -0
- package/dist/eureka/eureka.service.js +1 -0
- package/dist/eureka/eureka.service.js.map +1 -0
- package/dist/eureka/interfaces/eureka-config.interface.d.ts +33 -0
- package/dist/eureka/interfaces/eureka-config.interface.js +3 -0
- package/dist/eureka/interfaces/eureka-config.interface.js.map +1 -0
- package/dist/grpc/grpc.helper.d.ts +9 -0
- package/dist/grpc/grpc.helper.js +67 -0
- package/dist/grpc/grpc.helper.js.map +1 -0
- package/dist/grpc/grpc.module.d.ts +19 -0
- package/dist/grpc/grpc.module.js +68 -0
- package/dist/grpc/grpc.module.js.map +1 -0
- package/dist/grpc/interfaces/grpc-config.interface.d.ts +23 -0
- package/dist/grpc/interfaces/grpc-config.interface.js +3 -0
- package/dist/grpc/interfaces/grpc-config.interface.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -2
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { ElkConfig } from './interfaces/elk-config.interface';
|
|
3
|
+
export declare class ElkModule {
|
|
4
|
+
static forRoot(config: ElkConfig): DynamicModule;
|
|
5
|
+
static forRootAsync(options: {
|
|
6
|
+
useFactory: (...args: any[]) => Promise<ElkConfig> | ElkConfig;
|
|
7
|
+
inject?: any[];
|
|
8
|
+
}): DynamicModule;
|
|
9
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var ElkModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.ElkModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const elk_service_1 = require("./elk.service");
|
|
13
|
+
let ElkModule = ElkModule_1 = class ElkModule {
|
|
14
|
+
static forRoot(config) {
|
|
15
|
+
return {
|
|
16
|
+
module: ElkModule_1,
|
|
17
|
+
providers: [
|
|
18
|
+
{
|
|
19
|
+
provide: 'ELK_CONFIG',
|
|
20
|
+
useValue: config,
|
|
21
|
+
},
|
|
22
|
+
elk_service_1.ElkService,
|
|
23
|
+
],
|
|
24
|
+
exports: [elk_service_1.ElkService],
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
static forRootAsync(options) {
|
|
28
|
+
return {
|
|
29
|
+
module: ElkModule_1,
|
|
30
|
+
providers: [
|
|
31
|
+
{
|
|
32
|
+
provide: 'ELK_CONFIG',
|
|
33
|
+
useFactory: options.useFactory,
|
|
34
|
+
inject: options.inject || [],
|
|
35
|
+
},
|
|
36
|
+
elk_service_1.ElkService,
|
|
37
|
+
],
|
|
38
|
+
exports: [elk_service_1.ElkService],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.ElkModule = ElkModule;
|
|
43
|
+
exports.ElkModule = ElkModule = ElkModule_1 = __decorate([
|
|
44
|
+
(0, common_1.Global)(),
|
|
45
|
+
(0, common_1.Module)({})
|
|
46
|
+
], ElkModule);
|
|
47
|
+
//# sourceMappingURL=elk.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elk.module.js","sourceRoot":"","sources":["../../src/elk/elk.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,+CAA2C;AAKpC,IAAM,SAAS,iBAAf,MAAM,SAAS;IAClB,MAAM,CAAC,OAAO,CAAC,MAAiB;QAC5B,OAAO;YACH,MAAM,EAAE,WAAS;YACjB,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,YAAY;oBACrB,QAAQ,EAAE,MAAM;iBACnB;gBACD,wBAAU;aACb;YACD,OAAO,EAAE,CAAC,wBAAU,CAAC;SACxB,CAAC;IACN,CAAC;IAED,MAAM,CAAC,YAAY,CAAC,OAGnB;QACG,OAAO;YACH,MAAM,EAAE,WAAS;YACjB,SAAS,EAAE;gBACP;oBACI,OAAO,EAAE,YAAY;oBACrB,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;iBAC/B;gBACD,wBAAU;aACb;YACD,OAAO,EAAE,CAAC,wBAAU,CAAC;SACxB,CAAC;IACN,CAAC;CACJ,CAAA;AAhCY,8BAAS;oBAAT,SAAS;IAFrB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,SAAS,CAgCrB"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { LoggerService as NestLoggerService } from '@nestjs/common';
|
|
2
|
+
import { Client } from '@elastic/elasticsearch';
|
|
3
|
+
import { ElkConfig, LogMetadata } from './interfaces/elk-config.interface';
|
|
4
|
+
export declare class ElkService implements NestLoggerService {
|
|
5
|
+
private config;
|
|
6
|
+
private logger;
|
|
7
|
+
private elasticClient;
|
|
8
|
+
constructor(config: ElkConfig);
|
|
9
|
+
private initializeElasticsearch;
|
|
10
|
+
private initializeLogger;
|
|
11
|
+
log(message: string, context?: string): void;
|
|
12
|
+
log(message: string, metadata?: LogMetadata): void;
|
|
13
|
+
error(message: string, trace?: string, context?: string): void;
|
|
14
|
+
error(message: string, metadata?: LogMetadata): void;
|
|
15
|
+
warn(message: string, context?: string): void;
|
|
16
|
+
warn(message: string, metadata?: LogMetadata): void;
|
|
17
|
+
debug(message: string, context?: string): void;
|
|
18
|
+
debug(message: string, metadata?: LogMetadata): void;
|
|
19
|
+
verbose(message: string, context?: string): void;
|
|
20
|
+
verbose(message: string, metadata?: LogMetadata): void;
|
|
21
|
+
searchLogs(query: any, from?: number, size?: number): Promise<any>;
|
|
22
|
+
getLogsByTimeRange(startTime: Date, endTime: Date): Promise<any>;
|
|
23
|
+
getElasticsearchClient(): Client;
|
|
24
|
+
checkHealth(): Promise<boolean>;
|
|
25
|
+
private normalizeMeta;
|
|
26
|
+
onModuleDestroy(): Promise<void>;
|
|
27
|
+
}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.ElkService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const elasticsearch_1 = require("@elastic/elasticsearch");
|
|
18
|
+
const winston = require("winston");
|
|
19
|
+
const winston_elasticsearch_1 = require("winston-elasticsearch");
|
|
20
|
+
let ElkService = class ElkService {
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.config = config;
|
|
23
|
+
this.initializeElasticsearch();
|
|
24
|
+
this.initializeLogger();
|
|
25
|
+
}
|
|
26
|
+
initializeElasticsearch() {
|
|
27
|
+
this.elasticClient = new elasticsearch_1.Client({
|
|
28
|
+
node: this.config.elasticsearch.node,
|
|
29
|
+
auth: this.config.elasticsearch.auth,
|
|
30
|
+
maxRetries: this.config.elasticsearch.maxRetries || 3,
|
|
31
|
+
requestTimeout: this.config.elasticsearch.requestTimeout || 30000,
|
|
32
|
+
sniffOnStart: this.config.elasticsearch.sniffOnStart || false,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
initializeLogger() {
|
|
36
|
+
const transports = [];
|
|
37
|
+
if (this.config.logging.consoleLog !== false) {
|
|
38
|
+
transports.push(new winston.transports.Console({
|
|
39
|
+
format: winston.format.combine(winston.format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss' }), winston.format.colorize(), winston.format.printf(({ timestamp, level, message, context, ...meta }) => {
|
|
40
|
+
const contextStr = context ? `[${context}]` : '';
|
|
41
|
+
const metaStr = Object.keys(meta).length ? JSON.stringify(meta) : '';
|
|
42
|
+
return `${timestamp} ${level} ${contextStr} ${message} ${metaStr}`;
|
|
43
|
+
})),
|
|
44
|
+
}));
|
|
45
|
+
}
|
|
46
|
+
const esTransportOpts = {
|
|
47
|
+
level: this.config.logging.level || 'info',
|
|
48
|
+
clientOpts: {
|
|
49
|
+
node: this.config.elasticsearch.node,
|
|
50
|
+
auth: this.config.elasticsearch.auth,
|
|
51
|
+
maxRetries: this.config.elasticsearch.maxRetries || 3,
|
|
52
|
+
requestTimeout: this.config.elasticsearch.requestTimeout || 30000,
|
|
53
|
+
sniffOnStart: this.config.elasticsearch.sniffOnStart || false,
|
|
54
|
+
},
|
|
55
|
+
index: this.config.logging.index,
|
|
56
|
+
buffering: this.config.logging.buffering !== false,
|
|
57
|
+
bufferLimit: this.config.logging.bufferLimit || 100,
|
|
58
|
+
flushInterval: this.config.logging.flushInterval || 2000,
|
|
59
|
+
retryLimit: this.config.logging.retryLimit || 3,
|
|
60
|
+
healthCheckTimeout: '30s',
|
|
61
|
+
healthCheckWaitForStatus: 'yellow',
|
|
62
|
+
transformer: (logData) => {
|
|
63
|
+
const transformed = {
|
|
64
|
+
'@timestamp': new Date().toISOString(),
|
|
65
|
+
message: logData.message,
|
|
66
|
+
severity: logData.level,
|
|
67
|
+
service: this.config.serviceName,
|
|
68
|
+
environment: this.config.environment,
|
|
69
|
+
context: logData.meta?.context,
|
|
70
|
+
...logData.meta,
|
|
71
|
+
};
|
|
72
|
+
Object.keys(transformed).forEach(key => {
|
|
73
|
+
if (transformed[key] === undefined) {
|
|
74
|
+
delete transformed[key];
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return transformed;
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
transports.push(new winston_elasticsearch_1.ElasticsearchTransport(esTransportOpts));
|
|
81
|
+
this.logger = winston.createLogger({
|
|
82
|
+
level: this.config.logging.level || 'info',
|
|
83
|
+
format: winston.format.combine(winston.format.timestamp(), winston.format.errors({ stack: true }), winston.format.json()),
|
|
84
|
+
defaultMeta: {
|
|
85
|
+
service: this.config.serviceName,
|
|
86
|
+
environment: this.config.environment,
|
|
87
|
+
},
|
|
88
|
+
transports,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
log(message, contextOrMeta) {
|
|
92
|
+
const meta = this.normalizeMeta(contextOrMeta);
|
|
93
|
+
this.logger.info(message, meta);
|
|
94
|
+
}
|
|
95
|
+
error(message, traceOrMeta, context) {
|
|
96
|
+
if (typeof traceOrMeta === 'string') {
|
|
97
|
+
this.logger.error(message, {
|
|
98
|
+
context,
|
|
99
|
+
trace: traceOrMeta,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
this.logger.error(message, traceOrMeta);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
warn(message, contextOrMeta) {
|
|
107
|
+
const meta = this.normalizeMeta(contextOrMeta);
|
|
108
|
+
this.logger.warn(message, meta);
|
|
109
|
+
}
|
|
110
|
+
debug(message, contextOrMeta) {
|
|
111
|
+
const meta = this.normalizeMeta(contextOrMeta);
|
|
112
|
+
this.logger.debug(message, meta);
|
|
113
|
+
}
|
|
114
|
+
verbose(message, contextOrMeta) {
|
|
115
|
+
const meta = this.normalizeMeta(contextOrMeta);
|
|
116
|
+
this.logger.verbose(message, meta);
|
|
117
|
+
}
|
|
118
|
+
async searchLogs(query, from = 0, size = 100) {
|
|
119
|
+
try {
|
|
120
|
+
return await this.elasticClient.search({
|
|
121
|
+
index: this.config.logging.index,
|
|
122
|
+
query,
|
|
123
|
+
from,
|
|
124
|
+
size,
|
|
125
|
+
sort: [{ '@timestamp': { order: 'desc' } }],
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
console.error('Error searching logs:', error);
|
|
130
|
+
throw error;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
async getLogsByTimeRange(startTime, endTime) {
|
|
134
|
+
const query = {
|
|
135
|
+
bool: {
|
|
136
|
+
must: [
|
|
137
|
+
{ match: { service: this.config.serviceName } },
|
|
138
|
+
{
|
|
139
|
+
range: {
|
|
140
|
+
'@timestamp': {
|
|
141
|
+
gte: startTime.toISOString(),
|
|
142
|
+
lte: endTime.toISOString(),
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
],
|
|
147
|
+
},
|
|
148
|
+
};
|
|
149
|
+
return this.searchLogs(query);
|
|
150
|
+
}
|
|
151
|
+
getElasticsearchClient() {
|
|
152
|
+
return this.elasticClient;
|
|
153
|
+
}
|
|
154
|
+
async checkHealth() {
|
|
155
|
+
try {
|
|
156
|
+
const health = await this.elasticClient.cluster.health();
|
|
157
|
+
return health.status === 'green' || health.status === 'yellow';
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
console.error('Elasticsearch health check failed:', error);
|
|
161
|
+
return false;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
normalizeMeta(contextOrMeta) {
|
|
165
|
+
if (typeof contextOrMeta === 'string') {
|
|
166
|
+
return { context: contextOrMeta };
|
|
167
|
+
}
|
|
168
|
+
return contextOrMeta || {};
|
|
169
|
+
}
|
|
170
|
+
async onModuleDestroy() {
|
|
171
|
+
await this.elasticClient.close();
|
|
172
|
+
this.logger.close();
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
exports.ElkService = ElkService;
|
|
176
|
+
exports.ElkService = ElkService = __decorate([
|
|
177
|
+
(0, common_1.Injectable)({ scope: common_1.Scope.DEFAULT }),
|
|
178
|
+
__param(0, (0, common_1.Inject)('ELK_CONFIG')),
|
|
179
|
+
__metadata("design:paramtypes", [Object])
|
|
180
|
+
], ElkService);
|
|
181
|
+
//# sourceMappingURL=elk.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elk.service.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AAK,CAAC,CAAC;YAC3D,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;IAKO,aAAa,CAAC,aAAoC;QACtD,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACpC,OAAO,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;QACtC,CAAC;QACD,OAAO,aAAa,IAAI,EAAE,CAAC;IAC/B,CAAC;IAKD,KAAK,CAAC,eAAe;QACjB,MAAM,IAAI,CAAC,aAAa,CAAC,KAAK,EAAE,CAAC;QACjC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACJ,CAAA;AAtOY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,EAAC,EAAE,KAAK,EAAE,cAAK,CAAC,OAAO,EAAE,CAAC;IAKpB,WAAA,IAAA,eAAM,EAAC,YAAY,CAAC,CAAA;;GAJxB,UAAU,CAsOtB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NestInterceptor, ExecutionContext, CallHandler } from '@nestjs/common';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { ElkService } from '../elk.service';
|
|
4
|
+
export declare class ElkLoggingInterceptor implements NestInterceptor {
|
|
5
|
+
private readonly elkService;
|
|
6
|
+
constructor(elkService: ElkService);
|
|
7
|
+
intercept(context: ExecutionContext, next: CallHandler): Observable<any>;
|
|
8
|
+
private sanitizeBody;
|
|
9
|
+
private generateRequestId;
|
|
10
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.ElkLoggingInterceptor = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
const operators_1 = require("rxjs/operators");
|
|
15
|
+
const elk_service_1 = require("../elk.service");
|
|
16
|
+
let ElkLoggingInterceptor = class ElkLoggingInterceptor {
|
|
17
|
+
constructor(elkService) {
|
|
18
|
+
this.elkService = elkService;
|
|
19
|
+
}
|
|
20
|
+
intercept(context, next) {
|
|
21
|
+
const request = context.switchToHttp().getRequest();
|
|
22
|
+
const { method, url, body, headers, ip } = request;
|
|
23
|
+
const userAgent = headers['user-agent'] || '';
|
|
24
|
+
const requestId = headers['x-request-id'] || this.generateRequestId();
|
|
25
|
+
const startTime = Date.now();
|
|
26
|
+
this.elkService.log('Incoming request', {
|
|
27
|
+
context: 'HTTP',
|
|
28
|
+
method,
|
|
29
|
+
url,
|
|
30
|
+
requestId,
|
|
31
|
+
ip,
|
|
32
|
+
userAgent,
|
|
33
|
+
body: this.sanitizeBody(body),
|
|
34
|
+
});
|
|
35
|
+
return next.handle().pipe((0, operators_1.tap)((data) => {
|
|
36
|
+
const response = context.switchToHttp().getResponse();
|
|
37
|
+
const { statusCode } = response;
|
|
38
|
+
const duration = Date.now() - startTime;
|
|
39
|
+
this.elkService.log('Request completed', {
|
|
40
|
+
context: 'HTTP',
|
|
41
|
+
method,
|
|
42
|
+
url,
|
|
43
|
+
requestId,
|
|
44
|
+
statusCode,
|
|
45
|
+
duration: `${duration}ms`,
|
|
46
|
+
});
|
|
47
|
+
}), (0, operators_1.catchError)((error) => {
|
|
48
|
+
const duration = Date.now() - startTime;
|
|
49
|
+
this.elkService.error('Request failed', {
|
|
50
|
+
context: 'HTTP',
|
|
51
|
+
method,
|
|
52
|
+
url,
|
|
53
|
+
requestId,
|
|
54
|
+
error: error.message,
|
|
55
|
+
stack: error.stack,
|
|
56
|
+
duration: `${duration}ms`,
|
|
57
|
+
});
|
|
58
|
+
throw error;
|
|
59
|
+
}));
|
|
60
|
+
}
|
|
61
|
+
sanitizeBody(body) {
|
|
62
|
+
if (!body)
|
|
63
|
+
return body;
|
|
64
|
+
const sanitized = { ...body };
|
|
65
|
+
const sensitiveFields = ['password', 'token', 'secret', 'apiKey', 'creditCard'];
|
|
66
|
+
sensitiveFields.forEach(field => {
|
|
67
|
+
if (sanitized[field]) {
|
|
68
|
+
sanitized[field] = '***REDACTED***';
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
return sanitized;
|
|
72
|
+
}
|
|
73
|
+
generateRequestId() {
|
|
74
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.ElkLoggingInterceptor = ElkLoggingInterceptor;
|
|
78
|
+
exports.ElkLoggingInterceptor = ElkLoggingInterceptor = __decorate([
|
|
79
|
+
(0, common_1.Injectable)(),
|
|
80
|
+
__metadata("design:paramtypes", [elk_service_1.ElkService])
|
|
81
|
+
], ElkLoggingInterceptor);
|
|
82
|
+
//# sourceMappingURL=elk-logging.interceptor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elk-logging.interceptor.js","sourceRoot":"","sources":["../../../src/elk/interceptors/elk-logging.interceptor.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAKwB;AAExB,8CAAiD;AACjD,gDAA4C;AAGrC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAEvD,SAAS,CAAC,OA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+
requestTimeout?: number;
|
|
10
|
+
sniffOnStart?: boolean;
|
|
11
|
+
};
|
|
12
|
+
logging: {
|
|
13
|
+
index: string;
|
|
14
|
+
level?: 'error' | 'warn' | 'info' | 'debug' | 'verbose';
|
|
15
|
+
datePattern?: string;
|
|
16
|
+
maxFiles?: string;
|
|
17
|
+
consoleLog?: boolean;
|
|
18
|
+
includeContext?: boolean;
|
|
19
|
+
buffering?: boolean;
|
|
20
|
+
bufferLimit?: number;
|
|
21
|
+
flushInterval?: number;
|
|
22
|
+
retryLimit?: number;
|
|
23
|
+
};
|
|
24
|
+
serviceName: string;
|
|
25
|
+
environment: string;
|
|
26
|
+
}
|
|
27
|
+
export interface LogMetadata {
|
|
28
|
+
context?: string;
|
|
29
|
+
userId?: string;
|
|
30
|
+
requestId?: string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elk-config.interface.js","sourceRoot":"","sources":["../../../src/elk/interfaces/elk-config.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { EurekaConfig } from "./interfaces/eureka-config.interface";
|
|
3
|
+
export interface EurekaModuleOptions extends EurekaConfig {
|
|
4
|
+
}
|
|
5
|
+
export declare class EurekaModule {
|
|
6
|
+
static forRoot(config: EurekaModuleOptions): DynamicModule;
|
|
7
|
+
static forRootAsync(options: {
|
|
8
|
+
useFactory: (...args: any[]) => Promise<EurekaModuleOptions> | EurekaModuleOptions;
|
|
9
|
+
inject?: any[];
|
|
10
|
+
}): DynamicModule;
|
|
11
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var EurekaModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.EurekaModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const nest_eureka_1 = require("nest-eureka");
|
|
13
|
+
let EurekaModule = EurekaModule_1 = class EurekaModule {
|
|
14
|
+
static forRoot(config) {
|
|
15
|
+
return {
|
|
16
|
+
module: EurekaModule_1,
|
|
17
|
+
imports: [
|
|
18
|
+
nest_eureka_1.EurekaModule.forRoot({
|
|
19
|
+
eureka: {
|
|
20
|
+
host: config.eureka.host,
|
|
21
|
+
port: config.eureka.port,
|
|
22
|
+
servicePath: config.eureka.servicePath || '/eureka/apps/',
|
|
23
|
+
heartbeatInterval: config.eureka.heartbeatInterval || 15000,
|
|
24
|
+
registryFetchInterval: config.eureka.registryFetchInterval || 15000,
|
|
25
|
+
requestRetryDelay: config.eureka.requestRetryDelay || 2000,
|
|
26
|
+
maxRetries: config.eureka.maxRetries || 3,
|
|
27
|
+
connectionTimeout: config.eureka.connectionTimeout || 5000,
|
|
28
|
+
requestTimeout: config.eureka.requestTimeout || 10000,
|
|
29
|
+
renewalIntervalInSecs: config.service.renewalIntervalInSecs || 30,
|
|
30
|
+
durationInSecs: config.service.durationInSecs || 90,
|
|
31
|
+
healthCheckUrl: config.service.healthCheckUrl || '/health',
|
|
32
|
+
statusPageUrl: config.service.statusPageUrl || '/info',
|
|
33
|
+
homePageUrl: config.service.homePageUrl || '/',
|
|
34
|
+
dataCenterInfo: config.service.dataCenterInfo || {
|
|
35
|
+
name: 'MyOwn',
|
|
36
|
+
className: 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
|
|
37
|
+
},
|
|
38
|
+
ssl: config.eureka.ssl,
|
|
39
|
+
auth: config.eureka.auth,
|
|
40
|
+
},
|
|
41
|
+
service: {
|
|
42
|
+
name: config.service.name,
|
|
43
|
+
port: config.service.port,
|
|
44
|
+
host: config.service.host,
|
|
45
|
+
},
|
|
46
|
+
}),
|
|
47
|
+
],
|
|
48
|
+
exports: [nest_eureka_1.EurekaModule],
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static forRootAsync(options) {
|
|
52
|
+
return {
|
|
53
|
+
module: EurekaModule_1,
|
|
54
|
+
imports: [
|
|
55
|
+
nest_eureka_1.EurekaModule.forRootAsync({
|
|
56
|
+
useFactory: async (...args) => {
|
|
57
|
+
const config = await options.useFactory(...args);
|
|
58
|
+
return {
|
|
59
|
+
eureka: {
|
|
60
|
+
host: config.eureka.host,
|
|
61
|
+
port: config.eureka.port,
|
|
62
|
+
servicePath: config.eureka.servicePath || '/eureka/apps/',
|
|
63
|
+
heartbeatInterval: config.eureka.heartbeatInterval || 15000,
|
|
64
|
+
registryFetchInterval: config.eureka.registryFetchInterval || 15000,
|
|
65
|
+
requestRetryDelay: config.eureka.requestRetryDelay || 2000,
|
|
66
|
+
maxRetries: config.eureka.maxRetries || 3,
|
|
67
|
+
connectionTimeout: config.eureka.connectionTimeout || 5000,
|
|
68
|
+
requestTimeout: config.eureka.requestTimeout || 10000,
|
|
69
|
+
ssl: config.eureka.ssl,
|
|
70
|
+
auth: config.eureka.auth,
|
|
71
|
+
},
|
|
72
|
+
service: {
|
|
73
|
+
name: config.service.name,
|
|
74
|
+
port: config.service.port,
|
|
75
|
+
host: config.service.host,
|
|
76
|
+
renewalIntervalInSecs: config.service.renewalIntervalInSecs || 30,
|
|
77
|
+
durationInSecs: config.service.durationInSecs || 90,
|
|
78
|
+
healthCheckUrl: config.service.healthCheckUrl || '/health',
|
|
79
|
+
statusPageUrl: config.service.statusPageUrl || '/info',
|
|
80
|
+
homePageUrl: config.service.homePageUrl || '/',
|
|
81
|
+
dataCenterInfo: config.service.dataCenterInfo || {
|
|
82
|
+
name: 'MyOwn',
|
|
83
|
+
className: 'com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo',
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
},
|
|
88
|
+
inject: options.inject || [],
|
|
89
|
+
}),
|
|
90
|
+
],
|
|
91
|
+
exports: [nest_eureka_1.EurekaModule],
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
exports.EurekaModule = EurekaModule;
|
|
96
|
+
exports.EurekaModule = EurekaModule = EurekaModule_1 = __decorate([
|
|
97
|
+
(0, common_1.Global)(),
|
|
98
|
+
(0, common_1.Module)({})
|
|
99
|
+
], EurekaModule);
|
|
100
|
+
//# sourceMappingURL=eureka.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eureka.module.js","sourceRoot":"","sources":["../../src/eureka/eureka.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,6CAA+D;AAOxD,IAAM,YAAY,oBAAlB,MAAM,YAAY;IACrB,MAAM,CAAC,OAAO,CAAC,MAA2B;QACtC,OAAO;YACH,MAAM,EAAE,cAAY;YACpB,OAAO,EAAE;gBACL,0BAAgB,CAAC,OAAO,CAAC;oBACrB,MAAM,EAAE;wBACJ,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;wBACxB,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI;wBACxB,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,WAAW,IAAI,eAAe;wBACzD,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC,iBAAiB,IAAI,KAAK;wBAC3D,qBAAqB,EAAE,MAAM,CAAC,MAAM,CAAC,qBAAqB,IAAI,KAAK;wBACnE,iBAAiB,EAAE,MAAM,CAAC,MAAM,CAAC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AAC,cAAc,IAAI;oCAC7C,IAAI,EAAE,OAAO;oCACb,SAAS,EAAE,wDAAwD;iCACtE;6BACJ;yBACJ,CAAC;oBACN,CAAC;oBACD,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;iBAC/B,CAAC;aACL;YACD,OAAO,EAAE,CAAC,0BAAgB,CAAC;SAC9B,CAAC;IACN,CAAC;CACJ,CAAA;AArFY,oCAAY;uBAAZ,YAAY;IAFxB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,YAAY,CAqFxB"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=eureka.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eureka.service.js","sourceRoot":"","sources":["../../src/eureka/eureka.service.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface EurekaConfig {
|
|
2
|
+
eureka: {
|
|
3
|
+
host: string;
|
|
4
|
+
port: number;
|
|
5
|
+
servicePath?: string;
|
|
6
|
+
heartbeatInterval?: number;
|
|
7
|
+
registryFetchInterval?: number;
|
|
8
|
+
requestRetryDelay?: number;
|
|
9
|
+
maxRetries?: number;
|
|
10
|
+
connectionTimeout?: number;
|
|
11
|
+
requestTimeout?: number;
|
|
12
|
+
ssl?: boolean;
|
|
13
|
+
auth?: {
|
|
14
|
+
user: string;
|
|
15
|
+
password: string;
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
service: {
|
|
19
|
+
name: string;
|
|
20
|
+
port: number;
|
|
21
|
+
host: string;
|
|
22
|
+
renewalIntervalInSecs?: number;
|
|
23
|
+
durationInSecs?: number;
|
|
24
|
+
healthCheckUrl?: string;
|
|
25
|
+
statusPageUrl?: string;
|
|
26
|
+
homePageUrl?: string;
|
|
27
|
+
dataCenterInfo?: {
|
|
28
|
+
name: string;
|
|
29
|
+
className?: string;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
metadata?: Record<string, string>;
|
|
33
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eureka-config.interface.js","sourceRoot":"","sources":["../../../src/eureka/interfaces/eureka-config.interface.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClientOptions } from '@nestjs/microservices';
|
|
2
|
+
import { GrpcConfig } from './interfaces/grpc-config.interface';
|
|
3
|
+
export declare class GrpcHelper {
|
|
4
|
+
static buildClientOptions(config: GrpcConfig): ClientOptions;
|
|
5
|
+
static buildMicroserviceOptions(config: GrpcConfig): ClientOptions;
|
|
6
|
+
static resolveProtoPath(packageName: string, basePath?: string): string;
|
|
7
|
+
static resolveAllProtoPath(basePath?: string): string;
|
|
8
|
+
static buildMultiPackageConfig(packages: string[], url: string, useAllProto?: boolean): GrpcConfig;
|
|
9
|
+
}
|