ts-deco 1.0.27 → 1.0.28
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/src/decorators/controllers/lib/resource.decorator.d.ts +9 -7
- package/dist/src/decorators/controllers/lib/resource.decorator.d.ts.map +1 -1
- package/dist/src/decorators/controllers/lib/resource.decorator.js +25 -10
- package/dist/src/decorators/controllers/lib/resource.decorator.js.map +1 -1
- package/package.json +1 -1
|
@@ -3,25 +3,27 @@ import type { ResourceOptions } from "../types/controller.types";
|
|
|
3
3
|
export type { ResourceOptions } from "../types/controller.types";
|
|
4
4
|
/**
|
|
5
5
|
* Resource 데코레이터 - Controller 관련 클래스 데코레이터를 통합
|
|
6
|
-
* NestJS
|
|
6
|
+
* NestJS `@Controller()` + ts-deco Controller(메타데이터) + DocTags를 한 번에 적용
|
|
7
7
|
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```
|
|
10
|
-
* // 간단한 사용법 (태그만)
|
|
8
|
+
* @example 태그만
|
|
9
|
+
* ```ts
|
|
11
10
|
* @Resource('Users')
|
|
12
11
|
* class UserController {}
|
|
12
|
+
* ```
|
|
13
13
|
*
|
|
14
|
-
*
|
|
14
|
+
* @example 태그 + 경로
|
|
15
|
+
* ```ts
|
|
15
16
|
* @Resource('Users', '/api/users')
|
|
16
17
|
* class UserController {}
|
|
18
|
+
* ```
|
|
17
19
|
*
|
|
18
|
-
*
|
|
20
|
+
* @example 옵션 객체 (추가 태그 포함)
|
|
21
|
+
* ```ts
|
|
19
22
|
* @Resource({
|
|
20
23
|
* tag: 'Users',
|
|
21
24
|
* path: '/api/users',
|
|
22
25
|
* extraTags: ['Admin', 'Auth'],
|
|
23
26
|
* })
|
|
24
|
-
* @Controller()
|
|
25
27
|
* class UserController {}
|
|
26
28
|
* ```
|
|
27
29
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorators/controllers/lib/resource.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"resource.decorator.d.ts","sourceRoot":"","sources":["../../../../../src/decorators/controllers/lib/resource.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAI1B,OAAO,KAAK,EAEV,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAGnC,YAAY,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAYjE;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,QAAQ,CACtB,YAAY,EAAE,MAAM,GAAG,eAAe,EACtC,IAAI,CAAC,EAAE,MAAM,GACZ,cAAc,CAgChB"}
|
|
@@ -2,32 +2,43 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Resource = Resource;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
5
|
const apply_decorators_1 = require("../../utils/apply-decorators");
|
|
7
6
|
const controller_decorator_1 = require("./controller.decorator");
|
|
8
7
|
const doc_tags_decorator_1 = require("./doc-tags.decorator");
|
|
9
8
|
const parse_resource_args_1 = require("../utils/parse-resource-args");
|
|
9
|
+
/** NestJS Controller 데코레이터 팩토리 (동적 로드, 선택적 사용) */
|
|
10
|
+
function getNestController() {
|
|
11
|
+
try {
|
|
12
|
+
const { Controller } = require("@nestjs/common");
|
|
13
|
+
return Controller;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
10
19
|
/**
|
|
11
20
|
* Resource 데코레이터 - Controller 관련 클래스 데코레이터를 통합
|
|
12
|
-
* NestJS
|
|
21
|
+
* NestJS `@Controller()` + ts-deco Controller(메타데이터) + DocTags를 한 번에 적용
|
|
13
22
|
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```
|
|
16
|
-
* // 간단한 사용법 (태그만)
|
|
23
|
+
* @example 태그만
|
|
24
|
+
* ```ts
|
|
17
25
|
* @Resource('Users')
|
|
18
26
|
* class UserController {}
|
|
27
|
+
* ```
|
|
19
28
|
*
|
|
20
|
-
*
|
|
29
|
+
* @example 태그 + 경로
|
|
30
|
+
* ```ts
|
|
21
31
|
* @Resource('Users', '/api/users')
|
|
22
32
|
* class UserController {}
|
|
33
|
+
* ```
|
|
23
34
|
*
|
|
24
|
-
*
|
|
35
|
+
* @example 옵션 객체 (추가 태그 포함)
|
|
36
|
+
* ```ts
|
|
25
37
|
* @Resource({
|
|
26
38
|
* tag: 'Users',
|
|
27
39
|
* path: '/api/users',
|
|
28
40
|
* extraTags: ['Admin', 'Auth'],
|
|
29
41
|
* })
|
|
30
|
-
* @Controller()
|
|
31
42
|
* class UserController {}
|
|
32
43
|
* ```
|
|
33
44
|
*/
|
|
@@ -40,9 +51,13 @@ function Resource(tagOrOptions, path) {
|
|
|
40
51
|
controllerOptions.tag = tag;
|
|
41
52
|
if (controllerPath)
|
|
42
53
|
controllerOptions.path = controllerPath;
|
|
54
|
+
// 1. NestJS 라우팅용 @Controller() - @nestjs/common 있을 때만 적용
|
|
55
|
+
const NestController = getNestController();
|
|
56
|
+
if (NestController) {
|
|
57
|
+
decorators.push(NestController(controllerPath ?? ""));
|
|
58
|
+
}
|
|
59
|
+
// 2. ts-deco Controller (Swagger 메타데이터 - CONTROLLER_PATH, DOC_TAGS)
|
|
43
60
|
decorators.push((0, controller_decorator_1.Controller)(controllerOptions));
|
|
44
|
-
// NestJS 라우팅용 @Controller() 적용 (컨트롤러 등록을 위해 필수)
|
|
45
|
-
decorators.push((0, common_1.Controller)(controllerPath ?? ""));
|
|
46
61
|
}
|
|
47
62
|
if (extraTags && extraTags.length > 0) {
|
|
48
63
|
decorators.push((0, doc_tags_decorator_1.DocTags)(...extraTags));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resource.decorator.js","sourceRoot":"","sources":["../../../../../src/decorators/controllers/lib/resource.decorator.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"resource.decorator.js","sourceRoot":"","sources":["../../../../../src/decorators/controllers/lib/resource.decorator.ts"],"names":[],"mappings":";;AAgDA,4BAmCC;AAnFD,4BAA0B;AAC1B,mEAA+D;AAC/D,iEAAoD;AACpD,6DAA+C;AAK/C,sEAAiE;AAIjE,kDAAkD;AAClD,SAAS,iBAAiB;IACxB,IAAI,CAAC;QACH,MAAM,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;QACjD,OAAO,UAAU,CAAC;IACpB,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,SAAgB,QAAQ,CACtB,YAAsC,EACtC,IAAa;IAEb,MAAM,UAAU,GAAqB,EAAE,CAAC;IACxC,MAAM,EACJ,GAAG,EACH,IAAI,EAAE,cAAc,EACpB,SAAS,GACV,GAAG,IAAA,uCAAiB,EAAC,YAAY,EAAE,IAAI,CAAC,CAAC;IAE1C,IAAI,GAAG,IAAI,cAAc,EAAE,CAAC;QAC1B,MAAM,iBAAiB,GAAsB,EAAE,CAAC;QAChD,IAAI,GAAG;YAAE,iBAAiB,CAAC,GAAG,GAAG,GAAG,CAAC;QACrC,IAAI,cAAc;YAAE,iBAAiB,CAAC,IAAI,GAAG,cAAc,CAAC;QAC5D,yDAAyD;QACzD,MAAM,cAAc,GAAG,iBAAiB,EAAE,CAAC;QAC3C,IAAI,cAAc,EAAE,CAAC;YACnB,UAAU,CAAC,IAAI,CAAC,cAAc,CAAC,cAAc,IAAI,EAAE,CAAmB,CAAC,CAAC;QAC1E,CAAC;QACD,oEAAoE;QACpE,UAAU,CAAC,IAAI,CAAC,IAAA,iCAAU,EAAC,iBAAiB,CAAC,CAAC,CAAC;IACjD,CAAC;IAED,IAAI,SAAS,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,UAAU,CAAC,IAAI,CAAC,IAAA,4BAAO,EAAC,GAAG,SAAS,CAAmB,CAAC,CAAC;IAC3D,CAAC;IAED,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,UAAU,MAAW;YAC1B,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC;IACJ,CAAC;IAED,OAAO,IAAA,kCAAe,EAAC,GAAG,UAAU,CAAC,CAAC;AACxC,CAAC"}
|