phx-node 1.0.37 → 1.0.38

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.
@@ -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
- throw new Error(`Failed to post data: ${error.message}`);
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":";;;;;;;;;;;;;;;;;;;;;AAAA,2CAA+C;AAC/C,2CAA4C;AAC5C,yCAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YACmB,aAA4B,EAC5B,WAAwB;QADxB,kBAAa,GAAb,aAAa,CAAe;QAC5B,gBAAW,GAAX,WAAW,CAAa;IACxC,CAAC;IAES,QAAQ,CAAC,GAAQ,EAAE,SAAiB;;YAC/C,MAAM,GAAG,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;YAClD,MAAM,IAAI,GAAG,GAAG,GAAG,GAAG,SAAS,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,GAAG,CAAC;YAEpB,MAAM,MAAM,GAAG;gBACb,OAAO,EAAE;oBACP,cAAc,EAAE,SAAS;iBAC1B;aACF,CAAC;YAEF,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,WAAW;qBACpC,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,CAAC;qBAC3B,SAAS,EAAE,CAAC;gBACf,OAAO,QAAQ,CAAC,IAAI,CAAC;YACvB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,IAAI,KAAK,CAAC,wBAAwB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;YAC3D,CAAC;QACH,CAAC;KAAA;CACF,CAAA;AA1BY,gCAAU;qBAAV,UAAU;IADtB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