@yolo-croket-dev/core 1.8.7 → 1.8.8-jun.0

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.
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class BadRequest extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class BadRequest extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class Conflict extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class Conflict extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,13 +1,16 @@
1
1
  import { HttpException } from '@nestjs/common';
2
+ import { ErrAction } from '../interfaces/exception';
3
+ import { MsaException } from '../interfaces/msa-exception';
2
4
  /**
3
5
  * Forbidden 지원
4
6
  * Type O
5
7
  * ErrAction X
6
8
  */
7
- export declare class Forbidden extends HttpException {
9
+ export declare class Forbidden extends HttpException implements MsaException {
8
10
  subMessage: string | null;
9
11
  errType: string | null;
10
12
  errMessage: string | null;
13
+ errAction: ErrAction | null;
11
14
  /** 해당 에러시 재시도 여부 */
12
15
  isRetry?: boolean;
13
16
  constructor(errType: string, errMessage?: string, isRetry?: boolean);
@@ -15,10 +15,12 @@ class Forbidden extends common_1.HttpException {
15
15
  // new
16
16
  this.errType = null;
17
17
  this.errMessage = null;
18
+ this.errAction = null;
18
19
  this.subMessage = errMessage || null;
19
20
  // new
20
21
  this.errType = errType || null;
21
22
  this.errMessage = errMessage || null;
23
+ this.errAction = null;
22
24
  this.isRetry = isRetry;
23
25
  }
24
26
  }
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class Gone extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class Gone extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class InternalServerError extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class InternalServerError extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class MethodNotAllowed extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class MethodNotAllowed extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class NotAcceptable extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class NotAcceptable extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,7 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class NotFound extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class NotFound extends HttpException implements MsaException {
4
5
  subMessage: string | null;
5
6
  errType: string | null;
6
7
  errMessage: string | null;
@@ -1,6 +1,9 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
- export declare class ServerPauseException extends HttpException {
3
+ import { MsaException } from '../interfaces/msa-exception';
4
+ export declare class ServerPauseException extends HttpException implements MsaException {
5
+ errType: string | null;
6
+ errMessage: string | null;
4
7
  errAction: ErrAction | null;
5
8
  constructor(serverPauseTitle: string, serverPauseMessage: string);
6
9
  }
@@ -6,7 +6,11 @@ const exception_1 = require("../interfaces/exception");
6
6
  class ServerPauseException extends common_1.HttpException {
7
7
  constructor(serverPauseTitle, serverPauseMessage) {
8
8
  super('SERVER_PAUSE_EXCEPTION', common_1.HttpStatus.SERVICE_UNAVAILABLE);
9
+ this.errType = null;
10
+ this.errMessage = null;
9
11
  this.errAction = null;
12
+ this.errType = 'SERVER_PAUSE_EXCEPTION';
13
+ this.errMessage = serverPauseMessage;
10
14
  this.errAction = {
11
15
  type: exception_1.ErrActionTypeEnum.SERVER_PAUSE,
12
16
  serverPauseTitle,
@@ -1,12 +1,14 @@
1
1
  import { HttpException } from '@nestjs/common';
2
2
  import { ErrAction } from '../interfaces/exception';
3
+ import { MsaException } from '../interfaces/msa-exception';
3
4
  /**
4
5
  * UnAuthorized 지원
5
6
  * Type X
6
7
  * ErrAction X
7
8
  */
8
- export declare class UnAuthorized extends HttpException {
9
+ export declare class UnAuthorized extends HttpException implements MsaException {
9
10
  subMessage: string | null;
11
+ errType: string | null;
10
12
  errMessage: string | null;
11
13
  errAction: ErrAction | null;
12
14
  constructor(errMessage?: string, errAction?: ErrAction);
@@ -13,10 +13,12 @@ class UnAuthorized extends common_1.HttpException {
13
13
  // legacy
14
14
  this.subMessage = null;
15
15
  // new
16
+ this.errType = null;
16
17
  this.errMessage = null;
17
18
  this.errAction = null;
18
19
  this.subMessage = errMessage || null;
19
20
  // new
21
+ this.errType = 'USER_AUTHENTICATION_FAIL';
20
22
  this.errMessage = errMessage || null;
21
23
  this.errAction = errAction || null;
22
24
  }
@@ -6,7 +6,7 @@ const rxjs_1 = require("rxjs");
6
6
  const operators_1 = require("rxjs/operators");
7
7
  const msa_logger_1 = require("@yolo-croket-dev/msa-logger");
8
8
  const _1 = require(".");
9
- const DEFAULT_TIMEOUT = 1000 * 60 * 29; // 29분 타임아웃
9
+ const DEFAULT_TIMEOUT = 1000 * 60 * 60 * 6; // 6시간 타임아웃
10
10
  const DEFAULT_TIMEOUT_MESSAGE = '요청이 타임아웃되었습니다.';
11
11
  const msaLogger = new msa_logger_1.MsaLogger(msa_logger_1.ServerTypeEnum.SERVICE);
12
12
  class HttpExceptionCustom extends common_1.HttpException {
@@ -5,3 +5,5 @@ export * from './rewrite-file-value.function';
5
5
  export * from './amqp-call-manager.function';
6
6
  export * from './extract-redis-url.function';
7
7
  export * from './abort';
8
+ export * from './uncaught-exception-handler';
9
+ export * from './unhandled-rejection-handler';
@@ -21,3 +21,5 @@ __exportStar(require("./rewrite-file-value.function"), exports);
21
21
  __exportStar(require("./amqp-call-manager.function"), exports);
22
22
  __exportStar(require("./extract-redis-url.function"), exports);
23
23
  __exportStar(require("./abort"), exports);
24
+ __exportStar(require("./uncaught-exception-handler"), exports);
25
+ __exportStar(require("./unhandled-rejection-handler"), exports);
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @author jun
3
+ * @description uncaughtException 핸들러 - 에러 로깅 및 모니터링
4
+ * @process
5
+ * 1. 에러 로그 기록 (MsaLogger, Datadog)
6
+ * 2. 개발팀에서 로그 확인 후 즉시 대응
7
+ *
8
+ * @note
9
+ * - uncaughtException 발생 시 즉시 로그를 기록하여 모니터링
10
+ * - 개발팀에서 알림을 받고 바로 대응 예정
11
+ * - MsaLogger 실패 시에도 console.error로 fallback 처리
12
+ */
13
+ export declare function uncaughtExceptionHandler(err: any): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.uncaughtExceptionHandler = void 0;
27
+ /* eslint-disable @typescript-eslint/no-explicit-any */
28
+ const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
29
+ const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.GATEWAY);
30
+ /**
31
+ * @author jun
32
+ * @description uncaughtException 핸들러 - 에러 로깅 및 모니터링
33
+ * @process
34
+ * 1. 에러 로그 기록 (MsaLogger, Datadog)
35
+ * 2. 개발팀에서 로그 확인 후 즉시 대응
36
+ *
37
+ * @note
38
+ * - uncaughtException 발생 시 즉시 로그를 기록하여 모니터링
39
+ * - 개발팀에서 알림을 받고 바로 대응 예정
40
+ * - MsaLogger 실패 시에도 console.error로 fallback 처리
41
+ */
42
+ function uncaughtExceptionHandler(err) {
43
+ try {
44
+ msaLogger.error('uncaughtException', {
45
+ traceId: 'uncaughtException',
46
+ errInfo: {
47
+ errType: err.name || 'Error',
48
+ status: err.status || 500,
49
+ message: err.message,
50
+ stack: err.stack,
51
+ },
52
+ });
53
+ }
54
+ catch (logError) {
55
+ // MsaLogger 실패 시 최후의 수단
56
+ // eslint-disable-next-line no-console
57
+ console.error('Failed to log uncaughtException:', logError);
58
+ // eslint-disable-next-line no-console
59
+ console.error('Original error:', err);
60
+ }
61
+ }
62
+ exports.uncaughtExceptionHandler = uncaughtExceptionHandler;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * @author jun
3
+ * @description unhandledRejection 핸들러 - 에러 로깅 및 모니터링
4
+ * @process
5
+ * 1. Promise rejection 에러 로그 기록
6
+ * 2. 개발팀에서 로그 확인 후 즉시 대응
7
+ *
8
+ * @note
9
+ * - unhandledRejection 발생 시 즉시 로그를 기록하여 모니터링
10
+ * - 개발팀에서 알림을 받고 바로 대응 예정
11
+ * - MsaLogger 실패 시에도 console.error로 fallback 처리
12
+ */
13
+ export declare function unhandledRejectionHandler(err: any): void;
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.unhandledRejectionHandler = void 0;
27
+ /* eslint-disable @typescript-eslint/no-explicit-any */
28
+ const msa_logger_1 = __importStar(require("@yolo-croket-dev/msa-logger"));
29
+ const msaLogger = new msa_logger_1.default(msa_logger_1.ServerTypeEnum.SERVICE);
30
+ /**
31
+ * @author jun
32
+ * @description unhandledRejection 핸들러 - 에러 로깅 및 모니터링
33
+ * @process
34
+ * 1. Promise rejection 에러 로그 기록
35
+ * 2. 개발팀에서 로그 확인 후 즉시 대응
36
+ *
37
+ * @note
38
+ * - unhandledRejection 발생 시 즉시 로그를 기록하여 모니터링
39
+ * - 개발팀에서 알림을 받고 바로 대응 예정
40
+ * - MsaLogger 실패 시에도 console.error로 fallback 처리
41
+ */
42
+ function unhandledRejectionHandler(err) {
43
+ try {
44
+ msaLogger.error('unhandledRejection', {
45
+ traceId: 'unhandledRejection',
46
+ errInfo: {
47
+ errType: (err === null || err === void 0 ? void 0 : err.name) || 'UnhandledRejection',
48
+ status: (err === null || err === void 0 ? void 0 : err.status) || 500,
49
+ message: (err === null || err === void 0 ? void 0 : err.message) || String(err),
50
+ stack: err === null || err === void 0 ? void 0 : err.stack,
51
+ },
52
+ });
53
+ }
54
+ catch (logError) {
55
+ // MsaLogger 실패 시 최후의 수단
56
+ // eslint-disable-next-line no-console
57
+ console.error('Failed to log unhandledRejection:', logError);
58
+ // eslint-disable-next-line no-console
59
+ console.error('Original error:', err);
60
+ }
61
+ }
62
+ exports.unhandledRejectionHandler = unhandledRejectionHandler;
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './exceptions';
2
2
  export * from './interceptors';
3
3
  export * from './interfaces';
4
+ export * from './functions';
package/index.js CHANGED
@@ -17,3 +17,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./exceptions"), exports);
18
18
  __exportStar(require("./interceptors"), exports);
19
19
  __exportStar(require("./interfaces"), exports);
20
+ __exportStar(require("./functions"), exports);
@@ -110,9 +110,7 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
110
110
  const currentSpan = dd_trace_1.default.scope().active();
111
111
  let loggingSpan = null;
112
112
  if (currentSpan) {
113
- loggingSpan = dd_trace_1.default.startSpan(`logging-service-interceptor-${content.pattern}`, {
114
- childOf: currentSpan.context(),
115
- });
113
+ loggingSpan = dd_trace_1.default.startSpan(`logging-service-interceptor-${content.pattern}`, { childOf: currentSpan.context() });
116
114
  }
117
115
  if (loggingSpan) {
118
116
  loggingSpan.setTag('traceId', traceId);
@@ -151,9 +149,9 @@ let LoggingServiceInterceptor = class LoggingServiceInterceptor {
151
149
  msaLogger.printExceptionFliterService({
152
150
  traceId,
153
151
  errInfo: {
154
- errType: error.message,
152
+ errType: error.subMessage ? error.message : error.name,
153
+ message: error.subMessage ? error.subMessage : error.message,
155
154
  status: error.status,
156
- message: error.subMessage,
157
155
  stack: error.stack,
158
156
  },
159
157
  messageBrokerInfo: {
@@ -2,3 +2,4 @@ export * from './http';
2
2
  export * from './decorator';
3
3
  export * from './exception';
4
4
  export * from './amqp';
5
+ export * from './msa-exception';
@@ -18,3 +18,4 @@ __exportStar(require("./http"), exports);
18
18
  __exportStar(require("./decorator"), exports);
19
19
  __exportStar(require("./exception"), exports);
20
20
  __exportStar(require("./amqp"), exports);
21
+ __exportStar(require("./msa-exception"), exports);
@@ -0,0 +1,25 @@
1
+ import { HttpException } from '@nestjs/common';
2
+ import { ErrAction } from './exception';
3
+ /**
4
+ * @author jun
5
+ * @description MSA 아키텍처에서 사용하는 공통 예외 인터페이스
6
+ * @process 커스텀 예외 클래스들이 구현하여 일관된 에러 처리 가능
7
+ */
8
+ export interface MsaException {
9
+ /** 에러 유형 코드 */
10
+ errType: string | null;
11
+ /** 에러 메시지 */
12
+ errMessage: string | null;
13
+ /** 클라이언트 액션 정보 */
14
+ errAction: ErrAction | null;
15
+ /** 재시도 가능 여부 */
16
+ isRetry?: boolean;
17
+ }
18
+ /** HttpException과 MsaException을 결합한 타입 */
19
+ export type MsaHttpException = MsaException & HttpException;
20
+ /**
21
+ * @description MsaException 타입 가드
22
+ * @param error 검사할 에러 객체
23
+ * @returns MsaHttpException 타입 여부
24
+ */
25
+ export declare function isMsaException(error: unknown): error is MsaHttpException;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isMsaException = void 0;
4
+ const common_1 = require("@nestjs/common");
5
+ /**
6
+ * @description MsaException 타입 가드
7
+ * @param error 검사할 에러 객체
8
+ * @returns MsaHttpException 타입 여부
9
+ */
10
+ function isMsaException(error) {
11
+ if (!error || typeof error !== 'object') {
12
+ return false;
13
+ }
14
+ const err = error;
15
+ return ('errType' in err
16
+ && 'errMessage' in err
17
+ && 'errAction' in err
18
+ && error instanceof common_1.HttpException);
19
+ }
20
+ exports.isMsaException = isMsaException;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yolo-croket-dev/core",
3
- "version": "1.8.7",
3
+ "version": "1.8.8-jun.0",
4
4
  "author": "Yolo Co., Ltd.",
5
5
  "description": "Yolo commonization module",
6
6
  "main": "index.js",
@@ -17,14 +17,14 @@
17
17
  "@nestjs/common": "^11.0.0",
18
18
  "@nestjs/swagger": "^11.0.0",
19
19
  "class-transformer": "^0.5.1",
20
- "class-validator": "^0.14.0"
20
+ "class-validator": "^0.14.0",
21
+ "dd-trace": "^5.0.0"
21
22
  },
22
23
  "dependencies": {
23
24
  "@yolo-croket-dev/logger": "^1.0.15",
24
- "@yolo-croket-dev/msa-logger": "^3.3.1",
25
+ "@yolo-croket-dev/msa-logger": "^3.4.2",
25
26
  "@yolo-croket-dev/redis": "^1.0.25",
26
27
  "axios": "^1.1.3",
27
- "dd-trace": "^5.46.0",
28
28
  "randomstring": "^1.2.2",
29
29
  "rxjs": "^7.4.0",
30
30
  "uuid": "^8.3.2"
@@ -1,9 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npm run lint)"
5
- ],
6
- "deny": [],
7
- "ask": []
8
- }
9
- }