@asapjs/router 1.0.0-alpha.42 → 1.0.0-alpha.43
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/decorator/AutoInject.d.ts +2 -24
- package/dist/decorator/AutoInject.d.ts.map +1 -1
- package/dist/decorator/AutoInject.js +9 -31
- package/dist/decorator/AutoInject.js.map +1 -1
- package/dist/decorator/ErrorPayload.d.ts +1 -4
- package/dist/decorator/ErrorPayload.d.ts.map +1 -1
- package/dist/decorator/ErrorPayload.js +7 -14
- package/dist/decorator/ErrorPayload.js.map +1 -1
- package/dist/decorator/ResponsePayload.d.ts +1 -19
- package/dist/decorator/ResponsePayload.d.ts.map +1 -1
- package/dist/decorator/ResponsePayload.js +7 -29
- package/dist/decorator/ResponsePayload.js.map +1 -1
- package/dist/decorator/index.d.ts +6 -6
- package/dist/decorator/index.d.ts.map +1 -1
- package/dist/decorator/index.js +10 -13
- package/dist/decorator/index.js.map +1 -1
- package/dist/express/router.d.ts +25 -22
- package/dist/express/router.d.ts.map +1 -1
- package/dist/express/router.js +51 -408
- package/dist/express/router.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -3
- package/dist/index.js.map +1 -1
- package/dist/middleware/errorHandler.d.ts +4 -1
- package/dist/middleware/errorHandler.d.ts.map +1 -1
- package/dist/middleware/errorHandler.js +14 -10
- package/dist/middleware/errorHandler.js.map +1 -1
- package/dist/plugin.d.ts.map +1 -1
- package/dist/plugin.js +20 -30
- package/dist/plugin.js.map +1 -1
- package/dist/registry.d.ts +3 -18
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +10 -22
- package/dist/registry.js.map +1 -1
- package/dist/router/index.d.ts +21 -3
- package/dist/router/index.d.ts.map +1 -1
- package/dist/router/index.js +24 -122
- package/dist/router/index.js.map +1 -1
- package/dist/swagger/index.d.ts +2 -17
- package/dist/swagger/index.d.ts.map +1 -1
- package/dist/swagger/index.js +17 -222
- package/dist/swagger/index.js.map +1 -1
- package/dist/utils/defineMiddleware.js +1 -1
- package/dist/utils/defineMiddleware.js.map +1 -1
- package/dist/utils/generateSchemeRefWithName.d.ts +2 -2
- package/dist/utils/generateSchemeRefWithName.d.ts.map +1 -1
- package/dist/utils/generateSchemeRefWithName.js +4 -1
- package/dist/utils/generateSchemeRefWithName.js.map +1 -1
- package/dist/utils/wrapper.d.ts +16 -10
- package/dist/utils/wrapper.d.ts.map +1 -1
- package/dist/utils/wrapper.js +23 -84
- package/dist/utils/wrapper.js.map +1 -1
- package/package.json +21 -14
- package/dist/utils/registeredMiddlewares.d.ts +0 -4
- package/dist/utils/registeredMiddlewares.d.ts.map +0 -1
- package/dist/utils/registeredMiddlewares.js +0 -12
- package/dist/utils/registeredMiddlewares.js.map +0 -1
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const AUTO_INJECT_METADATA_KEY = "response:autoInject";
|
|
4
|
-
export interface AutoInjectEntry {
|
|
5
|
-
key: string;
|
|
6
|
-
factory: (req: Request) => any;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* Marks a field in a Global Response DTO as auto-injected.
|
|
10
|
-
* The factory function receives the Express Request and returns the value to inject.
|
|
11
|
-
*
|
|
12
|
-
* @example
|
|
13
|
-
* class GlobalResponseDto extends ExtendableDto {
|
|
14
|
-
* @TypeIs.INT({ comment: '응답 시각' })
|
|
15
|
-
* @AutoInject(() => Date.now())
|
|
16
|
-
* timestamp: number;
|
|
17
|
-
*
|
|
18
|
-
* @TypeIs.STRING({ comment: '요청 ID' })
|
|
19
|
-
* @AutoInject((req) => req.headers['x-request-id'] || uuid())
|
|
20
|
-
* requestId: string;
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
export declare function AutoInject(factory: (req: Request) => any): PropertyDecorator;
|
|
24
|
-
export declare function getAutoInjectEntries(DtoClass: new () => any): AutoInjectEntry[];
|
|
1
|
+
export { AUTO_INJECT_METADATA_KEY, AutoInject, getAutoInjectEntries } from '@asapjs/common';
|
|
2
|
+
export type { AutoInjectEntry } from '@asapjs/common';
|
|
25
3
|
//# sourceMappingURL=AutoInject.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoInject.d.ts","sourceRoot":"","sources":["../../src/decorator/AutoInject.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"AutoInject.d.ts","sourceRoot":"","sources":["../../src/decorator/AutoInject.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAC5F,YAAY,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,34 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AUTO_INJECT_METADATA_KEY = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* @example
|
|
13
|
-
* class GlobalResponseDto extends ExtendableDto {
|
|
14
|
-
* @TypeIs.INT({ comment: '응답 시각' })
|
|
15
|
-
* @AutoInject(() => Date.now())
|
|
16
|
-
* timestamp: number;
|
|
17
|
-
*
|
|
18
|
-
* @TypeIs.STRING({ comment: '요청 ID' })
|
|
19
|
-
* @AutoInject((req) => req.headers['x-request-id'] || uuid())
|
|
20
|
-
* requestId: string;
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
function AutoInject(factory) {
|
|
24
|
-
return (target, propertyKey) => {
|
|
25
|
-
const key = String(propertyKey);
|
|
26
|
-
const existing = Reflect.getMetadata(exports.AUTO_INJECT_METADATA_KEY, target.constructor) || [];
|
|
27
|
-
existing.push({ key, factory });
|
|
28
|
-
Reflect.defineMetadata(exports.AUTO_INJECT_METADATA_KEY, existing, target.constructor);
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
function getAutoInjectEntries(DtoClass) {
|
|
32
|
-
return Reflect.getMetadata(exports.AUTO_INJECT_METADATA_KEY, DtoClass) || [];
|
|
33
|
-
}
|
|
3
|
+
exports.getAutoInjectEntries = exports.AutoInject = exports.AUTO_INJECT_METADATA_KEY = void 0;
|
|
4
|
+
// R13 (adapter-neutral extraction): the AutoInject decorator + its
|
|
5
|
+
// reflect-metadata store moved to @asapjs/common/http so @asapjs/fastify reuses
|
|
6
|
+
// the identical metadata key. Re-exported here so the pre-existing
|
|
7
|
+
// `@asapjs/router` import paths keep working unchanged.
|
|
8
|
+
var common_1 = require("@asapjs/common");
|
|
9
|
+
Object.defineProperty(exports, "AUTO_INJECT_METADATA_KEY", { enumerable: true, get: function () { return common_1.AUTO_INJECT_METADATA_KEY; } });
|
|
10
|
+
Object.defineProperty(exports, "AutoInject", { enumerable: true, get: function () { return common_1.AutoInject; } });
|
|
11
|
+
Object.defineProperty(exports, "getAutoInjectEntries", { enumerable: true, get: function () { return common_1.getAutoInjectEntries; } });
|
|
34
12
|
//# sourceMappingURL=AutoInject.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoInject.js","sourceRoot":"","sources":["../../src/decorator/AutoInject.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"AutoInject.js","sourceRoot":"","sources":["../../src/decorator/AutoInject.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,gFAAgF;AAChF,mEAAmE;AACnE,wDAAwD;AACxD,yCAA4F;AAAnF,kHAAA,wBAAwB,OAAA;AAAE,oGAAA,UAAU,OAAA;AAAE,8GAAA,oBAAoB,OAAA"}
|
|
@@ -1,5 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const ERROR_PAYLOAD_METADATA_KEY = "response:errorPayloadKey";
|
|
3
|
-
export declare function ErrorPayload(): PropertyDecorator;
|
|
4
|
-
export declare function getErrorPayloadKey(DtoClass: new () => any): string | undefined;
|
|
1
|
+
export { ERROR_PAYLOAD_METADATA_KEY, ErrorPayload, getErrorPayloadKey } from '@asapjs/common';
|
|
5
2
|
//# sourceMappingURL=ErrorPayload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPayload.d.ts","sourceRoot":"","sources":["../../src/decorator/ErrorPayload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ErrorPayload.d.ts","sourceRoot":"","sources":["../../src/decorator/ErrorPayload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ERROR_PAYLOAD_METADATA_KEY = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require("
|
|
7
|
-
exports
|
|
8
|
-
function
|
|
9
|
-
|
|
10
|
-
const key = String(propertyKey);
|
|
11
|
-
Reflect.defineMetadata(exports.ERROR_PAYLOAD_METADATA_KEY, key, target.constructor);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
function getErrorPayloadKey(DtoClass) {
|
|
15
|
-
return Reflect.getMetadata(exports.ERROR_PAYLOAD_METADATA_KEY, DtoClass);
|
|
16
|
-
}
|
|
3
|
+
exports.getErrorPayloadKey = exports.ErrorPayload = exports.ERROR_PAYLOAD_METADATA_KEY = void 0;
|
|
4
|
+
// R13 (adapter-neutral extraction): moved to @asapjs/common/http; re-exported
|
|
5
|
+
// so the pre-existing `@asapjs/router` import paths keep working unchanged.
|
|
6
|
+
var common_1 = require("@asapjs/common");
|
|
7
|
+
Object.defineProperty(exports, "ERROR_PAYLOAD_METADATA_KEY", { enumerable: true, get: function () { return common_1.ERROR_PAYLOAD_METADATA_KEY; } });
|
|
8
|
+
Object.defineProperty(exports, "ErrorPayload", { enumerable: true, get: function () { return common_1.ErrorPayload; } });
|
|
9
|
+
Object.defineProperty(exports, "getErrorPayloadKey", { enumerable: true, get: function () { return common_1.getErrorPayloadKey; } });
|
|
17
10
|
//# sourceMappingURL=ErrorPayload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorPayload.js","sourceRoot":"","sources":["../../src/decorator/ErrorPayload.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ErrorPayload.js","sourceRoot":"","sources":["../../src/decorator/ErrorPayload.ts"],"names":[],"mappings":";;;AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E,yCAA8F;AAArF,oHAAA,0BAA0B,OAAA;AAAE,sGAAA,YAAY,OAAA;AAAE,4GAAA,kBAAkB,OAAA"}
|
|
@@ -1,20 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const RESPONSE_PAYLOAD_METADATA_KEY = "response:payloadKey";
|
|
3
|
-
/**
|
|
4
|
-
* Marks a field in a Global Response DTO as the slot where each route's response DTO will be placed.
|
|
5
|
-
* If no field is marked with @ResponsePayload(), the Global DTO operates in "spread" mode:
|
|
6
|
-
* the route DTO's fields are merged at the top level using OpenAPI allOf.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* class DefaultResponseDto extends ExtendableDto {
|
|
10
|
-
* @TypeIs.INT()
|
|
11
|
-
* @AutoInject(() => Date.now())
|
|
12
|
-
* timestamp: number;
|
|
13
|
-
*
|
|
14
|
-
* @ResponsePayload()
|
|
15
|
-
* result: any; // route DTO goes here
|
|
16
|
-
* }
|
|
17
|
-
*/
|
|
18
|
-
export declare function ResponsePayload(): PropertyDecorator;
|
|
19
|
-
export declare function getResponsePayloadKey(DtoClass: new () => any): string | undefined;
|
|
1
|
+
export { RESPONSE_PAYLOAD_METADATA_KEY, ResponsePayload, getResponsePayloadKey } from '@asapjs/common';
|
|
20
2
|
//# sourceMappingURL=ResponsePayload.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsePayload.d.ts","sourceRoot":"","sources":["../../src/decorator/ResponsePayload.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ResponsePayload.d.ts","sourceRoot":"","sources":["../../src/decorator/ResponsePayload.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,6BAA6B,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC"}
|
|
@@ -1,32 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.RESPONSE_PAYLOAD_METADATA_KEY = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require("
|
|
7
|
-
exports
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
* If no field is marked with @ResponsePayload(), the Global DTO operates in "spread" mode:
|
|
11
|
-
* the route DTO's fields are merged at the top level using OpenAPI allOf.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* class DefaultResponseDto extends ExtendableDto {
|
|
15
|
-
* @TypeIs.INT()
|
|
16
|
-
* @AutoInject(() => Date.now())
|
|
17
|
-
* timestamp: number;
|
|
18
|
-
*
|
|
19
|
-
* @ResponsePayload()
|
|
20
|
-
* result: any; // route DTO goes here
|
|
21
|
-
* }
|
|
22
|
-
*/
|
|
23
|
-
function ResponsePayload() {
|
|
24
|
-
return (target, propertyKey) => {
|
|
25
|
-
const key = String(propertyKey);
|
|
26
|
-
Reflect.defineMetadata(exports.RESPONSE_PAYLOAD_METADATA_KEY, key, target.constructor);
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
function getResponsePayloadKey(DtoClass) {
|
|
30
|
-
return Reflect.getMetadata(exports.RESPONSE_PAYLOAD_METADATA_KEY, DtoClass);
|
|
31
|
-
}
|
|
3
|
+
exports.getResponsePayloadKey = exports.ResponsePayload = exports.RESPONSE_PAYLOAD_METADATA_KEY = void 0;
|
|
4
|
+
// R13 (adapter-neutral extraction): moved to @asapjs/common/http; re-exported
|
|
5
|
+
// so the pre-existing `@asapjs/router` import paths keep working unchanged.
|
|
6
|
+
var common_1 = require("@asapjs/common");
|
|
7
|
+
Object.defineProperty(exports, "RESPONSE_PAYLOAD_METADATA_KEY", { enumerable: true, get: function () { return common_1.RESPONSE_PAYLOAD_METADATA_KEY; } });
|
|
8
|
+
Object.defineProperty(exports, "ResponsePayload", { enumerable: true, get: function () { return common_1.ResponsePayload; } });
|
|
9
|
+
Object.defineProperty(exports, "getResponsePayloadKey", { enumerable: true, get: function () { return common_1.getResponsePayloadKey; } });
|
|
32
10
|
//# sourceMappingURL=ResponsePayload.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponsePayload.js","sourceRoot":"","sources":["../../src/decorator/ResponsePayload.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"ResponsePayload.js","sourceRoot":"","sources":["../../src/decorator/ResponsePayload.ts"],"names":[],"mappings":";;;AAAA,8EAA8E;AAC9E,4EAA4E;AAC5E,yCAAuG;AAA9F,uHAAA,6BAA6B,OAAA;AAAE,yGAAA,eAAe,OAAA;AAAE,+GAAA,qBAAqB,OAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { ErrorCreator } from '@asapjs/error';
|
|
2
|
-
import
|
|
2
|
+
import type { IPreference } from '../express/router';
|
|
3
3
|
export { AutoInject, getAutoInjectEntries } from './AutoInject';
|
|
4
4
|
export type { AutoInjectEntry } from './AutoInject';
|
|
5
5
|
export { ResponsePayload, getResponsePayloadKey } from './ResponsePayload';
|
|
6
6
|
export { ErrorPayload, getErrorPayloadKey } from './ErrorPayload';
|
|
7
7
|
export interface GlobalRouteOptions {
|
|
8
8
|
}
|
|
9
|
-
export interface IOptions extends Omit<IPreference, 'path' | 'excute'>, GlobalRouteOptions {
|
|
9
|
+
export interface IOptions extends Omit<IPreference, 'path' | 'excute' | 'execute'>, GlobalRouteOptions {
|
|
10
10
|
errors?: ErrorCreator[];
|
|
11
11
|
}
|
|
12
|
-
export declare function Get(path: string, options: IOptions): (target:
|
|
13
|
-
export declare function Post(path: string, options: IOptions): (target:
|
|
14
|
-
export declare function Put(path: string, options: IOptions): (target:
|
|
15
|
-
export declare function Delete(path: string, options: IOptions): (target:
|
|
12
|
+
export declare function Get(path: string, options: IOptions): (target: any, propertyKey: string) => void;
|
|
13
|
+
export declare function Post(path: string, options: IOptions): (target: any, propertyKey: string) => void;
|
|
14
|
+
export declare function Put(path: string, options: IOptions): (target: any, propertyKey: string) => void;
|
|
15
|
+
export declare function Delete(path: string, options: IOptions): (target: any, propertyKey: string) => void;
|
|
16
16
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,OAAO,EAAE,UAAU,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAGlE,MAAM,WAAW,kBAAkB;CAAG;AAEtC,MAAM,WAAW,QAAS,SAAQ,IAAI,CAAC,WAAW,EAAE,MAAM,GAAG,QAAQ,GAAG,SAAS,CAAC,EAAE,kBAAkB;IACpG,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;CACzB;AAQD,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,8CAElD;AAED,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,8CAEnD;AAED,wBAAgB,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,8CAElD;AAED,wBAAgB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,8CAErD"}
|
package/dist/decorator/index.js
CHANGED
|
@@ -5,6 +5,7 @@ exports.Get = Get;
|
|
|
5
5
|
exports.Post = Post;
|
|
6
6
|
exports.Put = Put;
|
|
7
7
|
exports.Delete = Delete;
|
|
8
|
+
const common_1 = require("@asapjs/common");
|
|
8
9
|
var AutoInject_1 = require("./AutoInject");
|
|
9
10
|
Object.defineProperty(exports, "AutoInject", { enumerable: true, get: function () { return AutoInject_1.AutoInject; } });
|
|
10
11
|
Object.defineProperty(exports, "getAutoInjectEntries", { enumerable: true, get: function () { return AutoInject_1.getAutoInjectEntries; } });
|
|
@@ -14,25 +15,21 @@ Object.defineProperty(exports, "getResponsePayloadKey", { enumerable: true, get:
|
|
|
14
15
|
var ErrorPayload_1 = require("./ErrorPayload");
|
|
15
16
|
Object.defineProperty(exports, "ErrorPayload", { enumerable: true, get: function () { return ErrorPayload_1.ErrorPayload; } });
|
|
16
17
|
Object.defineProperty(exports, "getErrorPayloadKey", { enumerable: true, get: function () { return ErrorPayload_1.getErrorPayloadKey; } });
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
target.routes.push(Object.assign(Object.assign({ method,
|
|
23
|
-
path }, options), { methodName: propertyKey }));
|
|
24
|
-
};
|
|
25
|
-
}
|
|
18
|
+
// R13-②-b: `routes` 배열에 push하던 Route 팩토리 본문은 @asapjs/common/http의
|
|
19
|
+
// createRouteDecorators로 이관됐다(fastify decorator와 바이트 동일했던 부분).
|
|
20
|
+
// 공개 데코레이터는 함수 선언 형태를 유지한다 — 시그니처와 api-surface 골든의
|
|
21
|
+
// `function` kind가 그대로여야 한다.
|
|
22
|
+
const routeDecorators = (0, common_1.createRouteDecorators)();
|
|
26
23
|
function Get(path, options) {
|
|
27
|
-
return
|
|
24
|
+
return routeDecorators.Get(path, options);
|
|
28
25
|
}
|
|
29
26
|
function Post(path, options) {
|
|
30
|
-
return
|
|
27
|
+
return routeDecorators.Post(path, options);
|
|
31
28
|
}
|
|
32
29
|
function Put(path, options) {
|
|
33
|
-
return
|
|
30
|
+
return routeDecorators.Put(path, options);
|
|
34
31
|
}
|
|
35
32
|
function Delete(path, options) {
|
|
36
|
-
return
|
|
33
|
+
return routeDecorators.Delete(path, options);
|
|
37
34
|
}
|
|
38
35
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorator/index.ts"],"names":[],"mappings":";;;AAsBA,kBAEC;AAED,oBAEC;AAED,kBAEC;AAED,wBAEC;AApCD,2CAAuD;AAIvD,2CAAgE;AAAvD,wGAAA,UAAU,OAAA;AAAE,kHAAA,oBAAoB,OAAA;AAEzC,qDAA2E;AAAlE,kHAAA,eAAe,OAAA;AAAE,wHAAA,qBAAqB,OAAA;AAC/C,+CAAkE;AAAzD,4GAAA,YAAY,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AASzC,kEAAkE;AAClE,+DAA+D;AAC/D,mDAAmD;AACnD,6BAA6B;AAC7B,MAAM,eAAe,GAAG,IAAA,8BAAqB,GAAY,CAAC;AAE1D,SAAgB,GAAG,CAAC,IAAY,EAAE,OAAiB;IACjD,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,IAAI,CAAC,IAAY,EAAE,OAAiB;IAClD,OAAO,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC7C,CAAC;AAED,SAAgB,GAAG,CAAC,IAAY,EAAE,OAAiB;IACjD,OAAO,eAAe,CAAC,GAAG,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC5C,CAAC;AAED,SAAgB,MAAM,CAAC,IAAY,EAAE,OAAiB;IACpD,OAAO,eAAe,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC/C,CAAC"}
|
package/dist/express/router.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { ErrorCreator } from '@asapjs/error';
|
|
2
2
|
import { type DtoOrTypeIs } from '@asapjs/types';
|
|
3
3
|
import { Router as ExpressRouter } from 'express';
|
|
4
4
|
import type { GlobalRouteOptions } from '../decorator';
|
|
@@ -20,7 +20,16 @@ export interface IPreference {
|
|
|
20
20
|
response?: DtoOrTypeIs;
|
|
21
21
|
errors?: ErrorCreator[];
|
|
22
22
|
middleware?: any[];
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* 라우트 핸들러. `this.router.get({ path, execute })` 형태로 직접 라우트를 등록할 때 사용.
|
|
25
|
+
*/
|
|
26
|
+
execute?: any;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated 오타 API입니다. `execute`를 사용하세요. 기존 사용자 코드 호환을 위해 한
|
|
29
|
+
* 릴리스 동안만 유지되며 다음 릴리스에서 제거됩니다. 런타임은 `execute ?? excute` 순으로
|
|
30
|
+
* 핸들러를 해석하므로 `execute`가 우선합니다. (R12-③)
|
|
31
|
+
*/
|
|
32
|
+
excute?: any;
|
|
24
33
|
requestExamples?: RouteExample[];
|
|
25
34
|
responseExamples?: RouteExample[];
|
|
26
35
|
}
|
|
@@ -29,21 +38,26 @@ export interface IDecoratorPreference extends IPreference, GlobalRouteOptions {
|
|
|
29
38
|
method: MethodType;
|
|
30
39
|
methodName: string;
|
|
31
40
|
}
|
|
41
|
+
/**
|
|
42
|
+
* Express adapter controller. As of R13 the Swagger scheme-generation and
|
|
43
|
+
* path-item assembly it used to do inline moved to
|
|
44
|
+
* `@asapjs/common/http` (`buildRouteSwaggerPathItem` + the shared registries);
|
|
45
|
+
* this class is now a thin Express-specific wrapper — it resolves the route
|
|
46
|
+
* options, records the route, delegates document generation to the neutral
|
|
47
|
+
* builder, and binds the handler chain onto an Express `Router`. The Fastify
|
|
48
|
+
* adapter (step 2) reuses the exact same neutral builder.
|
|
49
|
+
*/
|
|
32
50
|
export default class RouterController {
|
|
33
51
|
basePath: string;
|
|
34
52
|
responseDto?: (new () => any) | null;
|
|
35
53
|
expressRouter: ExpressRouter;
|
|
36
54
|
constructor();
|
|
37
55
|
protected registerRoutes(): void;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
private generateDtoScheme;
|
|
44
|
-
private generateTypeScheme;
|
|
45
|
-
private generateErrorSchemes;
|
|
46
|
-
private generateSwaggerDefaultsSet;
|
|
56
|
+
execute: <TOptions extends IPreference & GlobalRouteOptions = IPreference & GlobalRouteOptions>(method: MethodType) => (options: TOptions) => void;
|
|
57
|
+
/**
|
|
58
|
+
* @deprecated 오타 API입니다. `execute`를 사용하세요. 기존 사용자 코드(`this.excute(...)`
|
|
59
|
+
* 직접 호출) 호환을 위해 한 릴리스 동안만 유지되며 다음 릴리스에서 제거됩니다. (R12-③)
|
|
60
|
+
*/
|
|
47
61
|
excute: <TOptions extends IPreference & GlobalRouteOptions = IPreference & GlobalRouteOptions>(method: MethodType) => (options: TOptions) => void;
|
|
48
62
|
router: {
|
|
49
63
|
get: (options: IPreference & GlobalRouteOptions) => void;
|
|
@@ -52,16 +66,5 @@ export default class RouterController {
|
|
|
52
66
|
delete: (options: IPreference & GlobalRouteOptions) => void;
|
|
53
67
|
};
|
|
54
68
|
}
|
|
55
|
-
interface AsConstructor<T> {
|
|
56
|
-
new (): T;
|
|
57
|
-
}
|
|
58
|
-
type returnTypeBodyOrQuery = 'body' | 'query';
|
|
59
|
-
type returnTypeFuncReturn = {
|
|
60
|
-
type: returnTypeBodyOrQuery;
|
|
61
|
-
data: any;
|
|
62
|
-
} | undefined | true;
|
|
63
|
-
type returnTypeFunc = () => returnTypeFuncReturn;
|
|
64
|
-
export declare const requestType: (Dto: AsConstructor<any> | true, innerType?: returnTypeBodyOrQuery, isArray?: boolean) => returnTypeFunc;
|
|
65
|
-
export declare const responseType: (Dto: AsConstructor<any> | true, innerType?: returnTypeBodyOrQuery, isArray?: boolean) => returnTypeFunc;
|
|
66
69
|
export {};
|
|
67
70
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/express/router.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/express/router.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,KAAK,WAAW,EAAwB,MAAM,eAAe,CAAC;AACvE,OAAO,EAAE,MAAM,IAAI,aAAa,EAAE,MAAM,SAAS,CAAC;AAElD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAMvD,KAAK,eAAe,GAAG,kBAAkB,GAAG,qBAAqB,CAAC;AAElE,MAAM,WAAW,YAAY;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,WAAW;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,WAAW,CAAC;IACvB,MAAM,CAAC,EAAE,YAAY,EAAE,CAAC;IACxB,UAAU,CAAC,EAAE,GAAG,EAAE,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC;IACb,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC;IACjC,gBAAgB,CAAC,EAAE,YAAY,EAAE,CAAC;CAClC;AAED,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE3D,MAAM,WAAW,oBAAqB,SAAQ,WAAW,EAAE,kBAAkB;IAC5E,MAAM,EAAE,UAAU,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;GAQG;AACH,MAAM,CAAC,OAAO,OAAO,gBAAgB;IAC7B,QAAQ,SAAO;IACf,WAAW,CAAC,EAAE,CAAC,UAAU,GAAG,CAAC,GAAG,IAAI,CAAC;IAErC,aAAa,EAAE,aAAa,CAAC;;IAMpC,SAAS,CAAC,cAAc;IAcjB,OAAO,GAAI,QAAQ,SAAS,WAAW,GAAG,kBAAkB,GAAG,WAAW,GAAG,kBAAkB,EAAE,QAAQ,UAAU,MAAM,SAAS,QAAQ,UAgE/I;IAEF;;;OAGG;IACI,MAAM,GAtEK,QAAQ,SAAS,WAAW,GAAG,kBAAkB,6CAA6C,UAAU,MAAM,SAAS,QAAQ,UAsEpH;IAEtB,MAAM;;;;;MAKX;CACF"}
|