phx-node 1.0.37 → 1.0.39
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/module/api/api.service.d.ts +2 -0
- package/dist/module/api/api.service.js +28 -3
- package/dist/module/api/api.service.js.map +1 -1
- package/dist/module/grpc-client/grpc-client-system.service.d.ts +2 -0
- package/dist/module/grpc-client/grpc-client-system.service.js +32 -0
- package/dist/module/grpc-client/grpc-client-system.service.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,8 @@ import { HttpService } from "@nestjs/axios";
|
|
|
3
3
|
export declare class ApiService {
|
|
4
4
|
private readonly configService;
|
|
5
5
|
private readonly httpService;
|
|
6
|
+
private readonly logger;
|
|
6
7
|
constructor(configService: ConfigService, httpService: HttpService);
|
|
7
8
|
postData(req: any, end_point: string): Promise<any>;
|
|
9
|
+
postDataV3(req: any, end_point: string, hostname: string): Promise<any>;
|
|
8
10
|
}
|
|
@@ -17,15 +17,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
|
+
var ApiService_1;
|
|
20
21
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
22
|
exports.ApiService = void 0;
|
|
22
23
|
const config_1 = require("@nestjs/config");
|
|
23
24
|
const common_1 = require("@nestjs/common");
|
|
24
25
|
const axios_1 = require("@nestjs/axios");
|
|
25
|
-
let ApiService = class ApiService {
|
|
26
|
+
let ApiService = ApiService_1 = class ApiService {
|
|
26
27
|
constructor(configService, httpService) {
|
|
27
28
|
this.configService = configService;
|
|
28
29
|
this.httpService = httpService;
|
|
30
|
+
this.logger = new common_1.Logger(ApiService_1.name);
|
|
29
31
|
}
|
|
30
32
|
postData(req, end_point) {
|
|
31
33
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -44,13 +46,36 @@ let ApiService = class ApiService {
|
|
|
44
46
|
return response.data;
|
|
45
47
|
}
|
|
46
48
|
catch (error) {
|
|
47
|
-
|
|
49
|
+
this.logger.error(`Failed to post data: ${error.message}`);
|
|
50
|
+
return [];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
postDataV3(req, end_point, hostname) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
const URL = this.configService.get("INTERNAL_API_GATEWAY");
|
|
57
|
+
const path = `${URL}${end_point}`;
|
|
58
|
+
const payload = req;
|
|
59
|
+
const config = {
|
|
60
|
+
headers: {
|
|
61
|
+
hostname,
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
try {
|
|
65
|
+
const response = yield this.httpService
|
|
66
|
+
.post(path, payload, config)
|
|
67
|
+
.toPromise();
|
|
68
|
+
return response.data;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
this.logger.error(`Failed to post data: ${error.message}`);
|
|
72
|
+
return [];
|
|
48
73
|
}
|
|
49
74
|
});
|
|
50
75
|
}
|
|
51
76
|
};
|
|
52
77
|
exports.ApiService = ApiService;
|
|
53
|
-
exports.ApiService = ApiService = __decorate([
|
|
78
|
+
exports.ApiService = ApiService = ApiService_1 = __decorate([
|
|
54
79
|
(0, common_1.Injectable)(),
|
|
55
80
|
__metadata("design:paramtypes", [config_1.ConfigService,
|
|
56
81
|
axios_1.HttpService])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../../src/module/api/api.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.service.js","sourceRoot":"","sources":["../../../src/module/api/api.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAAoD;AACpD,yCAA4C;AAGrC,IAAM,UAAU,kBAAhB,MAAM,UAAU;IAErB,YACmB,aAA4B,EAC5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O,EAAE,MAAM,CAAC;qBAC3B,SAAS,EAAE,CAAC;gBACf,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;gBAC3D,OAAO,EAAE,CAAC;YACZ,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AAtDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;qCAIuB,sBAAa;QACf,mBAAW;GAJhC,UAAU,CAsDtB"}
|
|
@@ -13,4 +13,6 @@ export declare class PHXGrpcClientSystemService {
|
|
|
13
13
|
debug(hostname: string): void;
|
|
14
14
|
query({ query, variables, hostname, }: GrpcRequestType): Promise<any>;
|
|
15
15
|
mutation({ query, variables, hostname, }: GrpcRequestType): Promise<any>;
|
|
16
|
+
queryDataCenter({ query, variables, hostname, }: GrpcRequestType): Promise<any>;
|
|
17
|
+
mutationDataCenter({ query, variables, hostname, }: GrpcRequestType): Promise<any>;
|
|
16
18
|
}
|
|
@@ -65,6 +65,38 @@ let PHXGrpcClientSystemService = PHXGrpcClientSystemService_1 = class PHXGrpcCli
|
|
|
65
65
|
}
|
|
66
66
|
});
|
|
67
67
|
}
|
|
68
|
+
queryDataCenter(_a) {
|
|
69
|
+
return __awaiter(this, arguments, void 0, function* ({ query, variables, hostname, }) {
|
|
70
|
+
if (!hostname)
|
|
71
|
+
return;
|
|
72
|
+
try {
|
|
73
|
+
const response = yield this.httpService
|
|
74
|
+
.post(`${this.grpcGatewayUrl}/grpc-client/query`, Object.assign(Object.assign({}, (variables && { variables })), { source: this.projectSource, query, headers: { hostname: "data-center" } }))
|
|
75
|
+
.toPromise();
|
|
76
|
+
return response.data;
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
console.log("error", error);
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
mutationDataCenter(_a) {
|
|
85
|
+
return __awaiter(this, arguments, void 0, function* ({ query, variables, hostname, }) {
|
|
86
|
+
if (!hostname)
|
|
87
|
+
return;
|
|
88
|
+
try {
|
|
89
|
+
const response = yield this.httpService
|
|
90
|
+
.post(`${this.grpcGatewayUrl}/grpc-client/mutation`, Object.assign(Object.assign({}, (variables && { variables })), { source: this.projectSource, query, headers: { hostname: "data-center" } }))
|
|
91
|
+
.toPromise();
|
|
92
|
+
return response.data;
|
|
93
|
+
}
|
|
94
|
+
catch (error) {
|
|
95
|
+
console.log("error", error);
|
|
96
|
+
return false;
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
}
|
|
68
100
|
};
|
|
69
101
|
exports.PHXGrpcClientSystemService = PHXGrpcClientSystemService;
|
|
70
102
|
exports.PHXGrpcClientSystemService = PHXGrpcClientSystemService = PHXGrpcClientSystemService_1 = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grpc-client-system.service.js","sourceRoot":"","sources":["../../../src/module/grpc-client/grpc-client-system.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,yCAA4C;AASrC,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAKrC,YAA6B,WAAwB;QAAxB,gBAAW,GAAX,WAAW,CAAa;QAJpC,WAAM,GAAG,IAAI,eAAM,CAAC,4BAA0B,CAAC,IAAI,CAAC,CAAC;QAKpE,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;QAC/C,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC;IAClD,CAAC;IAEM,KAAK,CAAC,QAAgB;QAC3B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;QAC5B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;IACzC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