@saultechitsolutions/gighub-shared-core 1.0.4 → 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/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 +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +2 -1
|
@@ -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,iBAAi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;gCAC1D,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,aAAa,IAAI,OAAO;gCACtD,WAAW,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,IAAI,GAAG;gCAC9C,cAAc,EAAE,MAAM,CAAC,OAAO,CAAC,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
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GrpcHelper = void 0;
|
|
4
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
class GrpcHelper {
|
|
7
|
+
static buildClientOptions(config) {
|
|
8
|
+
return {
|
|
9
|
+
transport: microservices_1.Transport.GRPC,
|
|
10
|
+
options: {
|
|
11
|
+
package: config.package,
|
|
12
|
+
protoPath: config.protoPath,
|
|
13
|
+
url: config.url,
|
|
14
|
+
loader: config.loader || {
|
|
15
|
+
keepCase: true,
|
|
16
|
+
longs: String,
|
|
17
|
+
enums: String,
|
|
18
|
+
defaults: true,
|
|
19
|
+
oneofs: true,
|
|
20
|
+
},
|
|
21
|
+
credentials: config.credentials,
|
|
22
|
+
channelOptions: config.channelOptions,
|
|
23
|
+
maxSendMessageLength: config.maxSendMessageLength,
|
|
24
|
+
maxReceiveMessageLength: config.maxReceiveMessageLength,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static buildMicroserviceOptions(config) {
|
|
29
|
+
return this.buildClientOptions(config);
|
|
30
|
+
}
|
|
31
|
+
static resolveProtoPath(packageName, basePath = 'node_modules/@saultechnologies/proto-definitions/src/grpc/proto') {
|
|
32
|
+
return (0, path_1.join)(process.cwd(), basePath, `${packageName}.proto`);
|
|
33
|
+
}
|
|
34
|
+
static resolveAllProtoPath(basePath = 'node_modules/@saultechnologies/proto-definitions/src/grpc/proto') {
|
|
35
|
+
return (0, path_1.join)(process.cwd(), basePath, 'all.proto');
|
|
36
|
+
}
|
|
37
|
+
static buildMultiPackageConfig(packages, url, useAllProto = true) {
|
|
38
|
+
if (useAllProto) {
|
|
39
|
+
return {
|
|
40
|
+
package: packages,
|
|
41
|
+
protoPath: this.resolveAllProtoPath(),
|
|
42
|
+
url,
|
|
43
|
+
loader: {
|
|
44
|
+
keepCase: true,
|
|
45
|
+
longs: String,
|
|
46
|
+
enums: String,
|
|
47
|
+
defaults: true,
|
|
48
|
+
oneofs: true,
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return {
|
|
53
|
+
package: packages,
|
|
54
|
+
protoPath: packages.map((pkg) => this.resolveProtoPath(pkg)),
|
|
55
|
+
url,
|
|
56
|
+
loader: {
|
|
57
|
+
keepCase: true,
|
|
58
|
+
longs: String,
|
|
59
|
+
enums: String,
|
|
60
|
+
defaults: true,
|
|
61
|
+
oneofs: true,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.GrpcHelper = GrpcHelper;
|
|
67
|
+
//# sourceMappingURL=grpc.helper.js.map
|
|
@@ -0,0 +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,EACX,WAAW,GAAG,IAAI;QAElB,IAAI,WAAW,EAAE,CAAC;YACd,OAAO;gBACH,OAAO,EAAE,QAAQ;gBACjB,SAAS,EAAE,IAAI,CAAC,mBAAmB,EAAE;gBACrC,GAAG;gBACH,MAAM,EAAE;oBACJ,QAAQ,EAAE,IAAI;oBACd,KAAK,EAAE,MAAM;oBACb,KAAK,EAAE,MAAM;oBACb,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAI;iBACf;aACJ,CAAC;QACN,CAAC;QAGD,OAAO;YACH,OAAO,EAAE,QAAQ;YACjB,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,CAAC;YAC5D,GAAG;YACH,MAAM,EAAE;gBACJ,QAAQ,EAAE,IAAI;gBACd,KAAK,EAAE,MAAM;gBACb,KAAK,EAAE,MAAM;gBACb,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,IAAI;aACf;SACJ,CAAC;IACN,CAAC;CACJ;AA1FD,gCA0FC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import { GrpcConfig } from './interfaces/grpc-config.interface';
|
|
3
|
+
export interface GrpcModuleOptions {
|
|
4
|
+
name: string;
|
|
5
|
+
config: GrpcConfig;
|
|
6
|
+
}
|
|
7
|
+
export declare class GrpcModule {
|
|
8
|
+
static forRoot(options: GrpcModuleOptions | GrpcModuleOptions[]): DynamicModule;
|
|
9
|
+
static forRootAsync(options: {
|
|
10
|
+
name: string;
|
|
11
|
+
useFactory: (...args: any[]) => Promise<GrpcConfig> | GrpcConfig;
|
|
12
|
+
inject?: any[];
|
|
13
|
+
}): DynamicModule;
|
|
14
|
+
static forRootAsyncMultiple(options: Array<{
|
|
15
|
+
name: string;
|
|
16
|
+
useFactory: (...args: any[]) => Promise<GrpcConfig> | GrpcConfig;
|
|
17
|
+
inject?: any[];
|
|
18
|
+
}>): DynamicModule;
|
|
19
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
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 GrpcModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GrpcModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const microservices_1 = require("@nestjs/microservices");
|
|
13
|
+
const grpc_helper_1 = require("./grpc.helper");
|
|
14
|
+
let GrpcModule = GrpcModule_1 = class GrpcModule {
|
|
15
|
+
static forRoot(options) {
|
|
16
|
+
const optionsArray = Array.isArray(options) ? options : [options];
|
|
17
|
+
return {
|
|
18
|
+
module: GrpcModule_1,
|
|
19
|
+
imports: [
|
|
20
|
+
microservices_1.ClientsModule.register(optionsArray.map((opt) => ({
|
|
21
|
+
name: opt.name,
|
|
22
|
+
...grpc_helper_1.GrpcHelper.buildClientOptions(opt.config),
|
|
23
|
+
}))),
|
|
24
|
+
],
|
|
25
|
+
exports: [microservices_1.ClientsModule],
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
static forRootAsync(options) {
|
|
29
|
+
return {
|
|
30
|
+
module: GrpcModule_1,
|
|
31
|
+
imports: [
|
|
32
|
+
microservices_1.ClientsModule.registerAsync([
|
|
33
|
+
{
|
|
34
|
+
name: options.name,
|
|
35
|
+
useFactory: async (...args) => {
|
|
36
|
+
const config = await options.useFactory(...args);
|
|
37
|
+
return grpc_helper_1.GrpcHelper.buildClientOptions(config);
|
|
38
|
+
},
|
|
39
|
+
inject: options.inject || [],
|
|
40
|
+
},
|
|
41
|
+
]),
|
|
42
|
+
],
|
|
43
|
+
exports: [microservices_1.ClientsModule],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static forRootAsyncMultiple(options) {
|
|
47
|
+
return {
|
|
48
|
+
module: GrpcModule_1,
|
|
49
|
+
imports: [
|
|
50
|
+
microservices_1.ClientsModule.registerAsync(options.map((opt) => ({
|
|
51
|
+
name: opt.name,
|
|
52
|
+
useFactory: async (...args) => {
|
|
53
|
+
const config = await opt.useFactory(...args);
|
|
54
|
+
return grpc_helper_1.GrpcHelper.buildClientOptions(config);
|
|
55
|
+
},
|
|
56
|
+
inject: opt.inject || [],
|
|
57
|
+
}))),
|
|
58
|
+
],
|
|
59
|
+
exports: [microservices_1.ClientsModule],
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
exports.GrpcModule = GrpcModule;
|
|
64
|
+
exports.GrpcModule = GrpcModule = GrpcModule_1 = __decorate([
|
|
65
|
+
(0, common_1.Global)(),
|
|
66
|
+
(0, common_1.Module)({})
|
|
67
|
+
], GrpcModule);
|
|
68
|
+
//# sourceMappingURL=grpc.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc.module.js","sourceRoot":"","sources":["../../src/grpc/grpc.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAC/D,yDAAiE;AAEjE,+CAA2C;AASpC,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAInB,MAAM,CAAC,OAAO,CAAC,OAAgD;QAC3D,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;QAElE,OAAO;YACH,MA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AAC;oBACjD,CAAC;oBACD,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,EAAE;iBAC3B,CAAC,CAAC,CACN;aACJ;YACD,OAAO,EAAE,CAAC,6BAAa,CAAC;SAC3B,CAAC;IACN,CAAC;CACJ,CAAA;AA1EY,gCAAU;qBAAV,UAAU;IAFtB,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,UAAU,CA0EtB"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface GrpcPackageConfig {
|
|
2
|
+
name: string;
|
|
3
|
+
protoPath: string;
|
|
4
|
+
}
|
|
5
|
+
export interface GrpcConfig {
|
|
6
|
+
url: string;
|
|
7
|
+
package?: string | string[];
|
|
8
|
+
protoPath?: string | string[];
|
|
9
|
+
packages?: GrpcPackageConfig[];
|
|
10
|
+
loader?: {
|
|
11
|
+
keepCase?: boolean;
|
|
12
|
+
longs?: any;
|
|
13
|
+
enums?: any;
|
|
14
|
+
defaults?: boolean;
|
|
15
|
+
oneofs?: boolean;
|
|
16
|
+
includeDirs?: string[];
|
|
17
|
+
};
|
|
18
|
+
credentials?: any;
|
|
19
|
+
channelOptions?: Record<string, any>;
|
|
20
|
+
maxSendMessageLength?: number;
|
|
21
|
+
maxReceiveMessageLength?: number;
|
|
22
|
+
interceptors?: any[];
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"grpc-config.interface.js","sourceRoot":"","sources":["../../../src/grpc/interfaces/grpc-config.interface.ts"],"names":[],"mappings":""}
|
package/dist/index.d.ts
CHANGED
|
@@ -27,3 +27,8 @@ export * from './audit/interfaces/audit-log.interface';
|
|
|
27
27
|
export * from './kafka/interfaces/kafka-config.interface';
|
|
28
28
|
export * from './redis/interfaces/redis-config.interface';
|
|
29
29
|
export * from './elk/interfaces/elk-config.interface';
|
|
30
|
+
export * from './eureka/eureka.module';
|
|
31
|
+
export * from './eureka/interfaces/eureka-config.interface';
|
|
32
|
+
export * from './grpc/grpc.module';
|
|
33
|
+
export * from './grpc/grpc.helper';
|
|
34
|
+
export * from './grpc/interfaces/grpc-config.interface';
|
package/dist/index.js
CHANGED
|
@@ -43,4 +43,9 @@ __exportStar(require("./audit/interfaces/audit-log.interface"), exports);
|
|
|
43
43
|
__exportStar(require("./kafka/interfaces/kafka-config.interface"), exports);
|
|
44
44
|
__exportStar(require("./redis/interfaces/redis-config.interface"), exports);
|
|
45
45
|
__exportStar(require("./elk/interfaces/elk-config.interface"), exports);
|
|
46
|
+
__exportStar(require("./eureka/eureka.module"), exports);
|
|
47
|
+
__exportStar(require("./eureka/interfaces/eureka-config.interface"), exports);
|
|
48
|
+
__exportStar(require("./grpc/grpc.module"), exports);
|
|
49
|
+
__exportStar(require("./grpc/grpc.helper"), exports);
|
|
50
|
+
__exportStar(require("./grpc/interfaces/grpc-config.interface"), exports);
|
|
46
51
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,uDAAqC;AACrC,mEAAiD;AACjD,mDAAiC;AAGjC,wDAAsC;AACtC,wDAAsC;AACtC,wDAAsC;AACtC,oEAAkD;AAClD,oDAAiC;AAGjC,sDAAoC;AACpC,uDAAqC;AAGrC,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAG3D,kEAAgD;AAChD,oEAAkD;AAGlD,sEAAoD;AACpD,+DAA6C;AAG7C,iDAA+B;AAC/B,uDAAqC;AACrC,yDAAuC;AAGvC,kEAAgD;AAChD,6DAA2C;AAC3C,kEAAgD;AAGhD,yEAAuD;AACvD,4EAA0D;AAC1D,4EAA0D;AAC1D,wEAAsD"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,uDAAqC;AACrC,uDAAqC;AACrC,mEAAiD;AACjD,mDAAiC;AAGjC,wDAAsC;AACtC,wDAAsC;AACtC,wDAAsC;AACtC,oEAAkD;AAClD,oDAAiC;AAGjC,sDAAoC;AACpC,uDAAqC;AAGrC,qEAAmD;AACnD,uEAAqD;AACrD,6EAA2D;AAG3D,kEAAgD;AAChD,oEAAkD;AAGlD,sEAAoD;AACpD,+DAA6C;AAG7C,iDAA+B;AAC/B,uDAAqC;AACrC,yDAAuC;AAGvC,kEAAgD;AAChD,6DAA2C;AAC3C,kEAAgD;AAGhD,yEAAuD;AACvD,4EAA0D;AAC1D,4EAA0D;AAC1D,wEAAsD;AAEtD,yDAAuC;AACvC,8EAA4D;AAG5D,qDAAmC;AACnC,qDAAmC;AACnC,0EAAwD"}
|