@yolo-croket-dev/core 1.4.49 → 1.4.51

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.
@@ -6,6 +6,5 @@ export declare class RPCInterceptor implements NestInterceptor {
6
6
  constructor(reflector: Reflector);
7
7
  private maxLengthOverShorten;
8
8
  private updateMaxLengthArrayShorten;
9
- private keyCutter;
10
9
  intercept(context: ExecutionContext, next: CallHandler): Promise<Observable<unknown>>;
11
10
  }
@@ -8,9 +8,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.RPCInterceptor = void 0;
16
13
  /* eslint-disable no-param-reassign */
@@ -18,11 +15,10 @@ const common_1 = require("@nestjs/common");
18
15
  const core_1 = require("@nestjs/core");
19
16
  const rxjs_1 = require("rxjs");
20
17
  const operators_1 = require("rxjs/operators");
21
- const logger_1 = __importDefault(require("@yolo-croket-dev/logger"));
18
+ // import Logger from '@yolo-croket-dev/logger';
22
19
  const functions_1 = require("../functions");
23
20
  const exceptions_1 = require("../exceptions");
24
- const logger = logger_1.default.createLogger('RPCInterceptor');
25
- const MAX_CUT_LENGTH = 500;
21
+ // const MAX_CUT_LENGTH = 500;
26
22
  const MAX_LENGTH = 300;
27
23
  let RPCInterceptor = class RPCInterceptor {
28
24
  constructor(reflector) {
@@ -83,36 +79,32 @@ let RPCInterceptor = class RPCInterceptor {
83
79
  }
84
80
  return obj;
85
81
  }
86
- keyCutter(data) {
87
- try {
88
- if (data) {
89
- data = JSON.parse(data);
90
- }
91
- else {
92
- return data;
93
- }
94
- }
95
- catch (err) {
96
- return data;
97
- }
98
- for (const key of Object.keys(data)) {
99
- const type = typeof data[key];
100
- if (type === 'string') {
101
- if (data[key].length > MAX_CUT_LENGTH) {
102
- data[key] = `${data[key].slice(0, MAX_CUT_LENGTH)}...`;
103
- }
104
- }
105
- else if (type === 'object') {
106
- if (data[key] === null) {
107
- data[key] = null;
108
- }
109
- else {
110
- data[key] = this.keyCutter(data[key]);
111
- }
112
- }
113
- }
114
- return data;
115
- }
82
+ // private keyCutter(data: string) {
83
+ // try {
84
+ // if (data) {
85
+ // data = JSON.parse(data);
86
+ // } else {
87
+ // return data;
88
+ // }
89
+ // } catch (err) {
90
+ // return data;
91
+ // }
92
+ // for (const key of Object.keys(data)) {
93
+ // const type = typeof data[key as any];
94
+ // if (type === 'string') {
95
+ // if (data[key as any].length > MAX_CUT_LENGTH) {
96
+ // (data[key as any] as any) = `${data[key as any].slice(0, MAX_CUT_LENGTH)}...`;
97
+ // }
98
+ // } else if (type === 'object') {
99
+ // if (data[key as any] === null) {
100
+ // (data[key as any] as any) = null;
101
+ // } else {
102
+ // (data[key as any] as any) = this.keyCutter(data[key as any]);
103
+ // }
104
+ // }
105
+ // }
106
+ // return data;
107
+ // }
116
108
  async intercept(context, next) {
117
109
  var _a;
118
110
  const options = this.reflector.get('rpcInterceptorScope', context.getHandler());
@@ -123,17 +115,25 @@ let RPCInterceptor = class RPCInterceptor {
123
115
  const message = rmq.getMessage();
124
116
  const now = Date.now();
125
117
  const content = JSON.parse(message.content.toString());
126
- const traceId = content.data.param ? content.data.param.traceId : null;
118
+ // const traceId = content.data.param ? content.data.param.traceId : null;
127
119
  const isInternal = content.data.param ? content.data.param.isInternal : false;
128
120
  const isAdmin = content.data.param ? content.data.param.isAdmin : false;
129
- const method = content.pattern;
121
+ // const method = content.pattern;
130
122
  const reDeliveryCount = Number(message.properties.headers['x-delivery-count']) || 0; /** 몇번 재전달되었는지 */
131
123
  const staticRetryCount = Number(options === null || options === void 0 ? void 0 : options.messageRetryCount) || 0; /** 최대 재시도 갯수 */
132
- const logParam = {
133
- traceId,
134
- method,
135
- };
124
+ // const logParam = {
125
+ // traceId,
126
+ // method,
127
+ // };
136
128
  if (!staticRetryCount && reDeliveryCount > 0) {
129
+ channel.sendToQueue(message.properties.replyTo, Buffer.from(JSON.stringify({
130
+ isError: true,
131
+ message: 'RETRY_COUNT_ZERO_OR_NO_RETRY',
132
+ status: 500,
133
+ duration: Date.now() - now,
134
+ arg,
135
+ timestamp: new Date(),
136
+ })), { correlationId: message.properties.correlationId });
137
137
  channel.nack(message, false, false); /** 아마도 기본 30분 타임아웃이 지나고 새로 들어오면 발생할 예정, DLQ로 이동 */
138
138
  message.properties.replyTo = undefined; /** replyTo가 존재하면 sendToQueue가 호출되므로, 삭제해주기 */
139
139
  return new rxjs_1.Observable();
@@ -190,11 +190,11 @@ let RPCInterceptor = class RPCInterceptor {
190
190
  const messageContent = message.content.toString();
191
191
  /** 파일 객체 처리 */
192
192
  (0, functions_1.reWriteFileValue)((_a = messageContent === null || messageContent === void 0 ? void 0 : messageContent.data) === null || _a === void 0 ? void 0 : _a.file);
193
- logger.debug(`<= (error:${traceId}): ${JSON.stringify(sendMessage.toString())}`, {
194
- ...logParam,
195
- duration,
196
- isError: true,
197
- });
193
+ // logger.debug(`<= (error:${traceId}): ${JSON.stringify(sendMessage.toString())}`, {
194
+ // ...logParam,
195
+ // duration,
196
+ // isError: true,
197
+ // });
198
198
  if (!noAck && !isAck) {
199
199
  channel.ack(message);
200
200
  }
@@ -226,10 +226,10 @@ let RPCInterceptor = class RPCInterceptor {
226
226
  if (content.data.payload.file) {
227
227
  content.data.payload.file = `${content.data.payload.file.slice(0, 30)}...`;
228
228
  }
229
- logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
229
+ // logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
230
230
  }
231
231
  else {
232
- logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
232
+ // logger.debug(`=> (${traceId}): ${JSON.stringify(this.keyCutter(JSON.stringify(content)))}`);
233
233
  }
234
234
  // eslint-disable-next-line consistent-return
235
235
  return next
@@ -237,12 +237,12 @@ let RPCInterceptor = class RPCInterceptor {
237
237
  .pipe((0, operators_1.tap)({
238
238
  next: async (val) => {
239
239
  val.isError = false;
240
- const duration = Date.now() - now;
241
- logger.debug(`<= (success:${traceId}): ${val.message}`, {
242
- ...logParam,
243
- duration,
244
- isError: val.isError,
245
- });
240
+ // const duration = Date.now() - now;
241
+ // logger.debug(`<= (success:${traceId}): ${val.message}`, {
242
+ // ...logParam,
243
+ // duration,
244
+ // isError: val.isError,
245
+ // });
246
246
  /** 만약 응답데이터중 isRequeue가 true라면, 다시 재처리 하도록 함 */
247
247
  if (val.data && val.data.isRequeue) {
248
248
  channel.nack(message, false, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.4.49",
3
+ "version": "1.4.51",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
@@ -16,7 +16,7 @@
16
16
  "dependencies": {
17
17
  "@nestjs/common": "^8.2.3",
18
18
  "@nestjs/microservices": "9.0.8",
19
- "@yolo-croket-dev/logger": "^1.0.13",
19
+ "@yolo-croket-dev/logger": "^1.0.15",
20
20
  "@yolo-croket-dev/redis": "^1.0.22",
21
21
  "@yolo-croket-dev/swagger": "^0.0.7",
22
22
  "axios": "^1.1.3",