apitally 0.13.0 → 0.14.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.
- package/README.md +6 -10
- package/dist/adonisjs/provider.cjs.map +1 -1
- package/dist/adonisjs/provider.js.map +1 -1
- package/dist/common/client.cjs.map +1 -1
- package/dist/common/client.js.map +1 -1
- package/dist/common/consumerRegistry.cjs.map +1 -1
- package/dist/common/consumerRegistry.js.map +1 -1
- package/dist/common/requestCounter.cjs.map +1 -1
- package/dist/common/requestCounter.js.map +1 -1
- package/dist/common/requestLogger.cjs.map +1 -1
- package/dist/common/requestLogger.js.map +1 -1
- package/dist/common/serverErrorCounter.cjs.map +1 -1
- package/dist/common/serverErrorCounter.js.map +1 -1
- package/dist/common/tempGzipFile.cjs.map +1 -1
- package/dist/common/tempGzipFile.js.map +1 -1
- package/dist/common/types.cjs.map +1 -1
- package/dist/common/types.d.cts +0 -1
- package/dist/common/types.d.ts +0 -1
- package/dist/common/validationErrorCounter.cjs.map +1 -1
- package/dist/common/validationErrorCounter.js.map +1 -1
- package/dist/express/index.cjs +65 -20
- package/dist/express/index.cjs.map +1 -1
- package/dist/express/index.js +65 -20
- package/dist/express/index.js.map +1 -1
- package/dist/express/middleware.cjs +65 -20
- package/dist/express/middleware.cjs.map +1 -1
- package/dist/express/middleware.js +65 -20
- package/dist/express/middleware.js.map +1 -1
- package/dist/express/utils.cjs +59 -16
- package/dist/express/utils.cjs.map +1 -1
- package/dist/express/utils.d.cts +11 -2
- package/dist/express/utils.d.ts +11 -2
- package/dist/express/utils.js +56 -15
- package/dist/express/utils.js.map +1 -1
- package/dist/fastify/index.cjs.map +1 -1
- package/dist/fastify/index.js.map +1 -1
- package/dist/fastify/plugin.cjs.map +1 -1
- package/dist/fastify/plugin.js.map +1 -1
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/middleware.cjs.map +1 -1
- package/dist/hono/middleware.js.map +1 -1
- package/dist/koa/index.cjs.map +1 -1
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/middleware.cjs.map +1 -1
- package/dist/koa/middleware.js.map +1 -1
- package/dist/nestjs/index.cjs +65 -20
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.js +65 -20
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +26 -52
package/dist/nestjs/index.js
CHANGED
|
@@ -1077,6 +1077,29 @@ var STACK_ITEM_VALID_NAMES = [
|
|
|
1077
1077
|
"bound dispatch",
|
|
1078
1078
|
"mounted_app"
|
|
1079
1079
|
];
|
|
1080
|
+
var getRouterInfo = /* @__PURE__ */ __name(function(app) {
|
|
1081
|
+
var _a3, _b;
|
|
1082
|
+
if (app.stack) {
|
|
1083
|
+
return {
|
|
1084
|
+
stack: app.stack,
|
|
1085
|
+
version: "v4"
|
|
1086
|
+
};
|
|
1087
|
+
} else if ((_a3 = app._router) == null ? void 0 : _a3.stack) {
|
|
1088
|
+
return {
|
|
1089
|
+
stack: app._router.stack,
|
|
1090
|
+
version: "v4"
|
|
1091
|
+
};
|
|
1092
|
+
} else if ((_b = app.router) == null ? void 0 : _b.stack) {
|
|
1093
|
+
return {
|
|
1094
|
+
stack: app.router.stack,
|
|
1095
|
+
version: "v5"
|
|
1096
|
+
};
|
|
1097
|
+
}
|
|
1098
|
+
return {
|
|
1099
|
+
stack: null,
|
|
1100
|
+
version: "v4"
|
|
1101
|
+
};
|
|
1102
|
+
}, "getRouterInfo");
|
|
1080
1103
|
var getRouteMethods = /* @__PURE__ */ __name(function(route) {
|
|
1081
1104
|
let methods = Object.keys(route.methods);
|
|
1082
1105
|
methods = methods.filter((method) => method !== "_all");
|
|
@@ -1109,12 +1132,12 @@ var parseExpressRoute = /* @__PURE__ */ __name(function(route, basePath) {
|
|
|
1109
1132
|
});
|
|
1110
1133
|
return endpoints;
|
|
1111
1134
|
}, "parseExpressRoute");
|
|
1112
|
-
var
|
|
1135
|
+
var parseExpressPathRegExp = /* @__PURE__ */ __name(function(expressPathRegExp, keys) {
|
|
1113
1136
|
let parsedRegExp = expressPathRegExp.toString();
|
|
1114
1137
|
let expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
|
|
1115
1138
|
let paramIndex = 0;
|
|
1116
1139
|
while (hasParams(parsedRegExp)) {
|
|
1117
|
-
const paramName =
|
|
1140
|
+
const paramName = keys[paramIndex].name;
|
|
1118
1141
|
const paramId = `:${paramName}`;
|
|
1119
1142
|
parsedRegExp = parsedRegExp.replace(regExpToReplaceExpressPathRegExpParams, (str) => {
|
|
1120
1143
|
if (str.startsWith("(?:\\/")) {
|
|
@@ -1127,11 +1150,19 @@ var parseExpressPath = /* @__PURE__ */ __name(function(expressPathRegExp, params
|
|
|
1127
1150
|
if (parsedRegExp !== expressPathRegExp.toString()) {
|
|
1128
1151
|
expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
|
|
1129
1152
|
}
|
|
1130
|
-
|
|
1131
|
-
|
|
1153
|
+
return expressPathRegExpExec[1].replace(/\\\//g, "/");
|
|
1154
|
+
}, "parseExpressPathRegExp");
|
|
1155
|
+
var parseExpressPath = /* @__PURE__ */ __name(function(expressPath, params) {
|
|
1156
|
+
let result = expressPath;
|
|
1157
|
+
for (const [paramName, paramValue] of Object.entries(params)) {
|
|
1158
|
+
result = result.replace(paramValue, `:${paramName}`);
|
|
1159
|
+
}
|
|
1160
|
+
return result;
|
|
1132
1161
|
}, "parseExpressPath");
|
|
1133
1162
|
var parseEndpoints = /* @__PURE__ */ __name(function(app, basePath, endpoints) {
|
|
1134
|
-
const
|
|
1163
|
+
const routerInfo = getRouterInfo(app);
|
|
1164
|
+
const stack = routerInfo.stack;
|
|
1165
|
+
const version = routerInfo.version;
|
|
1135
1166
|
endpoints = endpoints || [];
|
|
1136
1167
|
basePath = basePath || "";
|
|
1137
1168
|
if (!stack) {
|
|
@@ -1145,7 +1176,7 @@ var parseEndpoints = /* @__PURE__ */ __name(function(app, basePath, endpoints) {
|
|
|
1145
1176
|
]);
|
|
1146
1177
|
}
|
|
1147
1178
|
} else {
|
|
1148
|
-
endpoints = parseStack(stack, basePath, endpoints);
|
|
1179
|
+
endpoints = parseStack(stack, basePath, endpoints, version);
|
|
1149
1180
|
}
|
|
1150
1181
|
return endpoints;
|
|
1151
1182
|
}, "parseEndpoints");
|
|
@@ -1161,20 +1192,28 @@ var addEndpoints = /* @__PURE__ */ __name(function(currentEndpoints, endpointsTo
|
|
|
1161
1192
|
});
|
|
1162
1193
|
return currentEndpoints;
|
|
1163
1194
|
}, "addEndpoints");
|
|
1164
|
-
var parseStack = /* @__PURE__ */ __name(function(stack, basePath, endpoints) {
|
|
1195
|
+
var parseStack = /* @__PURE__ */ __name(function(stack, basePath, endpoints, version) {
|
|
1165
1196
|
stack.forEach((stackItem) => {
|
|
1166
1197
|
if (stackItem.route) {
|
|
1167
1198
|
const newEndpoints = parseExpressRoute(stackItem.route, basePath);
|
|
1168
1199
|
endpoints = addEndpoints(endpoints, newEndpoints);
|
|
1169
1200
|
} else if (STACK_ITEM_VALID_NAMES.includes(stackItem.name)) {
|
|
1170
|
-
const isExpressPathRegexp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
|
|
1171
1201
|
let newBasePath = basePath;
|
|
1172
|
-
if (
|
|
1173
|
-
const
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1202
|
+
if (version === "v4") {
|
|
1203
|
+
const isExpressPathRegExp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
|
|
1204
|
+
if (isExpressPathRegExp) {
|
|
1205
|
+
const parsedPath = parseExpressPathRegExp(stackItem.regexp, stackItem.keys);
|
|
1206
|
+
newBasePath += `/${parsedPath}`;
|
|
1207
|
+
} else if (!stackItem.path && stackItem.regexp && stackItem.regexp.toString() !== EXPRESS_ROOT_PATH_REGEXP_VALUE) {
|
|
1208
|
+
const regExpPath = `RegExp(${stackItem.regexp})`;
|
|
1209
|
+
newBasePath += `/${regExpPath}`;
|
|
1210
|
+
}
|
|
1211
|
+
} else if (version === "v5") {
|
|
1212
|
+
if (!stackItem.path) {
|
|
1213
|
+
return;
|
|
1214
|
+
} else if (stackItem.path !== "/") {
|
|
1215
|
+
newBasePath += stackItem.path.startsWith("/") ? stackItem.path : `/${stackItem.path}`;
|
|
1216
|
+
}
|
|
1178
1217
|
}
|
|
1179
1218
|
endpoints = parseEndpoints(stackItem.handle, newBasePath, endpoints);
|
|
1180
1219
|
}
|
|
@@ -1225,7 +1264,7 @@ var getMiddleware = /* @__PURE__ */ __name((app, client) => {
|
|
|
1225
1264
|
}
|
|
1226
1265
|
return originalSend.call(res, body);
|
|
1227
1266
|
};
|
|
1228
|
-
res.
|
|
1267
|
+
res.once("finish", () => {
|
|
1229
1268
|
try {
|
|
1230
1269
|
const responseTime = performance.now() - startTime;
|
|
1231
1270
|
const path = getRoutePath(req);
|
|
@@ -1324,8 +1363,11 @@ var getRoutePath = /* @__PURE__ */ __name((req) => {
|
|
|
1324
1363
|
return;
|
|
1325
1364
|
}
|
|
1326
1365
|
if (req.baseUrl) {
|
|
1327
|
-
const
|
|
1328
|
-
|
|
1366
|
+
const routerInfo = getRouterInfo(req.app);
|
|
1367
|
+
if (routerInfo.stack) {
|
|
1368
|
+
const routerPath = getRouterPath(routerInfo.stack, req.baseUrl);
|
|
1369
|
+
return req.route.path === "/" ? routerPath : routerPath + req.route.path;
|
|
1370
|
+
}
|
|
1329
1371
|
}
|
|
1330
1372
|
return req.route.path;
|
|
1331
1373
|
}, "getRoutePath");
|
|
@@ -1335,12 +1377,15 @@ var getRouterPath = /* @__PURE__ */ __name((stack, baseUrl) => {
|
|
|
1335
1377
|
while (stack && stack.length > 0) {
|
|
1336
1378
|
const routerLayer = stack.find((layer) => {
|
|
1337
1379
|
var _a4;
|
|
1338
|
-
return layer.name === "router" && layer.path && ((_a4 = layer.regexp) == null ? void 0 : _a4.test(baseUrl));
|
|
1380
|
+
return layer.name === "router" && layer.path && (baseUrl.startsWith(layer.path) || ((_a4 = layer.regexp) == null ? void 0 : _a4.test(baseUrl)));
|
|
1339
1381
|
});
|
|
1340
1382
|
if (routerLayer) {
|
|
1341
|
-
if (routerLayer.keys.length > 0) {
|
|
1342
|
-
const parsedPath =
|
|
1383
|
+
if (routerLayer.regexp && routerLayer.keys && routerLayer.keys.length > 0) {
|
|
1384
|
+
const parsedPath = parseExpressPathRegExp(routerLayer.regexp, routerLayer.keys);
|
|
1343
1385
|
routerPaths.push("/" + parsedPath);
|
|
1386
|
+
} else if (routerLayer.params && Object.keys(routerLayer.params).length > 0) {
|
|
1387
|
+
const parsedPath = parseExpressPath(routerLayer.path, routerLayer.params);
|
|
1388
|
+
routerPaths.push(parsedPath);
|
|
1344
1389
|
} else {
|
|
1345
1390
|
routerPaths.push(routerLayer.path);
|
|
1346
1391
|
}
|