apitally 0.21.2 → 0.21.3
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/adonisjs/provider.cjs +15 -9
- package/dist/adonisjs/provider.cjs.map +1 -1
- package/dist/adonisjs/provider.js +15 -9
- package/dist/adonisjs/provider.js.map +1 -1
- package/dist/common/client.cjs +14 -9
- package/dist/common/client.cjs.map +1 -1
- package/dist/common/client.d.cts +1 -1
- package/dist/common/client.d.ts +1 -1
- package/dist/common/client.js +14 -9
- package/dist/common/client.js.map +1 -1
- package/dist/common/response.cjs +21 -2
- package/dist/common/response.cjs.map +1 -1
- package/dist/common/response.d.cts +2 -1
- package/dist/common/response.d.ts +2 -1
- package/dist/common/response.js +19 -1
- package/dist/common/response.js.map +1 -1
- package/dist/elysia/index.cjs +40 -16
- package/dist/elysia/index.cjs.map +1 -1
- package/dist/elysia/index.js +40 -16
- package/dist/elysia/index.js.map +1 -1
- package/dist/elysia/plugin.cjs +40 -16
- package/dist/elysia/plugin.cjs.map +1 -1
- package/dist/elysia/plugin.js +40 -16
- package/dist/elysia/plugin.js.map +1 -1
- package/dist/express/index.cjs +15 -9
- package/dist/express/index.cjs.map +1 -1
- package/dist/express/index.js +15 -9
- package/dist/express/index.js.map +1 -1
- package/dist/express/middleware.cjs +15 -9
- package/dist/express/middleware.cjs.map +1 -1
- package/dist/express/middleware.js +15 -9
- package/dist/express/middleware.js.map +1 -1
- package/dist/fastify/index.cjs +15 -9
- package/dist/fastify/index.cjs.map +1 -1
- package/dist/fastify/index.js +15 -9
- package/dist/fastify/index.js.map +1 -1
- package/dist/fastify/plugin.cjs +15 -9
- package/dist/fastify/plugin.cjs.map +1 -1
- package/dist/fastify/plugin.js +15 -9
- package/dist/fastify/plugin.js.map +1 -1
- package/dist/h3/index.cjs +15 -9
- package/dist/h3/index.cjs.map +1 -1
- package/dist/h3/index.js +15 -9
- package/dist/h3/index.js.map +1 -1
- package/dist/h3/plugin.cjs +15 -9
- package/dist/h3/plugin.cjs.map +1 -1
- package/dist/h3/plugin.js +15 -9
- package/dist/h3/plugin.js.map +1 -1
- package/dist/hapi/index.cjs +15 -9
- package/dist/hapi/index.cjs.map +1 -1
- package/dist/hapi/index.js +15 -9
- package/dist/hapi/index.js.map +1 -1
- package/dist/hapi/plugin.cjs +15 -9
- package/dist/hapi/plugin.cjs.map +1 -1
- package/dist/hapi/plugin.js +15 -9
- package/dist/hapi/plugin.js.map +1 -1
- package/dist/hono/index.cjs +15 -9
- package/dist/hono/index.cjs.map +1 -1
- package/dist/hono/index.js +15 -9
- package/dist/hono/index.js.map +1 -1
- package/dist/hono/middleware.cjs +15 -9
- package/dist/hono/middleware.cjs.map +1 -1
- package/dist/hono/middleware.js +15 -9
- package/dist/hono/middleware.js.map +1 -1
- package/dist/koa/index.cjs +15 -9
- package/dist/koa/index.cjs.map +1 -1
- package/dist/koa/index.js +15 -9
- package/dist/koa/index.js.map +1 -1
- package/dist/koa/middleware.cjs +15 -9
- package/dist/koa/middleware.cjs.map +1 -1
- package/dist/koa/middleware.js +15 -9
- package/dist/koa/middleware.js.map +1 -1
- package/dist/nestjs/index.cjs +16 -9
- package/dist/nestjs/index.cjs.map +1 -1
- package/dist/nestjs/index.js +16 -9
- package/dist/nestjs/index.js.map +1 -1
- package/package.json +1 -1
package/dist/elysia/plugin.cjs
CHANGED
|
@@ -886,11 +886,14 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
886
886
|
if (_ApitallyClient.instance) {
|
|
887
887
|
throw new Error("Apitally client is already initialized");
|
|
888
888
|
}
|
|
889
|
+
this.logger = logger ?? getLogger();
|
|
889
890
|
if (!isValidClientId(clientId)) {
|
|
890
|
-
|
|
891
|
+
this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
|
|
892
|
+
this.enabled = false;
|
|
891
893
|
}
|
|
892
894
|
if (!isValidEnv(env)) {
|
|
893
|
-
|
|
895
|
+
this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
|
|
896
|
+
this.enabled = false;
|
|
894
897
|
}
|
|
895
898
|
if (requestLoggingConfig && !requestLogging) {
|
|
896
899
|
console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
|
|
@@ -905,8 +908,6 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
905
908
|
this.validationErrorCounter = new ValidationErrorCounter();
|
|
906
909
|
this.serverErrorCounter = new ServerErrorCounter();
|
|
907
910
|
this.consumerRegistry = new ConsumerRegistry();
|
|
908
|
-
this.logger = logger ?? getLogger();
|
|
909
|
-
this.startSync();
|
|
910
911
|
this.handleShutdown = this.handleShutdown.bind(this);
|
|
911
912
|
}
|
|
912
913
|
static getInstance() {
|
|
@@ -961,15 +962,20 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
961
962
|
}
|
|
962
963
|
}
|
|
963
964
|
startSync() {
|
|
965
|
+
if (!this.enabled) {
|
|
966
|
+
return;
|
|
967
|
+
}
|
|
964
968
|
this.sync();
|
|
965
969
|
this.syncIntervalId = setInterval(() => {
|
|
966
970
|
this.sync();
|
|
967
971
|
}, INITIAL_SYNC_INTERVAL);
|
|
968
972
|
setTimeout(() => {
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
this.
|
|
972
|
-
|
|
973
|
+
if (this.syncIntervalId) {
|
|
974
|
+
clearInterval(this.syncIntervalId);
|
|
975
|
+
this.syncIntervalId = setInterval(() => {
|
|
976
|
+
this.sync();
|
|
977
|
+
}, SYNC_INTERVAL);
|
|
978
|
+
}
|
|
973
979
|
}, INITIAL_SYNC_INTERVAL_DURATION);
|
|
974
980
|
}
|
|
975
981
|
async sync() {
|
|
@@ -997,7 +1003,6 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
997
1003
|
setStartupData(data) {
|
|
998
1004
|
this.startupData = data;
|
|
999
1005
|
this.startupDataSent = false;
|
|
1000
|
-
this.sendStartupData();
|
|
1001
1006
|
}
|
|
1002
1007
|
async sendStartupData() {
|
|
1003
1008
|
if (this.startupData) {
|
|
@@ -1207,6 +1212,23 @@ function teeResponse(response) {
|
|
|
1207
1212
|
];
|
|
1208
1213
|
}
|
|
1209
1214
|
__name(teeResponse, "teeResponse");
|
|
1215
|
+
function teeResponseBlob(response, blob) {
|
|
1216
|
+
const newResponse1 = new Response(blob, {
|
|
1217
|
+
status: response.status,
|
|
1218
|
+
statusText: response.statusText,
|
|
1219
|
+
headers: response.headers
|
|
1220
|
+
});
|
|
1221
|
+
const newResponse2 = new Response(blob, {
|
|
1222
|
+
status: response.status,
|
|
1223
|
+
statusText: response.statusText,
|
|
1224
|
+
headers: response.headers
|
|
1225
|
+
});
|
|
1226
|
+
return [
|
|
1227
|
+
newResponse1,
|
|
1228
|
+
newResponse2
|
|
1229
|
+
];
|
|
1230
|
+
}
|
|
1231
|
+
__name(teeResponseBlob, "teeResponseBlob");
|
|
1210
1232
|
|
|
1211
1233
|
// src/loggers/console.ts
|
|
1212
1234
|
var import_node_util = require("util");
|
|
@@ -1432,33 +1454,35 @@ function apitallyPlugin(config) {
|
|
|
1432
1454
|
const originalMapResponse = handler.mapResponse;
|
|
1433
1455
|
const originalMapCompactResponse = handler.mapCompactResponse;
|
|
1434
1456
|
const originalMapEarlyResponse = handler.mapEarlyResponse;
|
|
1435
|
-
const captureResponse = /* @__PURE__ */ __name((
|
|
1436
|
-
|
|
1437
|
-
|
|
1457
|
+
const captureResponse = /* @__PURE__ */ __name((originalResponse, mappedResponse, request) => {
|
|
1458
|
+
var _a2;
|
|
1459
|
+
if (request instanceof Request && mappedResponse instanceof Response && !(RESPONSE_SYMBOL in request)) {
|
|
1460
|
+
const [newResponse1, newResponse2] = ((_a2 = originalResponse == null ? void 0 : originalResponse.constructor) == null ? void 0 : _a2.name) === "String" ? teeResponseBlob(mappedResponse, originalResponse) : teeResponse(mappedResponse);
|
|
1438
1461
|
request[RESPONSE_SYMBOL] = newResponse2;
|
|
1439
1462
|
return newResponse1;
|
|
1440
1463
|
} else {
|
|
1441
|
-
return
|
|
1464
|
+
return mappedResponse;
|
|
1442
1465
|
}
|
|
1443
1466
|
}, "captureResponse");
|
|
1444
1467
|
handler.mapResponse = /* @__PURE__ */ __name(function wrappedMapResponse(response, set, request) {
|
|
1445
1468
|
const mappedResponse = originalMapResponse(response, set, request);
|
|
1446
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1469
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1447
1470
|
return newResponse;
|
|
1448
1471
|
}, "wrappedMapResponse");
|
|
1449
1472
|
handler.mapCompactResponse = /* @__PURE__ */ __name(function wrappedMapCompactResponse(response, request) {
|
|
1450
1473
|
const mappedResponse = originalMapCompactResponse(response, request);
|
|
1451
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1474
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1452
1475
|
return newResponse;
|
|
1453
1476
|
}, "wrappedMapCompactResponse");
|
|
1454
1477
|
handler.mapEarlyResponse = /* @__PURE__ */ __name(function wrappedMapEarlyResponse(response, set, request) {
|
|
1455
1478
|
const mappedResponse = originalMapEarlyResponse(response, set, request);
|
|
1456
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1479
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1457
1480
|
return newResponse;
|
|
1458
1481
|
}, "wrappedMapEarlyResponse");
|
|
1459
1482
|
return app.decorate("apitally", {}).onStart(() => {
|
|
1460
1483
|
const appInfo = getAppInfo(app, config.appVersion);
|
|
1461
1484
|
client.setStartupData(appInfo);
|
|
1485
|
+
client.startSync();
|
|
1462
1486
|
}).onStop(async () => {
|
|
1463
1487
|
await client.handleShutdown();
|
|
1464
1488
|
}).onRequest(async ({ request }) => {
|