@miqro/core 3.0.3 → 3.0.5
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/build/cjs/api-router.js +2 -3
- package/build/cjs/api-router.js.map +1 -1
- package/build/cjs/common/api-router-types.d.ts +8 -5
- package/build/cjs/common/api-router-types.js +9 -1
- package/build/cjs/common/api-router-types.js.map +1 -1
- package/build/cjs/common/api-router-utils.d.ts +2 -4
- package/build/cjs/common/api-router-utils.js +65 -59
- package/build/cjs/common/api-router-utils.js.map +1 -1
- package/build/cjs/common/index.d.ts +1 -1
- package/build/cjs/common/index.js +1 -2
- package/build/cjs/common/index.js.map +1 -1
- package/build/cjs/common/logger/constants.d.ts +1 -0
- package/build/cjs/common/logger/constants.js +1 -0
- package/build/cjs/common/logger/constants.js.map +1 -1
- package/build/cjs/common/logger/interfaces.d.ts +1 -1
- package/build/cjs/common/logger/logger.js +1 -1
- package/build/cjs/common/logger/logger.js.map +1 -1
- package/build/cjs/common/logger/transport/console.js +3 -1
- package/build/cjs/common/logger/transport/console.js.map +1 -1
- package/build/cjs/common/router-default-logger-factory.d.ts +1 -0
- package/build/cjs/common/router-default-logger-factory.js +7 -1
- package/build/cjs/common/router-default-logger-factory.js.map +1 -1
- package/build/cjs/common/router-handler.d.ts +2 -1
- package/build/cjs/common/router-handler.js +41 -27
- package/build/cjs/common/router-handler.js.map +1 -1
- package/build/cjs/router.d.ts +9 -6
- package/build/cjs/router.js +21 -0
- package/build/cjs/router.js.map +1 -1
- package/build/esm/api-router.js +2 -3
- package/build/esm/api-router.js.map +1 -1
- package/build/esm/common/api-router-types.d.ts +8 -5
- package/build/esm/common/api-router-types.js +8 -0
- package/build/esm/common/api-router-types.js.map +1 -1
- package/build/esm/common/api-router-utils.d.ts +2 -4
- package/build/esm/common/api-router-utils.js +63 -57
- package/build/esm/common/api-router-utils.js.map +1 -1
- package/build/esm/common/index.d.ts +1 -1
- package/build/esm/common/index.js +1 -1
- package/build/esm/common/index.js.map +1 -1
- package/build/esm/common/logger/constants.d.ts +1 -0
- package/build/esm/common/logger/constants.js +1 -0
- package/build/esm/common/logger/constants.js.map +1 -1
- package/build/esm/common/logger/interfaces.d.ts +1 -1
- package/build/esm/common/logger/logger.js +1 -1
- package/build/esm/common/logger/logger.js.map +1 -1
- package/build/esm/common/logger/transport/console.js +3 -1
- package/build/esm/common/logger/transport/console.js.map +1 -1
- package/build/esm/common/router-default-logger-factory.d.ts +1 -0
- package/build/esm/common/router-default-logger-factory.js +5 -0
- package/build/esm/common/router-default-logger-factory.js.map +1 -1
- package/build/esm/common/router-handler.d.ts +2 -1
- package/build/esm/common/router-handler.js +41 -27
- package/build/esm/common/router-handler.js.map +1 -1
- package/build/esm/router.d.ts +9 -6
- package/build/esm/router.js +21 -0
- package/build/esm/router.js.map +1 -1
- package/package.json +4 -4
- package/src/api-router.ts +2 -3
- package/src/common/api-router-types.ts +15 -5
- package/src/common/api-router-utils.ts +67 -60
- package/src/common/index.ts +1 -1
- package/src/common/logger/constants.ts +1 -0
- package/src/common/logger/interfaces.ts +1 -1
- package/src/common/logger/logger.ts +1 -1
- package/src/common/logger/transport/console.ts +6 -4
- package/src/common/router-default-logger-factory.ts +6 -0
- package/src/common/router-handler.ts +39 -27
- package/src/router.ts +33 -6
- package/test.out.txt +3535 -0
- package/build/cjs/common/feature-router-types.d.ts +0 -12
- package/build/cjs/common/feature-router-types.js +0 -5
- package/build/cjs/common/feature-router-types.js.map +0 -1
- package/build/cjs/feature-router.d.ts +0 -4
- package/build/cjs/feature-router.js +0 -90
- package/build/cjs/feature-router.js.map +0 -1
- package/build/esm/common/feature-router-types.d.ts +0 -12
- package/build/esm/common/feature-router-types.js +0 -2
- package/build/esm/common/feature-router-types.js.map +0 -1
- package/build/esm/feature-router.d.ts +0 -4
- package/build/esm/feature-router.js +0 -86
- package/build/esm/feature-router.js.map +0 -1
- package/src/api-router.unit.test.js +0 -280
- package/src/common/feature-router-types.ts +0 -13
- package/src/feature-router.ts +0 -82
package/build/cjs/api-router.js
CHANGED
|
@@ -5,7 +5,6 @@ const fs_1 = require("fs");
|
|
|
5
5
|
const path_1 = require("path");
|
|
6
6
|
const api_router_utils_1 = require("./common/api-router-utils");
|
|
7
7
|
const parser_1 = require("@miqro/parser");
|
|
8
|
-
const feature_router_1 = require("./feature-router");
|
|
9
8
|
const api_router_types_1 = require("./common/api-router-types");
|
|
10
9
|
/**
|
|
11
10
|
* # APIRouter
|
|
@@ -46,8 +45,8 @@ async function APIRouter(options, logger) {
|
|
|
46
45
|
throw new Error(`${dirname} not a directory!`);
|
|
47
46
|
}
|
|
48
47
|
const apiName = options.apiName !== undefined ? options.apiName : (0, path_1.basename)(dirname);
|
|
49
|
-
const apiPath = options.path !== undefined ? options.path :
|
|
50
|
-
return
|
|
48
|
+
const apiPath = options.path !== undefined ? options.path : "";
|
|
49
|
+
return await (0, api_router_utils_1.traverseAPIRouteDir)(apiName.toUpperCase(), dirname, apiPath, undefined, logger);
|
|
51
50
|
}
|
|
52
51
|
exports.APIRouter = APIRouter;
|
|
53
52
|
//# sourceMappingURL=api-router.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-router.js","sourceRoot":"","sources":["../../src/api-router.ts"],"names":[],"mappings":";;;AAAA,2BAA2C;AAC3C,+BAAgC;AAChC,gEAAgE;AAEhE,0CAAqC;
|
|
1
|
+
{"version":3,"file":"api-router.js","sourceRoot":"","sources":["../../src/api-router.ts"],"names":[],"mappings":";;;AAAA,2BAA2C;AAC3C,+BAAgC;AAChC,gEAAgE;AAEhE,0CAAqC;AAErC,gEAAoF;AAEpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACI,KAAK,UAAU,SAAS,CAAC,OAAyB,EAAE,MAAe;IACxE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAA,cAAK,EAAC,OAAO,EAAE,wCAAqB,EAAE,UAAU,EAAE,SAAS,CAAqB,CAAC;IACrG,IAAI,OAAO,OAAO,KAAK,QAAQ,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;KACrD;IACD,IAAI,CAAC,IAAA,eAAU,EAAC,OAAO,CAAC,IAAI,CAAC,IAAA,cAAS,EAAC,OAAO,CAAC,CAAC,WAAW,EAAE,EAAE;QAC7D,MAAM,IAAI,KAAK,CAAC,GAAG,OAAO,mBAAmB,CAAC,CAAC;KAChD;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAA,eAAQ,EAAC,OAAO,CAAC,CAAC;IACpF,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IAC/D,OAAO,MAAM,IAAA,sCAAmB,EAAC,OAAO,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAC/F,CAAC;AAXD,8BAWC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ParseOptionMap } from "@miqro/parser";
|
|
2
|
-
import { Method } from "./context";
|
|
3
|
-
import {
|
|
2
|
+
import { Handler, Method } from "./context";
|
|
3
|
+
import { MinimalRouter, RouterHandlerOptions } from "./router-types";
|
|
4
4
|
/**
|
|
5
5
|
* # APIRoute
|
|
6
6
|
*
|
|
@@ -13,9 +13,11 @@ import { HandlerWithOptions } from "./router-types";
|
|
|
13
13
|
*export default route;
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
export interface APIRoute extends
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
export interface APIRoute extends RouterHandlerOptions {
|
|
17
|
+
postFolder?: boolean;
|
|
18
|
+
method?: Method | "use" | "USE";
|
|
19
|
+
path?: string;
|
|
20
|
+
handler: Handler | Array<Handler> | MinimalRouter;
|
|
19
21
|
}
|
|
20
22
|
export interface APIRouterOptions {
|
|
21
23
|
dirname: string;
|
|
@@ -23,3 +25,4 @@ export interface APIRouterOptions {
|
|
|
23
25
|
path?: string;
|
|
24
26
|
}
|
|
25
27
|
export declare const APIRouterParseOptions: ParseOptionMap;
|
|
28
|
+
export declare const APIRouteValidator: ParseOptionMap;
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.APIRouterParseOptions = void 0;
|
|
3
|
+
exports.APIRouteValidator = exports.APIRouterParseOptions = void 0;
|
|
4
|
+
const router_types_1 = require("./router-types");
|
|
4
5
|
exports.APIRouterParseOptions = {
|
|
5
6
|
dirname: "string",
|
|
6
7
|
apiName: "string?",
|
|
7
8
|
path: "string?"
|
|
8
9
|
};
|
|
10
|
+
exports.APIRouteValidator = {
|
|
11
|
+
...router_types_1.routerHandlerParseOptions,
|
|
12
|
+
postFolder: "boolean?",
|
|
13
|
+
method: "string?",
|
|
14
|
+
path: "string?",
|
|
15
|
+
handler: "function[]!|MinimalRouter",
|
|
16
|
+
};
|
|
9
17
|
//# sourceMappingURL=api-router-types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-router-types.js","sourceRoot":"","sources":["../../../src/common/api-router-types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"api-router-types.js","sourceRoot":"","sources":["../../../src/common/api-router-types.ts"],"names":[],"mappings":";;;AAEA,iDAAgG;AA2BnF,QAAA,qBAAqB,GAAmB;IACnD,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,SAAS;CAChB,CAAC;AAEW,QAAA,iBAAiB,GAAmB;IAC/C,GAAG,wCAAyB;IAC5B,UAAU,EAAE,UAAU;IACtB,MAAM,EAAE,SAAS;IACjB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,2BAA2B;CACrC,CAAC"}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import { Logger } from "./logger";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
export declare const APIRouteValidator: ParseOptionMap;
|
|
5
|
-
export declare function traverseAPIRouteDir(featureName: string, dirname: string, basePath?: string, features?: FeatureRouterOptions, logger?: Logger): Promise<FeatureRouterOptions>;
|
|
2
|
+
import { Router } from "../router";
|
|
3
|
+
export declare function traverseAPIRouteDir(featureName: string, dirname: string, basePath?: string, router?: Router, logger?: Logger): Promise<Router>;
|
|
@@ -1,27 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.traverseAPIRouteDir =
|
|
3
|
+
exports.traverseAPIRouteDir = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const path_1 = require("path");
|
|
6
|
-
const
|
|
6
|
+
const api_router_types_js_1 = require("./api-router-types.js");
|
|
7
7
|
const parser_1 = require("@miqro/parser");
|
|
8
8
|
const url_utils_1 = require("./url-utils");
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
path: "string?|string[]?"
|
|
13
|
-
};
|
|
14
|
-
async function traverseAPIRouteDir(featureName, dirname, basePath = "/", features = {}, logger) {
|
|
9
|
+
const router_1 = require("../router");
|
|
10
|
+
const router_types_1 = require("./router-types");
|
|
11
|
+
async function traverseAPIRouteDir(featureName, dirname, basePath = "/", router = new router_1.Router(), logger) {
|
|
15
12
|
if (logger) {
|
|
16
13
|
logger.trace("loading routes from [%s]", dirname);
|
|
17
14
|
}
|
|
18
15
|
const files = (0, fs_1.readdirSync)(dirname);
|
|
19
16
|
const dirs = files.filter(f => (0, fs_1.lstatSync)((0, path_1.join)(dirname, f)).isDirectory());
|
|
20
17
|
const methods = files.filter(f => !(0, fs_1.lstatSync)((0, path_1.join)(dirname, f)).isDirectory());
|
|
21
|
-
|
|
22
|
-
const { name } = (0, path_1.parse)(f);
|
|
23
|
-
features = await traverseAPIRouteDir(`${featureName}_${name}`.toUpperCase(), (0, path_1.join)(dirname, f), `${basePath}/${name}`, features, logger);
|
|
24
|
-
}
|
|
18
|
+
const postFolder = [];
|
|
25
19
|
for (const f of methods) {
|
|
26
20
|
const { name, ext } = (0, path_1.parse)(f);
|
|
27
21
|
if (name !== "index" && ((ext === ".ts" || ext === ".js") && name.slice(-2) !== ".d")) {
|
|
@@ -37,72 +31,84 @@ async function traverseAPIRouteDir(featureName, dirname, basePath = "/", feature
|
|
|
37
31
|
}
|
|
38
32
|
//const ___filePath = filePath + ext;
|
|
39
33
|
const ___filePath = filePath;
|
|
40
|
-
let routeMethods = [name];
|
|
34
|
+
//let routeMethods: Method[] = [name] as Method[];
|
|
35
|
+
let routeMethod = name;
|
|
41
36
|
if (typeof route === "function") {
|
|
42
37
|
route = {
|
|
43
38
|
handler: route
|
|
44
39
|
};
|
|
45
40
|
}
|
|
46
41
|
else {
|
|
47
|
-
if (typeof route.method !== "undefined" && (
|
|
48
|
-
throw new Error(`${
|
|
42
|
+
if (typeof route.method !== "undefined" && ( /*!(route.method instanceof Array) &&*/(typeof route.method !== "string"))) {
|
|
43
|
+
//throw new Error(`${resolve(dirname, name)} doesnt export method as a string or string array`);
|
|
44
|
+
throw new Error(`${(0, path_1.resolve)(dirname, name)} doesnt export method as a string`);
|
|
49
45
|
}
|
|
50
46
|
else if (typeof route.method !== "undefined") {
|
|
51
|
-
|
|
47
|
+
routeMethod = route.method; //route.method instanceof Array ? route.method : [route.method];
|
|
52
48
|
}
|
|
53
|
-
if (typeof route.path !== "string" && typeof route.path !== "undefined" && !(route.path instanceof Array)) {
|
|
54
|
-
throw new Error(`${
|
|
49
|
+
if (typeof route.path !== "string" && typeof route.path !== "undefined" /* && !(route.path instanceof Array)*/) {
|
|
50
|
+
//throw new Error(`${resolve(dirname, name)} doesnt export path as a string or a string array`);
|
|
51
|
+
throw new Error(`${(0, path_1.resolve)(dirname, name)} doesnt export path as a string`);
|
|
55
52
|
}
|
|
56
|
-
if ((!(route.handler instanceof Array) && typeof route.handler !== "function") || typeof route.handler === "undefined") {
|
|
53
|
+
if ((!(route.handler instanceof Array) && typeof route.handler !== "function" && !(0, router_types_1.isMinimalRouter)(route.handler)) || typeof route.handler === "undefined") {
|
|
57
54
|
throw new Error(`${(0, path_1.resolve)(dirname, name)} doesnt export handler as a function or an array`);
|
|
58
55
|
}
|
|
59
56
|
if (typeof route.name !== "string" && typeof route.name !== "undefined") {
|
|
60
57
|
throw new Error(`${(0, path_1.resolve)(dirname, name)} doesnt export name as a string`);
|
|
61
58
|
}
|
|
62
59
|
}
|
|
63
|
-
route = (0, parser_1.parse)(route,
|
|
64
|
-
const paths = route.path instanceof Array ? route.path : route.path === undefined ? [route.method && route.method.indexOf(name) === -1 ? `/${name}` : "/"] : [route.path];
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
60
|
+
route = (0, parser_1.parse)(route, api_router_types_js_1.APIRouteValidator, "no_extra", ___filePath);
|
|
61
|
+
//const paths = route.path instanceof Array ? route.path : route.path === undefined ? [route.method && route.method.indexOf(name as Method) === -1 ? `/${name}` : "/"] : [route.path];
|
|
62
|
+
const p = route.path === undefined ? route.method && route.method.indexOf(name) === -1 ? `/${name}` : "/" : route.path;
|
|
63
|
+
//for (let i = 0; i < paths.length; i++) {
|
|
64
|
+
//const p = paths[i];
|
|
65
|
+
if (typeof p !== "string" || !p) {
|
|
66
|
+
throw new Error(`${(0, path_1.resolve)(dirname, name)} doesnt export path as a string or a string array`);
|
|
67
|
+
}
|
|
68
|
+
const path = (0, url_utils_1.normalizePath)(`${basePath}${p && p !== "/" ? `${p}` : p}`);
|
|
69
|
+
const subName = (p.charAt(0) === "/" ? p.substring(1) : p).replace(/[^a-z0-9+]+/gi, '_');
|
|
70
|
+
const routeName = route.name ? route.name : name;
|
|
71
|
+
//const identifier = route.identifier ? route.identifier : getPathIdentifier(path, routeMethod);
|
|
72
|
+
/*let newFeatureSubPath = `${featureName}_${route.name ? route.name : name}${routeName !== subName ? `_${subName}` : ""}`.toUpperCase();
|
|
73
|
+
|
|
74
|
+
newFeatureSubPath = newFeatureSubPath.length > 1 && newFeatureSubPath.charAt(newFeatureSubPath.length - 1) === "_" ? newFeatureSubPath.substring(0, newFeatureSubPath.length - 1) : newFeatureSubPath;*/
|
|
75
|
+
/*if (features[identifier]) {
|
|
76
|
+
throw new Error(`${___filePath} feature name collides with ${(features[identifier] as any).___filePath}`)
|
|
77
|
+
}*/
|
|
78
|
+
if (route.identifier && route.identifier === "__prototype__" || route.identifier === "__proto__") {
|
|
79
|
+
throw new Error(`invalid feature name ${route.identifier}`);
|
|
80
|
+
}
|
|
81
|
+
const useCallArgs = [route.handler, path, routeMethod !== "use" && routeMethod !== "USE" ? routeMethod : undefined, {
|
|
82
|
+
identifier: route.identifier,
|
|
83
|
+
apiName: route.apiName,
|
|
84
|
+
name: route.name,
|
|
85
|
+
description: route.description,
|
|
86
|
+
parser: route.parser,
|
|
87
|
+
middleware: route.middleware,
|
|
88
|
+
session: route.session,
|
|
89
|
+
policy: route.policy,
|
|
90
|
+
request: route.request,
|
|
91
|
+
response: {
|
|
92
|
+
body: route.response && route.response.body !== undefined ? route.response.body : !(0, router_types_1.isMinimalRouter)(route.handler),
|
|
93
|
+
middleware: route.response && route.response.middleware !== undefined ? route.response.middleware : undefined
|
|
94
|
+
}
|
|
95
|
+
}];
|
|
96
|
+
if (route.postFolder) {
|
|
97
|
+
postFolder.push(useCallArgs);
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
router.use(...useCallArgs);
|
|
102
101
|
}
|
|
103
102
|
}
|
|
104
103
|
}
|
|
105
|
-
|
|
104
|
+
for (const f of dirs) {
|
|
105
|
+
const { name } = (0, path_1.parse)(f);
|
|
106
|
+
router = await traverseAPIRouteDir(`${featureName}_${name}`.toUpperCase(), (0, path_1.join)(dirname, f), `${basePath}/${name}`, router, logger);
|
|
107
|
+
}
|
|
108
|
+
for (const post of postFolder) {
|
|
109
|
+
router.use(...post);
|
|
110
|
+
}
|
|
111
|
+
return router;
|
|
106
112
|
}
|
|
107
113
|
exports.traverseAPIRouteDir = traverseAPIRouteDir;
|
|
108
114
|
;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-router-utils.js","sourceRoot":"","sources":["../../../src/common/api-router-utils.ts"],"names":[],"mappings":";;;AAAA,2BAA4C;AAC5C,+BAAyD;AAGzD
|
|
1
|
+
{"version":3,"file":"api-router-utils.js","sourceRoot":"","sources":["../../../src/common/api-router-utils.ts"],"names":[],"mappings":";;;AAAA,2BAA4C;AAC5C,+BAAyD;AAGzD,+DAAoE;AACpE,0CAAsC;AAEtC,2CAA4C;AAC5C,sCAAmC;AACnC,iDAAsF;AAI/E,KAAK,UAAU,mBAAmB,CACvC,WAAmB,EACnB,OAAe,EACf,QAAQ,GAAG,GAAG,EACd,SAAiB,IAAI,eAAM,EAAE,EAAE,MAAe;IAC9C,IAAI,MAAM,EAAE;QACV,MAAM,CAAC,KAAK,CAAC,0BAA0B,EAAE,OAAO,CAAC,CAAC;KACnD;IACD,MAAM,KAAK,GAAG,IAAA,gBAAW,EAAC,OAAO,CAAC,CAAC;IACnC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,IAAA,cAAS,EAAC,IAAA,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G,QAAQ,IAAI,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;KACrI;IACD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE;QAC7B,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAC;KACrB;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AA3GD,kDA2GC;AAAA,CAAC"}
|
|
@@ -7,5 +7,5 @@ export * from "./error";
|
|
|
7
7
|
export * from "./config";
|
|
8
8
|
export * from "./logger";
|
|
9
9
|
export { normalizePath, newURL } from "./url-utils";
|
|
10
|
-
export { traverseAPIRouteDir
|
|
10
|
+
export { traverseAPIRouteDir } from "./api-router-utils";
|
|
11
11
|
export { OldResponseHandler, ResponseHandler } from "./router-utils";
|
|
@@ -14,7 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ResponseHandler = exports.OldResponseHandler = exports.
|
|
17
|
+
exports.ResponseHandler = exports.OldResponseHandler = exports.traverseAPIRouteDir = exports.newURL = exports.normalizePath = void 0;
|
|
18
18
|
__exportStar(require("./context"), exports);
|
|
19
19
|
__exportStar(require("./router-default-logger-factory"), exports);
|
|
20
20
|
__exportStar(require("./api-router-types"), exports);
|
|
@@ -28,7 +28,6 @@ Object.defineProperty(exports, "normalizePath", { enumerable: true, get: functio
|
|
|
28
28
|
Object.defineProperty(exports, "newURL", { enumerable: true, get: function () { return url_utils_1.newURL; } });
|
|
29
29
|
var api_router_utils_1 = require("./api-router-utils");
|
|
30
30
|
Object.defineProperty(exports, "traverseAPIRouteDir", { enumerable: true, get: function () { return api_router_utils_1.traverseAPIRouteDir; } });
|
|
31
|
-
Object.defineProperty(exports, "APIRouteValidator", { enumerable: true, get: function () { return api_router_utils_1.APIRouteValidator; } });
|
|
32
31
|
var router_utils_1 = require("./router-utils");
|
|
33
32
|
Object.defineProperty(exports, "OldResponseHandler", { enumerable: true, get: function () { return router_utils_1.OldResponseHandler; } });
|
|
34
33
|
Object.defineProperty(exports, "ResponseHandler", { enumerable: true, get: function () { return router_utils_1.ResponseHandler; } });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,kEAAgD;AAChD,qDAAmC;AACnC,iDAA+B;AAC/B,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAoD;AAA3C,0GAAA,aAAa,OAAA;AAAE,mGAAA,MAAM,OAAA;AAC9B,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,4CAA0B;AAC1B,kEAAgD;AAChD,qDAAmC;AACnC,iDAA+B;AAC/B,4CAA0B;AAC1B,0CAAwB;AACxB,2CAAyB;AACzB,2CAAyB;AACzB,yCAAoD;AAA3C,0GAAA,aAAa,OAAA;AAAE,mGAAA,MAAM,OAAA;AAC9B,uDAAyD;AAAhD,uHAAA,mBAAmB,OAAA;AAC5B,+CAAqE;AAA5D,kHAAA,kBAAkB,OAAA;AAAE,+GAAA,eAAe,OAAA"}
|
|
@@ -2,6 +2,7 @@ import { LoggerFormatter, LoggerTransport } from "./interfaces.js";
|
|
|
2
2
|
export declare const DEFAULT_LOGGER_TRANSPORTS: () => LoggerTransport[];
|
|
3
3
|
export declare const DEFAULT_LOGGER_FORMATTER: LoggerFormatter;
|
|
4
4
|
export declare const LOG_LEVEL_MAP: {
|
|
5
|
+
none: number;
|
|
5
6
|
error: number;
|
|
6
7
|
warn: number;
|
|
7
8
|
info: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/common/logger/constants.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAClD,uDAAwD;AAEjD,MAAM,yBAAyB,GAA4B,GAAG,EAAE,CAAC;IACtE,IAAA,6BAAgB,GAAE;IAClB,IAAA,uBAAa,GAAE;CAChB,CAAC;AAHW,QAAA,yBAAyB,6BAGpC;AAEK,MAAM,wBAAwB,GACnC,CAAC,EAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,GAAG,GAAG;IAC7E,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;IACzC,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IAClH,GAAG,OAAO,EAAE,CAAC;AAJJ,QAAA,wBAAwB,4BAIpB;AAEJ,QAAA,aAAa,GACxB;IACE,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;CACX,CAAC;AAES,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,OAAO;CACf,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/common/logger/constants.ts"],"names":[],"mappings":";;;AACA,iDAAkD;AAClD,uDAAwD;AAEjD,MAAM,yBAAyB,GAA4B,GAAG,EAAE,CAAC;IACtE,IAAA,6BAAgB,GAAE;IAClB,IAAA,uBAAa,GAAE;CAChB,CAAC;AAHW,QAAA,yBAAyB,6BAGpC;AAEK,MAAM,wBAAwB,GACnC,CAAC,EAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAC,EAAE,EAAE,CAAC,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,IAAI,OAAO,CAAC,GAAG,GAAG;IAC7E,GAAG,UAAU,CAAC,CAAC,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE;IACzC,GAAG,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE;IAClH,GAAG,OAAO,EAAE,CAAC;AAJJ,QAAA,wBAAwB,4BAIpB;AAEJ,QAAA,aAAa,GACxB;IACE,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,MAAM,EAAE,CAAC;IACT,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,CAAC;CACX,CAAC;AAES,QAAA,YAAY,GAAG;IAC1B,KAAK,EAAE,OAAO;CACf,CAAC"}
|
|
@@ -15,7 +15,7 @@ class Logger extends EventTarget {
|
|
|
15
15
|
super();
|
|
16
16
|
this.identifier = identifier;
|
|
17
17
|
this.level = level;
|
|
18
|
-
if (
|
|
18
|
+
if (constants_js_1.LOG_LEVEL_MAP[level] === undefined) {
|
|
19
19
|
throw new Error(`Unknown level [${level}]`);
|
|
20
20
|
}
|
|
21
21
|
this.addEventListener(constants_js_1.LoggerEvents.error, (ev) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../../../src/common/logger/logger.ts"],"names":[],"mappings":";;;AAAA,+BAA4B;AAE5B,iDAAgH;AAUhH,MAAa,gBAAiB,SAAQ,KAAK;IAGzC,YAAY,KAAa,EAAE,IAA0B;QACnD,KA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AAM,EAAE,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;IAC9D,CAAC;IAED,uEAAuE;IAChE,KAAK,CAAC,OAAa,EAAE,GAAG,cAAqB;QAClD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;IAC/D,CAAC;IAED,uEAAuE;IAChE,IAAI,CAAC,OAAa,EAAE,GAAG,cAAqB;QACjD,OAAO,IAAI,CAAC,KAAK,CAAC,EAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,EAAC,CAAC,CAAC;IAC9D,CAAC;CACF;AA7FD,wBA6FC"}
|
|
@@ -19,6 +19,8 @@ function ConsoleTransport(color = true, level) {
|
|
|
19
19
|
case "debug":
|
|
20
20
|
console.log("\x1b[36m%s\x1b[0m", out);
|
|
21
21
|
break;
|
|
22
|
+
case "none":
|
|
23
|
+
break;
|
|
22
24
|
default:
|
|
23
25
|
console[level](out);
|
|
24
26
|
break;
|
|
@@ -28,7 +30,7 @@ function ConsoleTransport(color = true, level) {
|
|
|
28
30
|
if (level === "trace" || level === "debug") {
|
|
29
31
|
console.log(out);
|
|
30
32
|
}
|
|
31
|
-
else {
|
|
33
|
+
else if (level !== "none") {
|
|
32
34
|
console[level](out);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/common/logger/transport/console.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,QAAiB,IAAI,EAAE,KAAgB;IACtE,OAAO;QACL,KAAK;QACL,KAAK,EAAE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../../../../src/common/logger/transport/console.ts"],"names":[],"mappings":";;;AAEA,SAAgB,gBAAgB,CAAC,QAAiB,IAAI,EAAE,KAAgB;IACtE,OAAO;QACL,KAAK;QACL,KAAK,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAA4B,EAAiB,EAAE;YACvE,IAAI,KAAK,EAAE;gBACT,QAAQ,KAAK,EAAE;oBACb,KAAK,MAAM;wBACT,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;wBACvC,MAAM;oBACR,KAAK,OAAO;wBACV,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;wBACxC,MAAM;oBACR,KAAK,OAAO;wBACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;wBACtC,MAAM;oBACR,KAAK,OAAO;wBACV,OAAO,CAAC,GAAG,CAAC,mBAAmB,EAAE,GAAG,CAAC,CAAC;wBACtC,MAAM;oBACR,KAAK,MAAM;wBACT,MAAM;oBACR;wBACE,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;wBACpB,MAAM;iBACT;aACF;iBAAM;gBACL,IAAI,KAAK,KAAK,OAAO,IAAI,KAAK,KAAK,OAAO,EAAE;oBAC1C,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;iBAClB;qBAAM,IAAI,KAAK,KAAK,MAAM,EAAE;oBAC3B,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;iBACrB;aACF;QACH,CAAC;KACF,CAAC;AACJ,CAAC;AAjCD,4CAiCC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.defaultLoggerFactory = void 0;
|
|
3
|
+
exports.getPathIdentifier = exports.defaultLoggerFactory = void 0;
|
|
4
4
|
const url_utils_1 = require("./url-utils");
|
|
5
5
|
const logger_1 = require("./logger");
|
|
6
6
|
const defaultLoggerFactory = (uuid, req) => {
|
|
@@ -33,4 +33,10 @@ const defaultLoggerFactory = (uuid, req) => {
|
|
|
33
33
|
return logger;
|
|
34
34
|
};
|
|
35
35
|
exports.defaultLoggerFactory = defaultLoggerFactory;
|
|
36
|
+
function getPathIdentifier(path, method) {
|
|
37
|
+
const pathToEnv = path.replace(/[^a-z0-9+]+/gi, '_').toUpperCase();
|
|
38
|
+
const identifier = `${pathToEnv === "_" ? "" : pathToEnv.substring(1)}${method.toUpperCase()}`;
|
|
39
|
+
return identifier;
|
|
40
|
+
}
|
|
41
|
+
exports.getPathIdentifier = getPathIdentifier;
|
|
36
42
|
//# sourceMappingURL=router-default-logger-factory.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router-default-logger-factory.js","sourceRoot":"","sources":["../../../src/common/router-default-logger-factory.ts"],"names":[],"mappings":";;;AAEA,2CAAoD;AACpD,qCAAuE;AAEhE,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,GAAoB,EAAU,EAAE;IACjF,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,eAAe,CAAC;IACpB,IAAI,MAAM,GAAG,KAAK,CAAC;IACnB,IAAI,aAAa,GAAuB,EAAE,CAAC;IAC3C,IAAI;QACF,MAAM,GAAG,GAAG,IAAA,kBAAM,EAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAQ,CAAC;QACnD,KAAK,GAAG,GAAG,CAAC,YAAY,CAAC,QAAQ,EAAE,CAAC;QACpC,IAAI,GAAG,IAAA,yBAAa,EAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,kBAAkB;QACtD,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAY,CAAC,CAAC,CAAC,KAAK,CAAC;QACjE,aAAa,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC;KAC1C;IAAC,OAAO,CAAC,EAAE;QACV,eAAe,GAAG,CAAC,CAAC;KACrB;IACD,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,MAAM,UAAU,GAAG,GAAG,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;IAE/F,MAAM,MAAM,GAAG,IAAA,kBAAS,EAAC,UAAU,EAAE;QACnC,SAAS,EAAE,CAAC,IAAI,EAAE,EAAE;YAClB,IAAI,CAAC,OAAO,GAAG,GAAG,MAAM,IAAI,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,aAAa,CAAC,CAAC,CAAC,KAAK,aAAa,GAAG,CAAC,CAAC,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACtJ,OAAO,IAAA,iCAAwB,EAAC,IAAI,CAAC,CAAC;QACxC,CAAC;KACF,EAAE,KAAK,CAAC,CAAC;IAEV,IAAI,eAAe,EAAE;QACnB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;KAC/B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA;AA9BY,QAAA,oBAAoB,wBA8BhC"}
|
|
1
|
+
{"version":3,"file":"router-default-logger-factory.js","sourceRoot":"","sources":["../../../src/common/router-default-logger-factory.ts"],"names":[],"mappings":";;;AAEA,2CAAoD;AACpD,qCAAuE;AAEhE,MAAM,oBAAoB,GAAG,CAAC,IAAY,EAAE,GAAoB,EAAU,EAAE;IACjF,IAAI,IAAI,GAAG,EAAE,CAAC;IACd,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,eAAe,CAAC;IACpB,IAAI,MAAM,GAAG,KAA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AO,EAAE,CAAC;YACtJ,OAAO,IAAA,iCAAwB,EAAC,IAAI,CAAC,CAAC;QACxC,CAAC;KACF,EAAE,KAAK,CAAC,CAAC;IAEV,IAAI,eAAe,EAAE;QACnB,MAAM,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;KAC/B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA;AA9BY,QAAA,oBAAoB,wBA8BhC;AAED,SAAgB,iBAAiB,CAAC,IAAY,EAAE,MAAc;IAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;IACnE,MAAM,UAAU,GAAG,GAAG,SAAS,KAAK,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,WAAW,EAAE,EAAE,CAAC;IAC/F,OAAO,UAAU,CAAC;AACpB,CAAC;AAJD,8CAIC"}
|
|
@@ -3,13 +3,14 @@ import { Context, Handler, Method } from "./context";
|
|
|
3
3
|
import { MinimalRouter } from "./router-types";
|
|
4
4
|
import { HandlerWithOptions, RouterHandlerOptions, RouterJSONDoc } from "./router-types";
|
|
5
5
|
export declare class RouterHandler {
|
|
6
|
+
private readonly originalHandler;
|
|
6
7
|
private readonly path;
|
|
7
8
|
private readonly method;
|
|
8
9
|
private readonly tokens;
|
|
9
10
|
private readonly handler;
|
|
10
11
|
private readonly isRouter;
|
|
11
12
|
private readonly options?;
|
|
12
|
-
constructor(
|
|
13
|
+
constructor(originalHandler: Array<Handler> | HandlerWithOptions | Handler | MinimalRouter, path: string | undefined, method: Method | undefined, options?: RouterHandlerOptions);
|
|
13
14
|
getJSONDoc(doc?: RouterJSONDoc, prePath?: string): RouterJSONDoc;
|
|
14
15
|
invoke(ctx: Context, pathTokens: PathPart[], prePathTokens: PathPartToken[]): Promise<boolean>;
|
|
15
16
|
isMatch(method: string, requestParts: PathPart[], prePathTokens: PathPartToken[]): {
|
|
@@ -8,7 +8,8 @@ const middleware_1 = require("../middleware");
|
|
|
8
8
|
const router_types_2 = require("./router-types");
|
|
9
9
|
const _1 = require(".");
|
|
10
10
|
class RouterHandler {
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(originalHandler, path, method, options) {
|
|
12
|
+
this.originalHandler = originalHandler;
|
|
12
13
|
this.path = path;
|
|
13
14
|
this.method = method;
|
|
14
15
|
this.tokens = (0, tokenize_match_1.tokenizePath)(path);
|
|
@@ -16,28 +17,29 @@ class RouterHandler {
|
|
|
16
17
|
options = (0, parser_1.parse)(options, router_types_2.routerHandlerParseOptions, "no_extra", "options");
|
|
17
18
|
}
|
|
18
19
|
let handlers = [];
|
|
19
|
-
this.isRouter = (0, router_types_1.isMinimalRouter)(
|
|
20
|
-
if (!this.isRouter && !(
|
|
20
|
+
this.isRouter = (0, router_types_1.isMinimalRouter)(originalHandler); //handler instanceof Router;
|
|
21
|
+
if (!this.isRouter && !(originalHandler instanceof Array) && typeof originalHandler === "object") {
|
|
21
22
|
// HandlerWithOptions
|
|
22
23
|
if (options) {
|
|
23
24
|
throw new Error("bad arguments. cannot send options with HandlerWithOptions");
|
|
24
25
|
}
|
|
25
26
|
//console.dir(handler);
|
|
26
|
-
|
|
27
|
-
const realHandler =
|
|
27
|
+
this.originalHandler = (0, parser_1.parse)(originalHandler, router_types_2.handlerWithOptionsParseOptions, "no_extra", "handler");
|
|
28
|
+
const realHandler = originalHandler.handler;
|
|
28
29
|
const newOptions = {
|
|
29
|
-
...
|
|
30
|
+
...originalHandler
|
|
30
31
|
};
|
|
31
32
|
delete newOptions.handler;
|
|
32
|
-
|
|
33
|
+
this.originalHandler = realHandler;
|
|
33
34
|
this.options = newOptions;
|
|
34
35
|
}
|
|
35
36
|
else {
|
|
36
37
|
this.options = options;
|
|
37
38
|
}
|
|
38
|
-
const routeHandlers =
|
|
39
|
-
if ((!this.isRouter && routeHandlers.length !== routeHandlers.filter(h => typeof h === "function").length) || (this.isRouter && this.options)) {
|
|
40
|
-
|
|
39
|
+
const routeHandlers = this.originalHandler instanceof Array ? this.originalHandler : [this.originalHandler];
|
|
40
|
+
//if ((!this.isRouter && routeHandlers.length !== routeHandlers.filter(h => typeof h === "function").length) || (this.isRouter && this.options)) {
|
|
41
|
+
if ((!this.isRouter && routeHandlers.length !== routeHandlers.filter(h => typeof h === "function").length)) {
|
|
42
|
+
throw new Error(`bad arguments isRouter[${this.isRouter}]`);
|
|
41
43
|
}
|
|
42
44
|
if (this.options && this.options.middleware) {
|
|
43
45
|
handlers = handlers.concat(this.options.middleware);
|
|
@@ -73,31 +75,43 @@ class RouterHandler {
|
|
|
73
75
|
const nPath = this.path && this.path.length > 1 ? this.path.substring(1) : "";
|
|
74
76
|
const nMethod = this.method ? this.method : "";
|
|
75
77
|
if (this.isRouter) {
|
|
76
|
-
const router = this.
|
|
78
|
+
const router = this.originalHandler;
|
|
77
79
|
router.getJSONDoc(doc, `${prePath}${nPath}`);
|
|
78
80
|
}
|
|
79
|
-
else
|
|
81
|
+
else {
|
|
80
82
|
if (!doc[`${prePath}${nPath}`]) {
|
|
81
83
|
doc[`${prePath}${nPath}`] = Object.create(null);
|
|
82
84
|
}
|
|
83
85
|
if (doc[`${prePath}${nPath}`][nMethod]) {
|
|
84
86
|
throw new Error("cannot create doc routes override each other");
|
|
85
87
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
88
|
+
if (this.options) {
|
|
89
|
+
doc[`${prePath}${nPath}`][nMethod] = {
|
|
90
|
+
description: this.options.description,
|
|
91
|
+
name: this.options.name,
|
|
92
|
+
identifier: this.options.identifier ? this.options.identifier : `${prePath}${nPath}${this.options.name ? this.options.name : ""}${nMethod ? `_${nMethod}` : ""}`.replace(/[^a-z0-9+]+/gi, '_').split("_").map(s => s.trim()).filter(s => s).join("_").toUpperCase(),
|
|
93
|
+
policy: this.options.policy,
|
|
94
|
+
request: this.options.request ? {
|
|
95
|
+
body: this.options.request.body,
|
|
96
|
+
headers: this.options.request.headers,
|
|
97
|
+
params: this.options.request.params,
|
|
98
|
+
query: this.options.request.query,
|
|
99
|
+
} : undefined,
|
|
100
|
+
response: this.options.response ? {
|
|
101
|
+
body: this.options.response.body
|
|
102
|
+
} : undefined
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
doc[`${prePath}${nPath}`][nMethod] = {
|
|
107
|
+
description: undefined,
|
|
108
|
+
name: undefined,
|
|
109
|
+
identifier: `${prePath}${nPath}${nMethod ? `_${nMethod}` : ""}`.replace(/[^a-z0-9+]+/gi, '_').split("_").map(s => s.trim()).filter(s => s).join("_").toUpperCase(),
|
|
110
|
+
policy: undefined,
|
|
111
|
+
request: undefined,
|
|
112
|
+
response: undefined
|
|
113
|
+
};
|
|
114
|
+
}
|
|
101
115
|
}
|
|
102
116
|
return doc;
|
|
103
117
|
}
|