widefleet 0.0.0-stage → 0.0.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Widefleet contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,72 @@
1
- # Temporary Holding Version
1
+ # widefleet
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Check HTTP endpoints from the command line or JavaScript. This initial release
4
+ provides a small HTTP health-check utility, with no runtime dependencies.
5
+ It does not deploy applications or provide the full Widefleet platform CLI.
6
+
7
+ Requires Node.js 22 or newer.
8
+
9
+ ## Command line
10
+
11
+ Once published to npm:
12
+
13
+ ```sh
14
+ npx widefleet check https://example.com
15
+ npx widefleet check https://example.com https://example.org --timeout 3000 --json
16
+ ```
17
+
18
+ From this repository:
19
+
20
+ ```sh
21
+ node bin/widefleet.js check https://example.com
22
+ ```
23
+
24
+ Checks send HTTP GET requests, follow redirects and consider final status codes
25
+ 200–299 healthy. URLs are checked sequentially in the supplied order. Timing is
26
+ measured through receiving the final response headers; response bodies are
27
+ cancelled without being read. The default timeout is 5,000 milliseconds per URL.
28
+ Requests have no retries. Only use this command with endpoints intended for GET
29
+ requests. URLs containing embedded credentials are rejected.
30
+
31
+ Example JSON output:
32
+
33
+ ```json
34
+ [
35
+ {
36
+ "url": "https://example.com/",
37
+ "ok": true,
38
+ "status": 200,
39
+ "durationMs": 123
40
+ }
41
+ ]
42
+ ```
43
+
44
+ Network failures have `status: null` and an `error` message. The reported URL is
45
+ the normalized input URL. Exit codes are `0` when every endpoint is healthy,
46
+ `1` when an endpoint fails and `2` for invalid command-line arguments.
47
+
48
+ ## JavaScript
49
+
50
+ ```js
51
+ import { checkUrl } from "widefleet";
52
+
53
+ const result = await checkUrl("https://example.com", { timeoutMs: 3000 });
54
+ console.log(result.ok, result.status, result.durationMs);
55
+ ```
56
+
57
+ `checkUrl` returns the same result object as the command line. Invalid URLs,
58
+ embedded credentials and invalid timeouts throw; HTTP errors, connection errors
59
+ and timeouts produce an unsuccessful result instead.
60
+
61
+ ## Development
62
+
63
+ ```sh
64
+ npm test
65
+ npm pack --dry-run
66
+ ```
67
+
68
+ Tests use local HTTP servers and synthetic responses. Installation requires no
69
+ dependencies or lifecycle scripts. The publishable archive includes only the
70
+ CLI, library, manifest, README and license.
71
+
72
+ Publishing and version updates are documented in [PUBLISHING.md](PUBLISHING.md).
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env node
2
+ import { readFileSync } from "node:fs";
3
+ import { parseArgs } from "node:util";
4
+ import { checkUrl } from "../src/check.js";
5
+
6
+ const help = `Widefleet HTTP checks
7
+
8
+ Usage:
9
+ widefleet check <url> [url ...] [--timeout <ms>] [--json]
10
+
11
+ Options:
12
+ -t, --timeout <ms> Timeout per URL in milliseconds (default: 5000)
13
+ --json Print a JSON array of results
14
+ -h, --help Show help
15
+ -v, --version Show the package version
16
+
17
+ Checks send GET requests and follow redirects. HTTP 200-299 is healthy.
18
+ Exit codes: 0 = all healthy, 1 = an endpoint failed, 2 = invalid arguments.
19
+ `;
20
+
21
+ async function main() {
22
+ const { values, positionals } = parseArgs({
23
+ allowPositionals: true,
24
+ options: {
25
+ timeout: { type: "string", short: "t", default: "5000" },
26
+ json: { type: "boolean", default: false },
27
+ help: { type: "boolean", short: "h" },
28
+ version: { type: "boolean", short: "v" },
29
+ },
30
+ });
31
+
32
+ if (values.help || process.argv.length === 2) {
33
+ process.stdout.write(help);
34
+ return;
35
+ }
36
+ if (values.version) {
37
+ const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
38
+ console.log(manifest.version);
39
+ return;
40
+ }
41
+
42
+ const [command, ...inputs] = positionals;
43
+ if (command !== "check" || inputs.length === 0) {
44
+ throw new Error("Usage: widefleet check <url> [url ...] [--timeout <ms>] [--json]");
45
+ }
46
+ if (!/^[1-9]\d*$/.test(values.timeout) || Number(values.timeout) > 2147483647) {
47
+ throw new Error("Timeout must be an integer between 1 and 2147483647 milliseconds.");
48
+ }
49
+
50
+ // Validate every URL before making requests, even when a later input is invalid.
51
+ const urls = inputs.map((input) => {
52
+ const url = new URL(input);
53
+ if (!['http:', 'https:'].includes(url.protocol) || url.username || url.password) {
54
+ throw new Error("Use http:// or https:// URLs without embedded credentials.");
55
+ }
56
+ return url;
57
+ });
58
+
59
+ const results = [];
60
+ for (const url of urls) {
61
+ const result = await checkUrl(url, { timeoutMs: Number(values.timeout) });
62
+ results.push(result);
63
+ if (!values.json) {
64
+ console.log(`${result.ok ? "OK" : "FAIL"} ${result.url} ${result.status ?? result.error} (${result.durationMs} ms)`);
65
+ }
66
+ }
67
+ if (values.json) {
68
+ console.log(JSON.stringify(results, null, 2));
69
+ }
70
+ process.exitCode = results.every((result) => result.ok) ? 0 : 1;
71
+ }
72
+
73
+ try {
74
+ await main();
75
+ } catch (error) {
76
+ console.error(`widefleet: ${error instanceof Error ? error.message : String(error)}`);
77
+ process.exitCode = 2;
78
+ }
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "widefleet",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.0.1",
4
+ "description": "Check HTTP endpoints from the command line or JavaScript.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "engines": {
8
+ "node": ">=22"
9
+ },
10
+ "bin": {
11
+ "widefleet": "bin/widefleet.js"
12
+ },
13
+ "exports": "./src/check.js",
14
+ "files": [
15
+ "bin/",
16
+ "src/",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "test": "node --test",
22
+ "prepublishOnly": "npm test"
23
+ },
24
+ "repository": {
25
+ "type": "git",
26
+ "url": "git+https://github.com/widefleet/npm.git"
27
+ },
28
+ "bugs": {
29
+ "url": "https://github.com/widefleet/npm/issues"
30
+ },
31
+ "homepage": "https://widefleet.com",
32
+ "keywords": [
33
+ "http",
34
+ "healthcheck",
35
+ "cli",
36
+ "widefleet"
37
+ ],
38
+ "publishConfig": {
39
+ "registry": "https://registry.npmjs.org/",
40
+ "access": "public"
41
+ }
42
+ }
package/src/check.js ADDED
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Check an HTTP endpoint with a GET request, following redirects.
3
+ * The timeout covers receiving response headers; the response body is not read.
4
+ * Invalid inputs throw. HTTP and network failures return an unsuccessful result.
5
+ */
6
+ export async function checkUrl(input, { timeoutMs = 5000 } = {}) {
7
+ const url = new URL(input);
8
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
9
+ throw new TypeError("Only http:// and https:// URLs are supported.");
10
+ }
11
+ if (url.username || url.password) {
12
+ throw new TypeError("URLs containing credentials are not supported.");
13
+ }
14
+ if (!Number.isSafeInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 2147483647) {
15
+ throw new TypeError("Timeout must be an integer between 1 and 2147483647 milliseconds.");
16
+ }
17
+
18
+ const started = performance.now();
19
+ const signal = AbortSignal.timeout(timeoutMs);
20
+ try {
21
+ const response = await fetch(url, {
22
+ method: "GET",
23
+ redirect: "follow",
24
+ signal,
25
+ headers: { "user-agent": "widefleet-http-check" },
26
+ });
27
+ const durationMs = Math.round(performance.now() - started);
28
+ // Stop streaming immediately: a health check does not need the response body.
29
+ if (response.body) {
30
+ await response.body.cancel();
31
+ }
32
+ return { url: url.href, ok: response.ok, status: response.status, durationMs };
33
+ } catch (error) {
34
+ return {
35
+ url: url.href,
36
+ ok: false,
37
+ status: null,
38
+ durationMs: Math.round(performance.now() - started),
39
+ error: signal.aborted
40
+ ? `Timed out after ${timeoutMs} ms`
41
+ : error instanceof Error ? error.message : String(error),
42
+ };
43
+ }
44
+ }