@midwayjs/core 4.0.0-beta.10 → 4.0.0-beta.12
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/baseFramework.js +18 -1
- package/dist/common/asyncContextManager.js +0 -1
- package/dist/common/dataSourceManager.d.ts +1 -1
- package/dist/common/fileDetector.js +2 -0
- package/dist/common/webGenerator.js +3 -1
- package/dist/config/config.default.d.ts +2 -2
- package/dist/config/config.default.js +6 -1
- package/dist/context/componentLoader.js +1 -1
- package/dist/context/container.js +7 -0
- package/dist/decorator/common/tracer.d.ts +9 -0
- package/dist/decorator/common/tracer.js +18 -0
- package/dist/decorator/constant.d.ts +1 -0
- package/dist/decorator/constant.js +2 -1
- package/dist/decorator/index.d.ts +1 -0
- package/dist/decorator/index.js +1 -0
- package/dist/decorator/metadataManager.js +0 -2
- package/dist/decorator/web/requestMapping.d.ts +4 -0
- package/dist/decorator/web/requestMapping.js +14 -3
- package/dist/error/framework.d.ts +13 -1
- package/dist/error/framework.js +3 -1
- package/dist/functional/adapter.d.ts +4 -0
- package/dist/functional/adapter.js +7 -0
- package/dist/functional/api.d.ts +68 -0
- package/dist/functional/api.js +262 -0
- package/dist/functional/constants.d.ts +3 -0
- package/dist/functional/constants.js +6 -0
- package/dist/functional/hooks.js +0 -1
- package/dist/functional/index.d.ts +3 -0
- package/dist/functional/index.js +7 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/dist/interface.d.ts +29 -3
- package/dist/interface.js +1 -1
- package/dist/service/configService.js +0 -1
- package/dist/service/lifeCycleService.js +3 -1
- package/dist/service/traceService.d.ts +49 -0
- package/dist/service/traceService.js +306 -0
- package/dist/service/webRouterService.d.ts +40 -0
- package/dist/service/webRouterService.js +197 -45
- package/dist/setup.js +4 -0
- package/dist/util/index.d.ts +1 -0
- package/dist/util/index.js +78 -2
- package/package.json +3 -2
package/dist/baseFramework.js
CHANGED
|
@@ -22,6 +22,7 @@ const middlewareManager_1 = require("./common/middlewareManager");
|
|
|
22
22
|
const middlewareService_1 = require("./service/middlewareService");
|
|
23
23
|
const filterManager_1 = require("./common/filterManager");
|
|
24
24
|
const mockService_1 = require("./service/mockService");
|
|
25
|
+
const traceService_1 = require("./service/traceService");
|
|
25
26
|
const util = require("util");
|
|
26
27
|
const asyncContextManager_1 = require("./common/asyncContextManager");
|
|
27
28
|
const guardManager_1 = require("./common/guardManager");
|
|
@@ -180,6 +181,22 @@ class BaseFramework {
|
|
|
180
181
|
ctx.getApp = () => {
|
|
181
182
|
return this.getApplication();
|
|
182
183
|
};
|
|
184
|
+
if (!Object.getOwnPropertyDescriptor(ctx, 'traceId')) {
|
|
185
|
+
Object.defineProperty(ctx, 'traceId', {
|
|
186
|
+
get: () => {
|
|
187
|
+
try {
|
|
188
|
+
return this.getApplicationContext()
|
|
189
|
+
.get(traceService_1.MidwayTraceService)
|
|
190
|
+
.getTraceId();
|
|
191
|
+
}
|
|
192
|
+
catch {
|
|
193
|
+
return undefined;
|
|
194
|
+
}
|
|
195
|
+
},
|
|
196
|
+
enumerable: true,
|
|
197
|
+
configurable: true,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
183
200
|
return ctx;
|
|
184
201
|
},
|
|
185
202
|
addConfigObject: (obj) => {
|
|
@@ -235,7 +252,7 @@ class BaseFramework {
|
|
|
235
252
|
// run simulator context setup
|
|
236
253
|
await this.mockService.runSimulatorContextSetup(ctx, this.app);
|
|
237
254
|
this.mockService.applyContextMocks(this.app, ctx);
|
|
238
|
-
let returnResult
|
|
255
|
+
let returnResult;
|
|
239
256
|
try {
|
|
240
257
|
const result = await next();
|
|
241
258
|
returnResult = await this.filterManager.runResultFilter(result, ctx);
|
|
@@ -125,7 +125,6 @@ class AsyncLocalStorageContextManager {
|
|
|
125
125
|
* It isn't possible to tell Typescript that contextWrapper is the same as T
|
|
126
126
|
* so we forced to cast as any here.
|
|
127
127
|
*/
|
|
128
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
129
128
|
return contextWrapper;
|
|
130
129
|
}
|
|
131
130
|
return target;
|
|
@@ -4,7 +4,7 @@ import { MidwayPriorityManager } from './priorityManager';
|
|
|
4
4
|
export declare abstract class DataSourceManager<T, ConnectionOpts extends BaseDataSourceManagerConfigOption<Record<string, any>, ENTITY_CONFIG_KEY> = BaseDataSourceManagerConfigOption<Record<string, any>, 'entities'>, ENTITY_CONFIG_KEY extends string = 'entities'> implements IDataSourceManager<T, ConnectionOpts> {
|
|
5
5
|
protected dataSource: Map<string, T>;
|
|
6
6
|
protected options: DataSourceManagerConfigOption<ConnectionOpts, ENTITY_CONFIG_KEY>;
|
|
7
|
-
protected modelMapping: WeakMap<
|
|
7
|
+
protected modelMapping: WeakMap<WeakKey, any>;
|
|
8
8
|
private innerDefaultDataSourceName;
|
|
9
9
|
protected dataSourcePriority: Record<string, string>;
|
|
10
10
|
private creatingDataSources;
|
|
@@ -82,6 +82,7 @@ class CommonJSFileDetector extends AbstractFileDetector {
|
|
|
82
82
|
async loadAsync(container, namespace) {
|
|
83
83
|
this.options = this.options || {};
|
|
84
84
|
const loadDirs = [].concat(this.options.loadDir ?? container.get('baseDir'));
|
|
85
|
+
const importQuery = `${Date.now()}_${Math.random()}`;
|
|
85
86
|
for (const dir of loadDirs) {
|
|
86
87
|
const fileResults = (0, glob_1.run)(DEFAULT_GLOB_PATTERN.concat(this.options.pattern || []), {
|
|
87
88
|
cwd: dir,
|
|
@@ -105,6 +106,7 @@ class CommonJSFileDetector extends AbstractFileDetector {
|
|
|
105
106
|
for (const file of fileResults) {
|
|
106
107
|
const exports = await (0, util_1.loadModule)(file, {
|
|
107
108
|
loadMode: 'esm',
|
|
109
|
+
importQuery,
|
|
108
110
|
});
|
|
109
111
|
// add module to set
|
|
110
112
|
container.bindClass(exports, {
|
|
@@ -128,7 +128,9 @@ class WebControllerGenerator {
|
|
|
128
128
|
// eslint-disable-next-line prefer-spread
|
|
129
129
|
newRouter[routeInfo.requestMethod.toLowerCase()].apply(newRouter, routerArgs);
|
|
130
130
|
}
|
|
131
|
-
|
|
131
|
+
if (routerHandler) {
|
|
132
|
+
routerHandler(newRouter);
|
|
133
|
+
}
|
|
132
134
|
}
|
|
133
135
|
}
|
|
134
136
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
declare const _default: (
|
|
1
|
+
import type { MidwayCoreDefaultConfig } from '../interface';
|
|
2
|
+
declare const _default: () => MidwayCoreDefaultConfig;
|
|
3
3
|
export default _default;
|
|
4
4
|
//# sourceMappingURL=config.default.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const util_1 = require("../util/");
|
|
4
|
-
exports.default = (
|
|
4
|
+
exports.default = () => {
|
|
5
5
|
const isDevelopment = (0, util_1.isDevelopmentEnvironment)((0, util_1.getCurrentEnvironment)());
|
|
6
6
|
return {
|
|
7
7
|
core: {
|
|
@@ -13,6 +13,11 @@ exports.default = (appInfo) => {
|
|
|
13
13
|
asyncContextManager: {
|
|
14
14
|
enable: true,
|
|
15
15
|
},
|
|
16
|
+
tracing: {
|
|
17
|
+
enable: true,
|
|
18
|
+
onError: 'ignore',
|
|
19
|
+
logOnError: false,
|
|
20
|
+
},
|
|
16
21
|
midwayLogger: {
|
|
17
22
|
default: {
|
|
18
23
|
level: 'info',
|
|
@@ -165,7 +165,7 @@ class ComponentConfigurationLoader {
|
|
|
165
165
|
if (objs) {
|
|
166
166
|
const keys = Object.keys(objs);
|
|
167
167
|
for (const key of keys) {
|
|
168
|
-
if (typeof objs[key] !== undefined) {
|
|
168
|
+
if (typeof objs[key] !== 'undefined') {
|
|
169
169
|
this.container.registerObject(key, objs[key]);
|
|
170
170
|
}
|
|
171
171
|
}
|
|
@@ -13,6 +13,7 @@ const events_1 = require("events");
|
|
|
13
13
|
const types_1 = require("../util/types");
|
|
14
14
|
const util_1 = require("../util");
|
|
15
15
|
const metadataManager_1 = require("../decorator/metadataManager");
|
|
16
|
+
const constants_2 = require("../functional/constants");
|
|
16
17
|
const debug = util.debuglog('midway:debug');
|
|
17
18
|
const debugBind = util.debuglog('midway:bind');
|
|
18
19
|
const debugSpaceLength = 9;
|
|
@@ -68,6 +69,12 @@ class MidwayContainer {
|
|
|
68
69
|
if (types_1.Types.isClass(module) || types_1.Types.isFunction(module)) {
|
|
69
70
|
this.bindModule(module, options);
|
|
70
71
|
}
|
|
72
|
+
else if (module && typeof module === 'object') {
|
|
73
|
+
const functionalApiController = metadataManager_1.MetadataManager.getOwnMetadata(constants_2.FUNCTIONAL_API_CONTROLLER_CLASS_KEY, module) || module[constants_2.FUNCTIONAL_API_CONTROLLER_CLASS_KEY];
|
|
74
|
+
if (types_1.Types.isClass(functionalApiController)) {
|
|
75
|
+
this.bindModule(functionalApiController, options);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
71
78
|
}
|
|
72
79
|
}
|
|
73
80
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal metadata key for trace method decorator.
|
|
3
|
+
*/
|
|
4
|
+
export declare const TRACE_KEY = "decorator:open_telemetry_key";
|
|
5
|
+
/**
|
|
6
|
+
* Mark a method to create an OpenTelemetry span for its invocation.
|
|
7
|
+
*/
|
|
8
|
+
export declare function Trace(spanName: string): MethodDecorator;
|
|
9
|
+
//# sourceMappingURL=tracer.d.ts.map
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TRACE_KEY = void 0;
|
|
4
|
+
exports.Trace = Trace;
|
|
5
|
+
const decoratorManager_1 = require("../decoratorManager");
|
|
6
|
+
/**
|
|
7
|
+
* Internal metadata key for trace method decorator.
|
|
8
|
+
*/
|
|
9
|
+
exports.TRACE_KEY = 'decorator:open_telemetry_key';
|
|
10
|
+
/**
|
|
11
|
+
* Mark a method to create an OpenTelemetry span for its invocation.
|
|
12
|
+
*/
|
|
13
|
+
function Trace(spanName) {
|
|
14
|
+
return decoratorManager_1.DecoratorManager.createCustomMethodDecorator(exports.TRACE_KEY, {
|
|
15
|
+
spanName,
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=tracer.js.map
|
|
@@ -49,6 +49,7 @@ export declare const LOGGER_KEY = "logger";
|
|
|
49
49
|
export declare const APPLICATION_KEY = "common:application";
|
|
50
50
|
export declare const MAIN_APPLICATION_KEY = "common:main_application";
|
|
51
51
|
export declare const APPLICATION_CONTEXT_KEY = "common:application_context";
|
|
52
|
+
export declare const FUNCTIONAL_API_CONTROLLER_KEY = "functional:api_controller";
|
|
52
53
|
export declare const CLASS_KEY_CONSTRUCTOR = "midway:class_key_constructor";
|
|
53
54
|
export declare const MAIN_MODULE_KEY = "__main__";
|
|
54
55
|
//# sourceMappingURL=constant.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.MAIN_APPLICATION_KEY = exports.APPLICATION_KEY = exports.LOGGER_KEY = exports.PLUGIN_KEY = exports.CONFIG_KEY = exports.MS_HSF_METHOD_KEY = exports.MS_DUBBO_METHOD_KEY = exports.MS_GRPC_METHOD_KEY = exports.MS_PROVIDER_KEY = exports.MS_PRODUCER_KEY = exports.MS_CONSUMER_KEY = exports.WS_EVENT_KEY = exports.WS_CONTROLLER_KEY = exports.MODULE_TASK_QUEUE_OPTIONS = exports.MODULE_TASK_QUEUE_KEY = exports.MODULE_TASK_TASK_LOCAL_OPTIONS = exports.MODULE_TASK_TASK_LOCAL_KEY = exports.MODULE_TASK_METADATA = exports.MODULE_TASK_KEY = exports.WEB_RESPONSE_RENDER = exports.WEB_RESPONSE_CONTENT_TYPE = exports.WEB_RESPONSE_HEADER = exports.WEB_RESPONSE_REDIRECT = exports.WEB_RESPONSE_HTTP_CODE = exports.WEB_RESPONSE_KEY = exports.WEB_ROUTER_PARAM_KEY = exports.WEB_ROUTER_KEY = exports.CONTROLLER_KEY = exports.SERVERLESS_FUNC_KEY = exports.FUNC_KEY = exports.CUSTOM_PARAM_INJECT_KEY = exports.CUSTOM_METHOD_INJECT_KEY = exports.CUSTOM_PROPERTY_INJECT_KEY = exports.CONSTRUCTOR_INJECT_KEY = exports.PROPERTY_INJECT_KEY = exports.SCOPE_KEY = exports.PROVIDE_KEY = exports.OBJECT_DEFINITION_KEY = exports.PRE_START_MODULE_KEY = exports.FACTORY_SERVICE_CLIENT_KEY = exports.MOCK_KEY = exports.GUARD_KEY = exports.MATCH_KEY = exports.CATCH_KEY = exports.ASPECT_KEY = exports.FRAMEWORK_KEY = exports.CONFIGURATION_OBJECT_KEY = exports.CONFIGURATION_KEY = exports.SCHEDULE_KEY = exports.ALL_VALUE_KEY = void 0;
|
|
4
|
-
exports.MAIN_MODULE_KEY = exports.CLASS_KEY_CONSTRUCTOR = exports.APPLICATION_CONTEXT_KEY = void 0;
|
|
4
|
+
exports.MAIN_MODULE_KEY = exports.CLASS_KEY_CONSTRUCTOR = exports.FUNCTIONAL_API_CONTROLLER_KEY = exports.APPLICATION_CONTEXT_KEY = void 0;
|
|
5
5
|
// got all value with no property name
|
|
6
6
|
exports.ALL_VALUE_KEY = 'common:all_value_key';
|
|
7
7
|
// common
|
|
@@ -69,6 +69,7 @@ exports.LOGGER_KEY = 'logger';
|
|
|
69
69
|
exports.APPLICATION_KEY = 'common:application';
|
|
70
70
|
exports.MAIN_APPLICATION_KEY = 'common:main_application';
|
|
71
71
|
exports.APPLICATION_CONTEXT_KEY = 'common:application_context';
|
|
72
|
+
exports.FUNCTIONAL_API_CONTROLLER_KEY = 'functional:api_controller';
|
|
72
73
|
////////////////////////////////////////// inject keys
|
|
73
74
|
// constructor key
|
|
74
75
|
exports.CLASS_KEY_CONSTRUCTOR = 'midway:class_key_constructor';
|
|
@@ -11,6 +11,7 @@ export * from './common/middleware';
|
|
|
11
11
|
export * from './common/guard';
|
|
12
12
|
export * from './common/pipe';
|
|
13
13
|
export * from './common/mock';
|
|
14
|
+
export * from './common/tracer';
|
|
14
15
|
export * from './faas/serverlessTrigger';
|
|
15
16
|
export * from './web/controller';
|
|
16
17
|
export * from './web/paramMapping';
|
package/dist/decorator/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __exportStar(require("./common/middleware"), exports);
|
|
|
32
32
|
__exportStar(require("./common/guard"), exports);
|
|
33
33
|
__exportStar(require("./common/pipe"), exports);
|
|
34
34
|
__exportStar(require("./common/mock"), exports);
|
|
35
|
+
__exportStar(require("./common/tracer"), exports);
|
|
35
36
|
// faas
|
|
36
37
|
__exportStar(require("./faas/serverlessTrigger"), exports);
|
|
37
38
|
// web
|
|
@@ -388,7 +388,6 @@ class MetadataManager {
|
|
|
388
388
|
}
|
|
389
389
|
static validCacheConstruct(target) {
|
|
390
390
|
const metadata = this.getOrCreateMetaObject(target);
|
|
391
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
392
391
|
if (!metadata[this.cacheSymbol]) {
|
|
393
392
|
metadata[this.cacheSymbol] = Object.create(null);
|
|
394
393
|
}
|
|
@@ -422,7 +421,6 @@ class MetadataManager {
|
|
|
422
421
|
return ret === ObjectType.Instance ? target.constructor : target;
|
|
423
422
|
}
|
|
424
423
|
static ensureTargetType(target, type) {
|
|
425
|
-
// eslint-disable-next-line no-prototype-builtins
|
|
426
424
|
const ret = this.getOwnProperty(target, this.isClassSymbol);
|
|
427
425
|
if (!ret) {
|
|
428
426
|
this.setOwnProperty(target, this.isClassSymbol, type);
|
|
@@ -34,6 +34,10 @@ export interface RouterOption {
|
|
|
34
34
|
* ignore global prefix
|
|
35
35
|
*/
|
|
36
36
|
ignoreGlobalPrefix?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* internal flag for whether ignoreGlobalPrefix is explicitly configured on route
|
|
39
|
+
*/
|
|
40
|
+
__ignoreGlobalPrefixConfigured?: boolean;
|
|
37
41
|
}
|
|
38
42
|
export declare const RequestMethod: {
|
|
39
43
|
GET: string;
|
|
@@ -28,7 +28,9 @@ const RequestMapping = (metadata = defaultMetadata) => {
|
|
|
28
28
|
const routerName = metadata.routerName;
|
|
29
29
|
const middleware = metadata.middleware;
|
|
30
30
|
return (target, key, descriptor) => {
|
|
31
|
-
|
|
31
|
+
const hasIgnoreGlobalPrefix = Object.prototype.hasOwnProperty.call(metadata, 'ignoreGlobalPrefix') &&
|
|
32
|
+
metadata?.ignoreGlobalPrefix !== undefined;
|
|
33
|
+
const routerMeta = {
|
|
32
34
|
path,
|
|
33
35
|
requestMethod,
|
|
34
36
|
routerName,
|
|
@@ -36,8 +38,17 @@ const RequestMapping = (metadata = defaultMetadata) => {
|
|
|
36
38
|
middleware,
|
|
37
39
|
summary: metadata?.summary || '',
|
|
38
40
|
description: metadata?.description || '',
|
|
39
|
-
ignoreGlobalPrefix:
|
|
40
|
-
|
|
41
|
+
ignoreGlobalPrefix: hasIgnoreGlobalPrefix
|
|
42
|
+
? metadata?.ignoreGlobalPrefix
|
|
43
|
+
: false,
|
|
44
|
+
};
|
|
45
|
+
Object.defineProperty(routerMeta, '__ignoreGlobalPrefixConfigured', {
|
|
46
|
+
value: hasIgnoreGlobalPrefix,
|
|
47
|
+
enumerable: false,
|
|
48
|
+
configurable: false,
|
|
49
|
+
writable: false,
|
|
50
|
+
});
|
|
51
|
+
metadataManager_1.MetadataManager.attachMetadata(__1.WEB_ROUTER_KEY, routerMeta, target);
|
|
41
52
|
return descriptor;
|
|
42
53
|
};
|
|
43
54
|
};
|
|
@@ -45,8 +45,20 @@ export declare class MidwayConfigMissingError extends MidwayError {
|
|
|
45
45
|
export declare class MidwayInvalidConfigError extends MidwayError {
|
|
46
46
|
constructor(message?: string);
|
|
47
47
|
}
|
|
48
|
+
export interface DuplicateRouteErrorEntry {
|
|
49
|
+
source: 'functional' | 'decorator';
|
|
50
|
+
handler: string;
|
|
51
|
+
}
|
|
52
|
+
export interface DuplicateRouteErrorPayload {
|
|
53
|
+
code: 'MIDWAY_DUPLICATE_ROUTE';
|
|
54
|
+
method: string;
|
|
55
|
+
fullPath: string;
|
|
56
|
+
current: DuplicateRouteErrorEntry;
|
|
57
|
+
existing: DuplicateRouteErrorEntry;
|
|
58
|
+
}
|
|
48
59
|
export declare class MidwayDuplicateRouteError extends MidwayError {
|
|
49
|
-
|
|
60
|
+
payload?: DuplicateRouteErrorPayload;
|
|
61
|
+
constructor(routerUrl: string, existPos: string, existPosOther: string, payload?: DuplicateRouteErrorPayload);
|
|
50
62
|
}
|
|
51
63
|
export declare class MidwayUseWrongMethodError extends MidwayError {
|
|
52
64
|
constructor(wrongMethod: string, replacedMethod: string, describeKey?: string);
|
package/dist/error/framework.js
CHANGED
|
@@ -73,8 +73,10 @@ class MidwayInvalidConfigError extends base_1.MidwayError {
|
|
|
73
73
|
}
|
|
74
74
|
exports.MidwayInvalidConfigError = MidwayInvalidConfigError;
|
|
75
75
|
class MidwayDuplicateRouteError extends base_1.MidwayError {
|
|
76
|
-
|
|
76
|
+
payload;
|
|
77
|
+
constructor(routerUrl, existPos, existPosOther, payload) {
|
|
77
78
|
super(`Duplicate router "${routerUrl}" at "${existPos}" and "${existPosOther}"`, exports.FrameworkErrorEnum.DUPLICATE_ROUTER);
|
|
79
|
+
this.payload = payload;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
exports.MidwayDuplicateRouteError = MidwayDuplicateRouteError;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { RouteManifestItem } from '../service/webRouterService';
|
|
2
|
+
export type RouteManifestAdapter<TOutput = unknown, TOptions = Record<string, unknown>> = (manifest: RouteManifestItem[], options?: TOptions) => TOutput;
|
|
3
|
+
export declare function adaptRouteManifest<TOutput, TOptions = Record<string, unknown>>(manifest: RouteManifestItem[], adapter: RouteManifestAdapter<TOutput, TOptions>, options?: TOptions): TOutput;
|
|
4
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.adaptRouteManifest = adaptRouteManifest;
|
|
4
|
+
function adaptRouteManifest(manifest, adapter, options) {
|
|
5
|
+
return adapter(manifest, options);
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=adapter.js.map
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { NextFunction } from '../interface';
|
|
2
|
+
export interface FunctionalRouteInput {
|
|
3
|
+
params?: unknown;
|
|
4
|
+
query?: unknown;
|
|
5
|
+
body?: unknown;
|
|
6
|
+
headers?: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface FunctionalRouteHandlerArgs {
|
|
9
|
+
input: FunctionalRouteInput;
|
|
10
|
+
ctx: any;
|
|
11
|
+
next?: NextFunction;
|
|
12
|
+
}
|
|
13
|
+
export interface FunctionalRouteDefinition {
|
|
14
|
+
method: string;
|
|
15
|
+
path: string | RegExp;
|
|
16
|
+
options: FunctionalRouteOptions;
|
|
17
|
+
handle: (args: FunctionalRouteHandlerArgs) => Promise<unknown> | unknown;
|
|
18
|
+
}
|
|
19
|
+
export interface FunctionalRouteOptions {
|
|
20
|
+
routerName?: string;
|
|
21
|
+
middleware?: any[];
|
|
22
|
+
summary?: string;
|
|
23
|
+
description?: string;
|
|
24
|
+
ignoreGlobalPrefix?: boolean;
|
|
25
|
+
input?: FunctionalRouteInput;
|
|
26
|
+
output?: unknown;
|
|
27
|
+
}
|
|
28
|
+
export type FunctionalControllerOptions = {
|
|
29
|
+
sensitive?: boolean;
|
|
30
|
+
middleware?: any[];
|
|
31
|
+
alias?: string[];
|
|
32
|
+
description?: string;
|
|
33
|
+
tagName?: string;
|
|
34
|
+
ignoreGlobalPrefix?: boolean;
|
|
35
|
+
version?: string | string[];
|
|
36
|
+
versionType?: 'URI' | 'HEADER' | 'MEDIA_TYPE' | 'CUSTOM';
|
|
37
|
+
versionPrefix?: string;
|
|
38
|
+
};
|
|
39
|
+
export interface FunctionalApiModuleMeta {
|
|
40
|
+
prefix: string;
|
|
41
|
+
ignoreGlobalPrefix?: boolean;
|
|
42
|
+
version?: string | string[];
|
|
43
|
+
versionType?: 'URI' | 'HEADER' | 'MEDIA_TYPE' | 'CUSTOM';
|
|
44
|
+
versionPrefix?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface RouteBuilder {
|
|
47
|
+
input(schema: FunctionalRouteOptions['input']): RouteBuilder;
|
|
48
|
+
output(schema: FunctionalRouteOptions['output']): RouteBuilder;
|
|
49
|
+
middleware(mw: any[]): RouteBuilder;
|
|
50
|
+
meta(options: Omit<FunctionalRouteOptions, 'input' | 'output'>): RouteBuilder;
|
|
51
|
+
handle(fn: FunctionalRouteDefinition['handle']): FunctionalRouteDefinition;
|
|
52
|
+
}
|
|
53
|
+
interface RouteBuilderInternal extends RouteBuilder {
|
|
54
|
+
__isRouteBuilder: true;
|
|
55
|
+
__build: () => FunctionalRouteDefinition;
|
|
56
|
+
}
|
|
57
|
+
export declare function defineApi(prefix: string, factory: (api: {
|
|
58
|
+
get(path?: string | RegExp): RouteBuilder;
|
|
59
|
+
post(path?: string | RegExp): RouteBuilder;
|
|
60
|
+
put(path?: string | RegExp): RouteBuilder;
|
|
61
|
+
delete(path?: string | RegExp): RouteBuilder;
|
|
62
|
+
patch(path?: string | RegExp): RouteBuilder;
|
|
63
|
+
options(path?: string | RegExp): RouteBuilder;
|
|
64
|
+
head(path?: string | RegExp): RouteBuilder;
|
|
65
|
+
all(path?: string | RegExp): RouteBuilder;
|
|
66
|
+
}) => Record<string, FunctionalRouteDefinition | RouteBuilderInternal>, controllerOptions?: FunctionalControllerOptions): Record<string, FunctionalRouteDefinition>;
|
|
67
|
+
export {};
|
|
68
|
+
//# sourceMappingURL=api.d.ts.map
|