dowwntime 1.2.1 → 1.2.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/cli.mjs +37 -48
- package/dist/cli.mjs.map +1 -1
- package/dist/index.mjs +36 -47
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/cli.mjs
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { createRequire } from "module";
|
|
3
3
|
import { debug } from "util";
|
|
4
4
|
import http from "http";
|
|
5
|
+
import https from "https";
|
|
5
6
|
import fs from "fs";
|
|
6
7
|
import path from "path";
|
|
7
8
|
|
|
@@ -14672,7 +14673,7 @@ var require_dayjs_min = /* @__PURE__ */ __commonJS({ "node_modules/dayjs/dayjs.m
|
|
|
14672
14673
|
|
|
14673
14674
|
//#endregion
|
|
14674
14675
|
//#region node_modules/p-throttle/index.js
|
|
14675
|
-
var import_dayjs_min = /* @__PURE__ */ __toESM(require_dayjs_min());
|
|
14676
|
+
var import_dayjs_min = /* @__PURE__ */ __toESM(require_dayjs_min(), 1);
|
|
14676
14677
|
const states = /* @__PURE__ */ new WeakMap();
|
|
14677
14678
|
const signalThrottleds = /* @__PURE__ */ new WeakMap();
|
|
14678
14679
|
const finalizationRegistry = new FinalizationRegistry(({ signalWeakRef, weakReference }) => {
|
|
@@ -14886,40 +14887,24 @@ const debug$1 = debug("dowwntime");
|
|
|
14886
14887
|
const measureRequest = async (url$2, options) => {
|
|
14887
14888
|
const startAt = Date.now();
|
|
14888
14889
|
return await new Promise((resolve$1) => {
|
|
14889
|
-
let firstByteAt;
|
|
14890
|
-
let endAt;
|
|
14891
|
-
let dnsLookupAt;
|
|
14892
|
-
let tcpConnectionAt;
|
|
14893
14890
|
let tlsHandshakeAt;
|
|
14894
|
-
|
|
14895
|
-
|
|
14896
|
-
statusCode = res.statusCode || 0;
|
|
14897
|
-
res.once("readable", () => {
|
|
14898
|
-
firstByteAt = Date.now();
|
|
14899
|
-
});
|
|
14891
|
+
const req = ((typeof url$2 === "string" ? new URL(url$2) : url$2).protocol === "https:" ? https : http).request(url$2, options, (res) => {
|
|
14892
|
+
res.on("data", () => {});
|
|
14900
14893
|
res.on("end", () => {
|
|
14901
|
-
|
|
14894
|
+
const totalMs = Date.now() - startAt;
|
|
14895
|
+
const tlsMs = tlsHandshakeAt ? tlsHandshakeAt - startAt : 0;
|
|
14902
14896
|
resolve$1({
|
|
14903
|
-
statusCode,
|
|
14904
|
-
|
|
14905
|
-
tcpConnectionMs: tcpConnectionAt - dnsLookupAt,
|
|
14906
|
-
tlsHandshakeMs: tlsHandshakeAt - tcpConnectionAt,
|
|
14907
|
-
timeToFirstByteMs: firstByteAt - tlsHandshakeAt,
|
|
14908
|
-
contentTransferMs: endAt - firstByteAt,
|
|
14909
|
-
totalTimeMs: endAt - startAt
|
|
14897
|
+
statusCode: res.statusCode || 0,
|
|
14898
|
+
durationMs: totalMs - tlsMs
|
|
14910
14899
|
});
|
|
14911
14900
|
});
|
|
14912
|
-
})
|
|
14913
|
-
|
|
14914
|
-
dnsLookupAt = Date.now();
|
|
14915
|
-
});
|
|
14916
|
-
socket.on("connect", () => {
|
|
14917
|
-
tcpConnectionAt = Date.now();
|
|
14918
|
-
});
|
|
14901
|
+
});
|
|
14902
|
+
req.on("socket", (socket) => {
|
|
14919
14903
|
socket.on("secureConnect", () => {
|
|
14920
14904
|
tlsHandshakeAt = Date.now();
|
|
14921
14905
|
});
|
|
14922
14906
|
});
|
|
14907
|
+
req.end();
|
|
14923
14908
|
});
|
|
14924
14909
|
};
|
|
14925
14910
|
|
|
@@ -23820,7 +23805,7 @@ var require_form_data = /* @__PURE__ */ __commonJS({ "node_modules/form-data/lib
|
|
|
23820
23805
|
var util$1 = __require("util");
|
|
23821
23806
|
var path$2 = __require("path");
|
|
23822
23807
|
var http$3 = __require("http");
|
|
23823
|
-
var https$
|
|
23808
|
+
var https$3 = __require("https");
|
|
23824
23809
|
var parseUrl$2 = __require("url").parse;
|
|
23825
23810
|
var fs$2 = __require("fs");
|
|
23826
23811
|
var Stream = __require("stream").Stream;
|
|
@@ -24012,7 +23997,7 @@ var require_form_data = /* @__PURE__ */ __commonJS({ "node_modules/form-data/lib
|
|
|
24012
23997
|
if (!options.port) options.port = options.protocol === "https:" ? 443 : 80;
|
|
24013
23998
|
}
|
|
24014
23999
|
options.headers = this.getHeaders(params.headers);
|
|
24015
|
-
if (options.protocol === "https:") request = https$
|
|
24000
|
+
if (options.protocol === "https:") request = https$3.request(options);
|
|
24016
24001
|
else request = http$3.request(options);
|
|
24017
24002
|
this.getLength(function(err, length) {
|
|
24018
24003
|
if (err && err !== "Unknown stream") {
|
|
@@ -24140,7 +24125,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJS({ "node_modules/follow
|
|
|
24140
24125
|
var url$1 = __require("url");
|
|
24141
24126
|
var URL$1 = url$1.URL;
|
|
24142
24127
|
var http$2 = __require("http");
|
|
24143
|
-
var https$
|
|
24128
|
+
var https$2 = __require("https");
|
|
24144
24129
|
var Writable = __require("stream").Writable;
|
|
24145
24130
|
var assert = __require("assert");
|
|
24146
24131
|
var debug$2 = require_debug();
|
|
@@ -24562,7 +24547,7 @@ var require_follow_redirects = /* @__PURE__ */ __commonJS({ "node_modules/follow
|
|
|
24562
24547
|
}
|
|
24563
24548
|
module.exports = wrap({
|
|
24564
24549
|
http: http$2,
|
|
24565
|
-
https: https$
|
|
24550
|
+
https: https$2
|
|
24566
24551
|
});
|
|
24567
24552
|
module.exports.wrap = wrap;
|
|
24568
24553
|
}) });
|
|
@@ -24576,7 +24561,7 @@ var require_axios = /* @__PURE__ */ __commonJS({ "node_modules/axios/dist/node/a
|
|
|
24576
24561
|
const url = __require("url");
|
|
24577
24562
|
const proxyFromEnv = require_proxy_from_env();
|
|
24578
24563
|
const http$1 = __require("http");
|
|
24579
|
-
const https = __require("https");
|
|
24564
|
+
const https$1 = __require("https");
|
|
24580
24565
|
const http2 = __require("http2");
|
|
24581
24566
|
const util = __require("util");
|
|
24582
24567
|
const followRedirects = require_follow_redirects();
|
|
@@ -24591,7 +24576,7 @@ var require_axios = /* @__PURE__ */ __commonJS({ "node_modules/axios/dist/node/a
|
|
|
24591
24576
|
const url__default = /* @__PURE__ */ _interopDefaultLegacy(url);
|
|
24592
24577
|
const proxyFromEnv__default = /* @__PURE__ */ _interopDefaultLegacy(proxyFromEnv);
|
|
24593
24578
|
const http__default = /* @__PURE__ */ _interopDefaultLegacy(http$1);
|
|
24594
|
-
const https__default = /* @__PURE__ */ _interopDefaultLegacy(https);
|
|
24579
|
+
const https__default = /* @__PURE__ */ _interopDefaultLegacy(https$1);
|
|
24595
24580
|
const http2__default = /* @__PURE__ */ _interopDefaultLegacy(http2);
|
|
24596
24581
|
const util__default = /* @__PURE__ */ _interopDefaultLegacy(util);
|
|
24597
24582
|
const followRedirects__default = /* @__PURE__ */ _interopDefaultLegacy(followRedirects);
|
|
@@ -28369,9 +28354,9 @@ const run = async (options) => {
|
|
|
28369
28354
|
method: "GET",
|
|
28370
28355
|
timeout: options.timeoutMs ?? 5e3
|
|
28371
28356
|
});
|
|
28372
|
-
durationMs = metrics.
|
|
28373
|
-
if (options.getStatus) status = options.getStatus(metrics.statusCode, path$4,
|
|
28374
|
-
else status = metrics.statusCode >= 200 &&
|
|
28357
|
+
durationMs = metrics.durationMs;
|
|
28358
|
+
if (options.getStatus) status = options.getStatus(metrics.statusCode, path$4, durationMs);
|
|
28359
|
+
else status = metrics.statusCode >= 200 && durationMs < 300 ? "up" : "down";
|
|
28375
28360
|
} catch (_error) {
|
|
28376
28361
|
durationMs = Date.now() - start;
|
|
28377
28362
|
status = "down";
|
|
@@ -28439,20 +28424,24 @@ const run = async (options) => {
|
|
|
28439
28424
|
if (filtered.length === 0) return null;
|
|
28440
28425
|
return filtered.filter((item) => item.status === "degraded").length / filtered.length;
|
|
28441
28426
|
};
|
|
28427
|
+
const relDegraded60m = getRelativeDegraded(startOfPast60m);
|
|
28428
|
+
const relDegraded24h = getRelativeDegraded(startOfPast24h);
|
|
28429
|
+
const relDegraded7d = getRelativeDegraded(startOfPast7d);
|
|
28430
|
+
const relDegraded30d = getRelativeDegraded(startOfPast30d);
|
|
28442
28431
|
return {
|
|
28443
|
-
path: path$4
|
|
28444
|
-
relDowntime60m,
|
|
28445
|
-
|
|
28446
|
-
avgDuration60m,
|
|
28447
|
-
relDowntime24h,
|
|
28448
|
-
|
|
28449
|
-
avgDuration24h,
|
|
28450
|
-
relDowntime7d,
|
|
28451
|
-
|
|
28452
|
-
avgDuration7d,
|
|
28453
|
-
relDowntime30d,
|
|
28454
|
-
|
|
28455
|
-
avgDuration30d
|
|
28432
|
+
path: `${path$4} - ${history[history.length - 1]?.status ?? "unknown"} - ${history[history.length - 1]?.durationMs ?? 0}ms`,
|
|
28433
|
+
down60m: relDowntime60m,
|
|
28434
|
+
degr60m: relDegraded60m,
|
|
28435
|
+
dur60m: avgDuration60m,
|
|
28436
|
+
down24h: relDowntime24h,
|
|
28437
|
+
degr24h: relDegraded24h,
|
|
28438
|
+
dur24h: avgDuration24h,
|
|
28439
|
+
down7d: relDowntime7d,
|
|
28440
|
+
degr7d: relDegraded7d,
|
|
28441
|
+
dur7d: avgDuration7d,
|
|
28442
|
+
down30d: relDowntime30d,
|
|
28443
|
+
degr30d: relDegraded30d,
|
|
28444
|
+
dur30d: avgDuration30d
|
|
28456
28445
|
};
|
|
28457
28446
|
}));
|
|
28458
28447
|
console.table(reports);
|