@nathapp/nestjs-microservices 1.0.0-rc.8 → 1.0.0-rc.9

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.
@@ -5,6 +5,7 @@ const auth_1 = require("@nathapp/auth");
5
5
  const nestjs_common_1 = require("@nathapp/nestjs-common");
6
6
  const common_1 = require("@nestjs/common");
7
7
  const axios_1 = require("axios");
8
+ const nestjs_i18n_1 = require("nestjs-i18n");
8
9
  class HttpServiceAdapter {
9
10
  constructor(options) {
10
11
  this.logger = new common_1.Logger(HttpServiceAdapter.name);
@@ -32,6 +33,17 @@ class HttpServiceAdapter {
32
33
  if (bearer) {
33
34
  headers["Authorization"] = `Bearer ${bearer}`;
34
35
  }
36
+ try {
37
+ const i18n = nestjs_i18n_1.I18nContext.current();
38
+ const lang = i18n === null || i18n === void 0 ? void 0 : i18n.lang;
39
+ if (!headers.hasOwnProperty("lang") && !headers.hasOwnProperty("Accept-Language") && lang) {
40
+ headers["lang"] = lang;
41
+ headers["Accept-Language"] = lang;
42
+ }
43
+ }
44
+ catch (err) {
45
+ this.logger.verbose(`I18nContext get Language Error`);
46
+ }
35
47
  try {
36
48
  const response = await this.axiosClient.post(method, payload, { headers });
37
49
  if (!response) {
@@ -45,9 +57,9 @@ class HttpServiceAdapter {
45
57
  const result = response.data;
46
58
  if ("0" != result.ret) {
47
59
  this.logger.error(`Failed response - ret: ${result.ret}, url: ${url},method ${method}, timeout: ${requestTimeout}`);
48
- this.logger.error(`Failed response message: ${result.msg}`);
60
+ this.logger.error(`Failed response message: ${result.msg || result.message}`);
49
61
  if (result.ret) {
50
- throw new nestjs_common_1.AppException(result.ret);
62
+ throw new nestjs_common_1.HttpMicroServiceException(result.ret, result.msg || result.message);
51
63
  }
52
64
  else {
53
65
  throw new nestjs_common_1.AppException(nestjs_common_1.CommonExceptionCode.UNKNOWN_ERROR);
@@ -1,2 +1,3 @@
1
+ import { JwtMsAuthGuard } from "./jwt-ms-auth.guard";
1
2
  import { MicroServiceJwtAuthGuard } from "./micro-service.guard";
2
- export { MicroServiceJwtAuthGuard };
3
+ export { JwtMsAuthGuard, MicroServiceJwtAuthGuard, };
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MicroServiceJwtAuthGuard = void 0;
3
+ exports.MicroServiceJwtAuthGuard = exports.JwtMsAuthGuard = void 0;
4
+ const jwt_ms_auth_guard_1 = require("./jwt-ms-auth.guard");
5
+ Object.defineProperty(exports, "JwtMsAuthGuard", { enumerable: true, get: function () { return jwt_ms_auth_guard_1.JwtMsAuthGuard; } });
4
6
  const micro_service_guard_1 = require("./micro-service.guard");
5
7
  Object.defineProperty(exports, "MicroServiceJwtAuthGuard", { enumerable: true, get: function () { return micro_service_guard_1.MicroServiceJwtAuthGuard; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nathapp/nestjs-microservices",
3
- "version": "1.0.0-rc.8",
3
+ "version": "1.0.0-rc.9",
4
4
  "description": "nestjs-microservices",
5
5
  "scripts": {
6
6
  "build": "rimraf dist && tsc -p tsconfig.json",
@@ -34,8 +34,8 @@
34
34
  },
35
35
  "dependencies": {
36
36
  "@nathapp/auth": "^1.0.1",
37
- "@nathapp/nestjs-auth": "^1.0.0-rc.18",
38
- "@nathapp/nestjs-common": "^1.0.1-rc.9",
37
+ "@nathapp/nestjs-auth": "^1.0.0-rc.20",
38
+ "@nathapp/nestjs-common": "^1.0.1-rc.10",
39
39
  "axios": "^1.4.0",
40
40
  "passport-jwt": "^4.0.1"
41
41
  },