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
|
@@ -1100,6 +1100,29 @@ var STACK_ITEM_VALID_NAMES = [
|
|
|
1100
1100
|
"bound dispatch",
|
|
1101
1101
|
"mounted_app"
|
|
1102
1102
|
];
|
|
1103
|
+
var getRouterInfo = /* @__PURE__ */ __name(function(app) {
|
|
1104
|
+
var _a2, _b;
|
|
1105
|
+
if (app.stack) {
|
|
1106
|
+
return {
|
|
1107
|
+
stack: app.stack,
|
|
1108
|
+
version: "v4"
|
|
1109
|
+
};
|
|
1110
|
+
} else if ((_a2 = app._router) == null ? void 0 : _a2.stack) {
|
|
1111
|
+
return {
|
|
1112
|
+
stack: app._router.stack,
|
|
1113
|
+
version: "v4"
|
|
1114
|
+
};
|
|
1115
|
+
} else if ((_b = app.router) == null ? void 0 : _b.stack) {
|
|
1116
|
+
return {
|
|
1117
|
+
stack: app.router.stack,
|
|
1118
|
+
version: "v5"
|
|
1119
|
+
};
|
|
1120
|
+
}
|
|
1121
|
+
return {
|
|
1122
|
+
stack: null,
|
|
1123
|
+
version: "v4"
|
|
1124
|
+
};
|
|
1125
|
+
}, "getRouterInfo");
|
|
1103
1126
|
var getRouteMethods = /* @__PURE__ */ __name(function(route) {
|
|
1104
1127
|
let methods = Object.keys(route.methods);
|
|
1105
1128
|
methods = methods.filter((method) => method !== "_all");
|
|
@@ -1132,12 +1155,12 @@ var parseExpressRoute = /* @__PURE__ */ __name(function(route, basePath) {
|
|
|
1132
1155
|
});
|
|
1133
1156
|
return endpoints;
|
|
1134
1157
|
}, "parseExpressRoute");
|
|
1135
|
-
var
|
|
1158
|
+
var parseExpressPathRegExp = /* @__PURE__ */ __name(function(expressPathRegExp, keys) {
|
|
1136
1159
|
let parsedRegExp = expressPathRegExp.toString();
|
|
1137
1160
|
let expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
|
|
1138
1161
|
let paramIndex = 0;
|
|
1139
1162
|
while (hasParams(parsedRegExp)) {
|
|
1140
|
-
const paramName =
|
|
1163
|
+
const paramName = keys[paramIndex].name;
|
|
1141
1164
|
const paramId = `:${paramName}`;
|
|
1142
1165
|
parsedRegExp = parsedRegExp.replace(regExpToReplaceExpressPathRegExpParams, (str) => {
|
|
1143
1166
|
if (str.startsWith("(?:\\/")) {
|
|
@@ -1150,11 +1173,19 @@ var parseExpressPath = /* @__PURE__ */ __name(function(expressPathRegExp, params
|
|
|
1150
1173
|
if (parsedRegExp !== expressPathRegExp.toString()) {
|
|
1151
1174
|
expressPathRegExpExec = regExpToParseExpressPathRegExp.exec(parsedRegExp);
|
|
1152
1175
|
}
|
|
1153
|
-
|
|
1154
|
-
|
|
1176
|
+
return expressPathRegExpExec[1].replace(/\\\//g, "/");
|
|
1177
|
+
}, "parseExpressPathRegExp");
|
|
1178
|
+
var parseExpressPath = /* @__PURE__ */ __name(function(expressPath, params) {
|
|
1179
|
+
let result = expressPath;
|
|
1180
|
+
for (const [paramName, paramValue] of Object.entries(params)) {
|
|
1181
|
+
result = result.replace(paramValue, `:${paramName}`);
|
|
1182
|
+
}
|
|
1183
|
+
return result;
|
|
1155
1184
|
}, "parseExpressPath");
|
|
1156
1185
|
var parseEndpoints = /* @__PURE__ */ __name(function(app, basePath, endpoints) {
|
|
1157
|
-
const
|
|
1186
|
+
const routerInfo = getRouterInfo(app);
|
|
1187
|
+
const stack = routerInfo.stack;
|
|
1188
|
+
const version = routerInfo.version;
|
|
1158
1189
|
endpoints = endpoints || [];
|
|
1159
1190
|
basePath = basePath || "";
|
|
1160
1191
|
if (!stack) {
|
|
@@ -1168,7 +1199,7 @@ var parseEndpoints = /* @__PURE__ */ __name(function(app, basePath, endpoints) {
|
|
|
1168
1199
|
]);
|
|
1169
1200
|
}
|
|
1170
1201
|
} else {
|
|
1171
|
-
endpoints = parseStack(stack, basePath, endpoints);
|
|
1202
|
+
endpoints = parseStack(stack, basePath, endpoints, version);
|
|
1172
1203
|
}
|
|
1173
1204
|
return endpoints;
|
|
1174
1205
|
}, "parseEndpoints");
|
|
@@ -1184,20 +1215,28 @@ var addEndpoints = /* @__PURE__ */ __name(function(currentEndpoints, endpointsTo
|
|
|
1184
1215
|
});
|
|
1185
1216
|
return currentEndpoints;
|
|
1186
1217
|
}, "addEndpoints");
|
|
1187
|
-
var parseStack = /* @__PURE__ */ __name(function(stack, basePath, endpoints) {
|
|
1218
|
+
var parseStack = /* @__PURE__ */ __name(function(stack, basePath, endpoints, version) {
|
|
1188
1219
|
stack.forEach((stackItem) => {
|
|
1189
1220
|
if (stackItem.route) {
|
|
1190
1221
|
const newEndpoints = parseExpressRoute(stackItem.route, basePath);
|
|
1191
1222
|
endpoints = addEndpoints(endpoints, newEndpoints);
|
|
1192
1223
|
} else if (STACK_ITEM_VALID_NAMES.includes(stackItem.name)) {
|
|
1193
|
-
const isExpressPathRegexp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
|
|
1194
1224
|
let newBasePath = basePath;
|
|
1195
|
-
if (
|
|
1196
|
-
const
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1225
|
+
if (version === "v4") {
|
|
1226
|
+
const isExpressPathRegExp = regExpToParseExpressPathRegExp.test(stackItem.regexp);
|
|
1227
|
+
if (isExpressPathRegExp) {
|
|
1228
|
+
const parsedPath = parseExpressPathRegExp(stackItem.regexp, stackItem.keys);
|
|
1229
|
+
newBasePath += `/${parsedPath}`;
|
|
1230
|
+
} else if (!stackItem.path && stackItem.regexp && stackItem.regexp.toString() !== EXPRESS_ROOT_PATH_REGEXP_VALUE) {
|
|
1231
|
+
const regExpPath = `RegExp(${stackItem.regexp})`;
|
|
1232
|
+
newBasePath += `/${regExpPath}`;
|
|
1233
|
+
}
|
|
1234
|
+
} else if (version === "v5") {
|
|
1235
|
+
if (!stackItem.path) {
|
|
1236
|
+
return;
|
|
1237
|
+
} else if (stackItem.path !== "/") {
|
|
1238
|
+
newBasePath += stackItem.path.startsWith("/") ? stackItem.path : `/${stackItem.path}`;
|
|
1239
|
+
}
|
|
1201
1240
|
}
|
|
1202
1241
|
endpoints = parseEndpoints(stackItem.handle, newBasePath, endpoints);
|
|
1203
1242
|
}
|
|
@@ -1248,7 +1287,7 @@ var getMiddleware = /* @__PURE__ */ __name((app, client) => {
|
|
|
1248
1287
|
}
|
|
1249
1288
|
return originalSend.call(res, body);
|
|
1250
1289
|
};
|
|
1251
|
-
res.
|
|
1290
|
+
res.once("finish", () => {
|
|
1252
1291
|
try {
|
|
1253
1292
|
const responseTime = import_perf_hooks.performance.now() - startTime;
|
|
1254
1293
|
const path = getRoutePath(req);
|
|
@@ -1347,8 +1386,11 @@ var getRoutePath = /* @__PURE__ */ __name((req) => {
|
|
|
1347
1386
|
return;
|
|
1348
1387
|
}
|
|
1349
1388
|
if (req.baseUrl) {
|
|
1350
|
-
const
|
|
1351
|
-
|
|
1389
|
+
const routerInfo = getRouterInfo(req.app);
|
|
1390
|
+
if (routerInfo.stack) {
|
|
1391
|
+
const routerPath = getRouterPath(routerInfo.stack, req.baseUrl);
|
|
1392
|
+
return req.route.path === "/" ? routerPath : routerPath + req.route.path;
|
|
1393
|
+
}
|
|
1352
1394
|
}
|
|
1353
1395
|
return req.route.path;
|
|
1354
1396
|
}, "getRoutePath");
|
|
@@ -1358,12 +1400,15 @@ var getRouterPath = /* @__PURE__ */ __name((stack, baseUrl) => {
|
|
|
1358
1400
|
while (stack && stack.length > 0) {
|
|
1359
1401
|
const routerLayer = stack.find((layer) => {
|
|
1360
1402
|
var _a3;
|
|
1361
|
-
return layer.name === "router" && layer.path && ((_a3 = layer.regexp) == null ? void 0 : _a3.test(baseUrl));
|
|
1403
|
+
return layer.name === "router" && layer.path && (baseUrl.startsWith(layer.path) || ((_a3 = layer.regexp) == null ? void 0 : _a3.test(baseUrl)));
|
|
1362
1404
|
});
|
|
1363
1405
|
if (routerLayer) {
|
|
1364
|
-
if (routerLayer.keys.length > 0) {
|
|
1365
|
-
const parsedPath =
|
|
1406
|
+
if (routerLayer.regexp && routerLayer.keys && routerLayer.keys.length > 0) {
|
|
1407
|
+
const parsedPath = parseExpressPathRegExp(routerLayer.regexp, routerLayer.keys);
|
|
1366
1408
|
routerPaths.push("/" + parsedPath);
|
|
1409
|
+
} else if (routerLayer.params && Object.keys(routerLayer.params).length > 0) {
|
|
1410
|
+
const parsedPath = parseExpressPath(routerLayer.path, routerLayer.params);
|
|
1411
|
+
routerPaths.push(parsedPath);
|
|
1367
1412
|
} else {
|
|
1368
1413
|
routerPaths.push(routerLayer.path);
|
|
1369
1414
|
}
|