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/index.js
CHANGED
|
@@ -860,11 +860,14 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
860
860
|
if (_ApitallyClient.instance) {
|
|
861
861
|
throw new Error("Apitally client is already initialized");
|
|
862
862
|
}
|
|
863
|
+
this.logger = logger ?? getLogger();
|
|
863
864
|
if (!isValidClientId(clientId)) {
|
|
864
|
-
|
|
865
|
+
this.logger.error(`Invalid Apitally client ID '${clientId}' (expecting hexadecimal UUID format)`);
|
|
866
|
+
this.enabled = false;
|
|
865
867
|
}
|
|
866
868
|
if (!isValidEnv(env)) {
|
|
867
|
-
|
|
869
|
+
this.logger.error(`Invalid Apitally env '${env}' (expecting 1-32 alphanumeric characters and hyphens only)`);
|
|
870
|
+
this.enabled = false;
|
|
868
871
|
}
|
|
869
872
|
if (requestLoggingConfig && !requestLogging) {
|
|
870
873
|
console.warn("requestLoggingConfig is deprecated, use requestLogging instead.");
|
|
@@ -879,8 +882,6 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
879
882
|
this.validationErrorCounter = new ValidationErrorCounter();
|
|
880
883
|
this.serverErrorCounter = new ServerErrorCounter();
|
|
881
884
|
this.consumerRegistry = new ConsumerRegistry();
|
|
882
|
-
this.logger = logger ?? getLogger();
|
|
883
|
-
this.startSync();
|
|
884
885
|
this.handleShutdown = this.handleShutdown.bind(this);
|
|
885
886
|
}
|
|
886
887
|
static getInstance() {
|
|
@@ -935,15 +936,20 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
935
936
|
}
|
|
936
937
|
}
|
|
937
938
|
startSync() {
|
|
939
|
+
if (!this.enabled) {
|
|
940
|
+
return;
|
|
941
|
+
}
|
|
938
942
|
this.sync();
|
|
939
943
|
this.syncIntervalId = setInterval(() => {
|
|
940
944
|
this.sync();
|
|
941
945
|
}, INITIAL_SYNC_INTERVAL);
|
|
942
946
|
setTimeout(() => {
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
this.
|
|
946
|
-
|
|
947
|
+
if (this.syncIntervalId) {
|
|
948
|
+
clearInterval(this.syncIntervalId);
|
|
949
|
+
this.syncIntervalId = setInterval(() => {
|
|
950
|
+
this.sync();
|
|
951
|
+
}, SYNC_INTERVAL);
|
|
952
|
+
}
|
|
947
953
|
}, INITIAL_SYNC_INTERVAL_DURATION);
|
|
948
954
|
}
|
|
949
955
|
async sync() {
|
|
@@ -971,7 +977,6 @@ var _ApitallyClient = class _ApitallyClient {
|
|
|
971
977
|
setStartupData(data) {
|
|
972
978
|
this.startupData = data;
|
|
973
979
|
this.startupDataSent = false;
|
|
974
|
-
this.sendStartupData();
|
|
975
980
|
}
|
|
976
981
|
async sendStartupData() {
|
|
977
982
|
if (this.startupData) {
|
|
@@ -1181,6 +1186,23 @@ function teeResponse(response) {
|
|
|
1181
1186
|
];
|
|
1182
1187
|
}
|
|
1183
1188
|
__name(teeResponse, "teeResponse");
|
|
1189
|
+
function teeResponseBlob(response, blob) {
|
|
1190
|
+
const newResponse1 = new Response(blob, {
|
|
1191
|
+
status: response.status,
|
|
1192
|
+
statusText: response.statusText,
|
|
1193
|
+
headers: response.headers
|
|
1194
|
+
});
|
|
1195
|
+
const newResponse2 = new Response(blob, {
|
|
1196
|
+
status: response.status,
|
|
1197
|
+
statusText: response.statusText,
|
|
1198
|
+
headers: response.headers
|
|
1199
|
+
});
|
|
1200
|
+
return [
|
|
1201
|
+
newResponse1,
|
|
1202
|
+
newResponse2
|
|
1203
|
+
];
|
|
1204
|
+
}
|
|
1205
|
+
__name(teeResponseBlob, "teeResponseBlob");
|
|
1184
1206
|
|
|
1185
1207
|
// src/loggers/console.ts
|
|
1186
1208
|
import { format as format2 } from "util";
|
|
@@ -1405,33 +1427,35 @@ function apitallyPlugin(config) {
|
|
|
1405
1427
|
const originalMapResponse = handler.mapResponse;
|
|
1406
1428
|
const originalMapCompactResponse = handler.mapCompactResponse;
|
|
1407
1429
|
const originalMapEarlyResponse = handler.mapEarlyResponse;
|
|
1408
|
-
const captureResponse = /* @__PURE__ */ __name((
|
|
1409
|
-
|
|
1410
|
-
|
|
1430
|
+
const captureResponse = /* @__PURE__ */ __name((originalResponse, mappedResponse, request) => {
|
|
1431
|
+
var _a2;
|
|
1432
|
+
if (request instanceof Request && mappedResponse instanceof Response && !(RESPONSE_SYMBOL in request)) {
|
|
1433
|
+
const [newResponse1, newResponse2] = ((_a2 = originalResponse == null ? void 0 : originalResponse.constructor) == null ? void 0 : _a2.name) === "String" ? teeResponseBlob(mappedResponse, originalResponse) : teeResponse(mappedResponse);
|
|
1411
1434
|
request[RESPONSE_SYMBOL] = newResponse2;
|
|
1412
1435
|
return newResponse1;
|
|
1413
1436
|
} else {
|
|
1414
|
-
return
|
|
1437
|
+
return mappedResponse;
|
|
1415
1438
|
}
|
|
1416
1439
|
}, "captureResponse");
|
|
1417
1440
|
handler.mapResponse = /* @__PURE__ */ __name(function wrappedMapResponse(response, set, request) {
|
|
1418
1441
|
const mappedResponse = originalMapResponse(response, set, request);
|
|
1419
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1442
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1420
1443
|
return newResponse;
|
|
1421
1444
|
}, "wrappedMapResponse");
|
|
1422
1445
|
handler.mapCompactResponse = /* @__PURE__ */ __name(function wrappedMapCompactResponse(response, request) {
|
|
1423
1446
|
const mappedResponse = originalMapCompactResponse(response, request);
|
|
1424
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1447
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1425
1448
|
return newResponse;
|
|
1426
1449
|
}, "wrappedMapCompactResponse");
|
|
1427
1450
|
handler.mapEarlyResponse = /* @__PURE__ */ __name(function wrappedMapEarlyResponse(response, set, request) {
|
|
1428
1451
|
const mappedResponse = originalMapEarlyResponse(response, set, request);
|
|
1429
|
-
const newResponse = captureResponse(mappedResponse, request);
|
|
1452
|
+
const newResponse = captureResponse(response, mappedResponse, request);
|
|
1430
1453
|
return newResponse;
|
|
1431
1454
|
}, "wrappedMapEarlyResponse");
|
|
1432
1455
|
return app.decorate("apitally", {}).onStart(() => {
|
|
1433
1456
|
const appInfo = getAppInfo(app, config.appVersion);
|
|
1434
1457
|
client.setStartupData(appInfo);
|
|
1458
|
+
client.startSync();
|
|
1435
1459
|
}).onStop(async () => {
|
|
1436
1460
|
await client.handleShutdown();
|
|
1437
1461
|
}).onRequest(async ({ request }) => {
|