@openstatus/health-planetscale 0.1.4-dev.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 +73 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/mod.cjs +30 -0
- package/dist/mod.d.cts +22 -0
- package/dist/mod.d.cts.map +1 -0
- package/dist/mod.d.ts +22 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +29 -0
- package/dist/mod.js.map +1 -0
- package/package.json +69 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# @openstatus/health-planetscale
|
|
2
|
+
|
|
3
|
+
[PlanetScale](https://planetscale.com/) probe for
|
|
4
|
+
[`@openstatus/health`](https://jsr.io/@openstatus/health). Runs `select 1`
|
|
5
|
+
over the serverless HTTP driver,
|
|
6
|
+
[`@planetscale/database`](https://github.com/planetscale/database-js), and
|
|
7
|
+
fails the check when the round trip does.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
deno add jsr:@openstatus/health jsr:@openstatus/health-planetscale
|
|
11
|
+
npm install @openstatus/health @openstatus/health-planetscale
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { connect } from "@planetscale/database";
|
|
16
|
+
import { createHealthHandler } from "@openstatus/health";
|
|
17
|
+
import { planetscaleProbe } from "@openstatus/health-planetscale";
|
|
18
|
+
|
|
19
|
+
const connection = connect({ url: env.DATABASE_URL });
|
|
20
|
+
|
|
21
|
+
Deno.serve(
|
|
22
|
+
createHealthHandler({
|
|
23
|
+
probes: [planetscaleProbe({ connection })],
|
|
24
|
+
}),
|
|
25
|
+
);
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Every probe is one stateless `fetch` against PlanetScale's HTTP API, so
|
|
29
|
+
nothing stays open between health requests and the probe runs on edge
|
|
30
|
+
runtimes. A `Client` from the same package works too — the probe only calls
|
|
31
|
+
`execute("select 1")`. The driver's `execute()` takes no `AbortSignal`, so a
|
|
32
|
+
check that outlives `timeoutMs` is reported `timeout` while the HTTP request
|
|
33
|
+
runs to completion in the background; pass a `fetch` with its own deadline to
|
|
34
|
+
`connect()` if that matters. For a PlanetScale database reached through
|
|
35
|
+
`mysql2` instead, use `@openstatus/health-mysql`.
|
|
36
|
+
|
|
37
|
+
```ts
|
|
38
|
+
planetscaleProbe({
|
|
39
|
+
connection,
|
|
40
|
+
// optional overrides from the Probe contract
|
|
41
|
+
name: "primary",
|
|
42
|
+
critical: false,
|
|
43
|
+
timeoutMs: 2000,
|
|
44
|
+
skip: () => env.DATABASE_URL == null,
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
Critical by default: a database that does not answer usually means requests
|
|
49
|
+
cannot be served, so the report turns `unhealthy` and the instance is taken
|
|
50
|
+
out of rotation. Set `critical: false` for a replica or reporting database.
|
|
51
|
+
|
|
52
|
+
The connection is typed structurally as `{ execute(query): PromiseLike<...> }`,
|
|
53
|
+
so `@planetscale/database` is an optional peer dependency for its types only
|
|
54
|
+
and the probe adds no runtime import of it. The factory throws
|
|
55
|
+
`ProbeConfigError` at construction when the connection has no `execute()`.
|
|
56
|
+
|
|
57
|
+
## About openstatus
|
|
58
|
+
|
|
59
|
+
[openstatus](https://www.openstatus.dev/) is the open-source uptime monitoring
|
|
60
|
+
and status page platform. This package is part of
|
|
61
|
+
[`@openstatus/health`](https://github.com/openstatusHQ/health), the `/health`
|
|
62
|
+
endpoints behind openstatus's own services, extracted so any JavaScript server
|
|
63
|
+
can expose one. Point an
|
|
64
|
+
[openstatus monitor](https://www.openstatus.dev/docs/reference/http-monitor)
|
|
65
|
+
at the endpoint and assert on `status` in the body to be alerted on
|
|
66
|
+
`degraded` before it becomes `unhealthy`.
|
|
67
|
+
|
|
68
|
+
Source: [github.com/openstatusHQ/health](https://github.com/openstatusHQ/health).
|
|
69
|
+
Issues and PRs welcome.
|
|
70
|
+
|
|
71
|
+
## License
|
|
72
|
+
|
|
73
|
+
[MIT](https://github.com/openstatusHQ/health/blob/main/LICENSE)
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/mod.cjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __openstatus_health = require_rolldown_runtime.__toESM(require("@openstatus/health"));
|
|
3
|
+
|
|
4
|
+
//#region src/mod.ts
|
|
5
|
+
/** Probe name when `name` is unset. */
|
|
6
|
+
const planetscaleDefaultName = "database";
|
|
7
|
+
/** A probe that runs `select 1`; critical by default. The driver's `execute()` takes no `AbortSignal`, so a timed-out request is not cancelled. Throws `ProbeConfigError` without `execute()`. */
|
|
8
|
+
function planetscaleProbe(options) {
|
|
9
|
+
const connection = options.connection;
|
|
10
|
+
if (typeof connection?.execute !== "function") throw new __openstatus_health.ProbeConfigError("planetscaleProbe", "connection", `must expose execute(), got ${describe(connection)}`);
|
|
11
|
+
return {
|
|
12
|
+
name: options.name ?? planetscaleDefaultName,
|
|
13
|
+
critical: options.critical ?? true,
|
|
14
|
+
timeoutMs: options.timeoutMs,
|
|
15
|
+
skip: options.skip,
|
|
16
|
+
run: async () => {
|
|
17
|
+
await connection.execute("select 1");
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function describe(connection) {
|
|
22
|
+
if (connection == null) return String(connection);
|
|
23
|
+
if (typeof connection !== "object") return typeof connection;
|
|
24
|
+
const keys = Object.keys(connection);
|
|
25
|
+
return keys.length === 0 ? "an object with no keys" : `an object with keys ${keys.slice(0, 8).join(", ")}`;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
exports.planetscaleDefaultName = planetscaleDefaultName;
|
|
30
|
+
exports.planetscaleProbe = planetscaleProbe;
|
package/dist/mod.d.cts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Probe, ProbeOverrides, ProbeResult } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.d.ts
|
|
4
|
+
|
|
5
|
+
/** Probe name when `name` is unset. */
|
|
6
|
+
declare const planetscaleDefaultName = "database";
|
|
7
|
+
/** The subset of a `@planetscale/database` `Connection` or `Client` the probe uses. */
|
|
8
|
+
interface PlanetScaleLikeConnection {
|
|
9
|
+
/** Run one statement. */
|
|
10
|
+
execute(query: string): PromiseLike<ProbeResult>;
|
|
11
|
+
}
|
|
12
|
+
/** Options for `planetscaleProbe()`. */
|
|
13
|
+
interface PlanetScaleProbeOptions extends ProbeOverrides {
|
|
14
|
+
/** A `connect()` connection or a `Client`. */
|
|
15
|
+
readonly connection: PlanetScaleLikeConnection;
|
|
16
|
+
}
|
|
17
|
+
/** A probe that runs `select 1`; critical by default. The driver's `execute()` takes no `AbortSignal`, so a timed-out request is not cancelled. Throws `ProbeConfigError` without `execute()`. */
|
|
18
|
+
declare function planetscaleProbe(options: PlanetScaleProbeOptions): Probe;
|
|
19
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
20
|
+
//#endregion
|
|
21
|
+
export { PlanetScaleLikeConnection, PlanetScaleProbeOptions, planetscaleDefaultName, planetscaleProbe };
|
|
22
|
+
//# sourceMappingURL=mod.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;AAqCA;AAAgC,cAfnB,sBAAA,GAemB,UAAA;;AAAoC,UAZnD,yBAAA,CAYmD;EAAK;0BAV/C,YAAY;;;UAIrB,uBAAA,SAAgC;;uBAE1B;;;iBAIP,gBAAA,UAA0B,0BAA0B"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Probe, ProbeOverrides, ProbeResult } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.d.ts
|
|
4
|
+
|
|
5
|
+
/** Probe name when `name` is unset. */
|
|
6
|
+
declare const planetscaleDefaultName = "database";
|
|
7
|
+
/** The subset of a `@planetscale/database` `Connection` or `Client` the probe uses. */
|
|
8
|
+
interface PlanetScaleLikeConnection {
|
|
9
|
+
/** Run one statement. */
|
|
10
|
+
execute(query: string): PromiseLike<ProbeResult>;
|
|
11
|
+
}
|
|
12
|
+
/** Options for `planetscaleProbe()`. */
|
|
13
|
+
interface PlanetScaleProbeOptions extends ProbeOverrides {
|
|
14
|
+
/** A `connect()` connection or a `Client`. */
|
|
15
|
+
readonly connection: PlanetScaleLikeConnection;
|
|
16
|
+
}
|
|
17
|
+
/** A probe that runs `select 1`; critical by default. The driver's `execute()` takes no `AbortSignal`, so a timed-out request is not cancelled. Throws `ProbeConfigError` without `execute()`. */
|
|
18
|
+
declare function planetscaleProbe(options: PlanetScaleProbeOptions): Probe;
|
|
19
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
20
|
+
//#endregion
|
|
21
|
+
export { PlanetScaleLikeConnection, PlanetScaleProbeOptions, planetscaleDefaultName, planetscaleProbe };
|
|
22
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;AAqCA;AAAgC,cAfnB,sBAAA,GAemB,UAAA;;AAAoC,UAZnD,yBAAA,CAYmD;EAAK;0BAV/C,YAAY;;;UAIrB,uBAAA,SAAgC;;uBAE1B;;;iBAIP,gBAAA,UAA0B,0BAA0B"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ProbeConfigError } from "@openstatus/health";
|
|
2
|
+
|
|
3
|
+
//#region src/mod.ts
|
|
4
|
+
/** Probe name when `name` is unset. */
|
|
5
|
+
const planetscaleDefaultName = "database";
|
|
6
|
+
/** A probe that runs `select 1`; critical by default. The driver's `execute()` takes no `AbortSignal`, so a timed-out request is not cancelled. Throws `ProbeConfigError` without `execute()`. */
|
|
7
|
+
function planetscaleProbe(options) {
|
|
8
|
+
const connection = options.connection;
|
|
9
|
+
if (typeof connection?.execute !== "function") throw new ProbeConfigError("planetscaleProbe", "connection", `must expose execute(), got ${describe(connection)}`);
|
|
10
|
+
return {
|
|
11
|
+
name: options.name ?? planetscaleDefaultName,
|
|
12
|
+
critical: options.critical ?? true,
|
|
13
|
+
timeoutMs: options.timeoutMs,
|
|
14
|
+
skip: options.skip,
|
|
15
|
+
run: async () => {
|
|
16
|
+
await connection.execute("select 1");
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function describe(connection) {
|
|
21
|
+
if (connection == null) return String(connection);
|
|
22
|
+
if (typeof connection !== "object") return typeof connection;
|
|
23
|
+
const keys = Object.keys(connection);
|
|
24
|
+
return keys.length === 0 ? "an object with no keys" : `an object with keys ${keys.slice(0, 8).join(", ")}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { planetscaleDefaultName, planetscaleProbe };
|
|
29
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","names":["options: PlanetScaleProbeOptions","connection: PlanetScaleLikeConnection"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * PlanetScale probe for `@openstatus/health`: runs `select 1` over the\n * serverless HTTP driver from `@planetscale/database`.\n *\n * ```ts\n * import { connect } from \"@planetscale/database\";\n * import { planetscaleProbe } from \"@openstatus/health-planetscale\";\n *\n * const probe = planetscaleProbe({ connection: connect({ url }) });\n * ```\n *\n * @module\n */\n\nimport {\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n type ProbeResult,\n} from \"@openstatus/health\";\n\n/** Probe name when `name` is unset. */\nexport const planetscaleDefaultName = \"database\";\n\n/** The subset of a `@planetscale/database` `Connection` or `Client` the probe uses. */\nexport interface PlanetScaleLikeConnection {\n /** Run one statement. */\n execute(query: string): PromiseLike<ProbeResult>;\n}\n\n/** Options for `planetscaleProbe()`. */\nexport interface PlanetScaleProbeOptions extends ProbeOverrides {\n /** A `connect()` connection or a `Client`. */\n readonly connection: PlanetScaleLikeConnection;\n}\n\n/** A probe that runs `select 1`; critical by default. The driver's `execute()` takes no `AbortSignal`, so a timed-out request is not cancelled. Throws `ProbeConfigError` without `execute()`. */\nexport function planetscaleProbe(options: PlanetScaleProbeOptions): Probe {\n const connection = options.connection;\n if (typeof connection?.execute !== \"function\") {\n throw new ProbeConfigError(\n \"planetscaleProbe\",\n \"connection\",\n `must expose execute(), got ${describe(connection)}`,\n );\n }\n return {\n name: options.name ?? planetscaleDefaultName,\n critical: options.critical ?? true,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: async () => {\n await connection.execute(\"select 1\");\n },\n };\n}\n\nfunction describe(connection: PlanetScaleLikeConnection): string {\n if (connection == null) return String(connection);\n if (typeof connection !== \"object\") return typeof connection;\n const keys = Object.keys(connection);\n return keys.length === 0\n ? \"an object with no keys\"\n : `an object with keys ${keys.slice(0, 8).join(\", \")}`;\n}\n"],"mappings":";;;;AAsBA,MAAa,yBAAyB;;AAetC,SAAgB,iBAAiBA,SAAyC;CACxE,MAAM,aAAa,QAAQ;AAC3B,YAAW,YAAY,YAAY,WACjC,OAAM,IAAI,iBACR,oBACA,eACC,6BAA6B,SAAS,WAAW,CAAC;AAGvD,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,YAAY;AACf,SAAM,WAAW,QAAQ,WAAW;EACrC;CACF;AACF;AAED,SAAS,SAASC,YAA+C;AAC/D,KAAI,cAAc,KAAM,QAAO,OAAO,WAAW;AACjD,YAAW,eAAe,SAAU,eAAc;CAClD,MAAM,OAAO,OAAO,KAAK,WAAW;AACpC,QAAO,KAAK,WAAW,IACnB,4BACC,sBAAsB,KAAK,MAAM,GAAG,EAAE,CAAC,KAAK,KAAK,CAAC;AACxD"}
|
package/package.json
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@openstatus/health-planetscale",
|
|
3
|
+
"version": "0.1.4-dev.0",
|
|
4
|
+
"description": "PlanetScale serverless driver probe for @openstatus/health",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"openstatus",
|
|
7
|
+
"health",
|
|
8
|
+
"healthcheck",
|
|
9
|
+
"planetscale",
|
|
10
|
+
"mysql",
|
|
11
|
+
"serverless",
|
|
12
|
+
"database"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "openstatus",
|
|
17
|
+
"url": "https://www.openstatus.dev/"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://github.com/openstatusHQ/health",
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/openstatusHQ/health.git",
|
|
23
|
+
"directory": "packages/planetscale/"
|
|
24
|
+
},
|
|
25
|
+
"bugs": {
|
|
26
|
+
"url": "https://github.com/openstatusHQ/health/issues"
|
|
27
|
+
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"module": "./dist/mod.js",
|
|
30
|
+
"main": "./dist/mod.cjs",
|
|
31
|
+
"types": "./dist/mod.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": {
|
|
35
|
+
"import": "./dist/mod.d.ts",
|
|
36
|
+
"require": "./dist/mod.d.cts"
|
|
37
|
+
},
|
|
38
|
+
"import": "./dist/mod.js",
|
|
39
|
+
"require": "./dist/mod.cjs"
|
|
40
|
+
},
|
|
41
|
+
"./package.json": "./package.json"
|
|
42
|
+
},
|
|
43
|
+
"sideEffects": false,
|
|
44
|
+
"files": [
|
|
45
|
+
"dist/"
|
|
46
|
+
],
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=22"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"@openstatus/health": "^0.1.4-dev.0",
|
|
52
|
+
"@planetscale/database": ">=1.0.0"
|
|
53
|
+
},
|
|
54
|
+
"peerDependenciesMeta": {
|
|
55
|
+
"@planetscale/database": {
|
|
56
|
+
"optional": true
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
"devDependencies": {
|
|
60
|
+
"@planetscale/database": "^1.19.0",
|
|
61
|
+
"tsdown": "^0.12.7",
|
|
62
|
+
"typescript": "^5.8.3"
|
|
63
|
+
},
|
|
64
|
+
"scripts": {
|
|
65
|
+
"build": "tsdown",
|
|
66
|
+
"prepack": "tsdown",
|
|
67
|
+
"test": "node --experimental-transform-types --test"
|
|
68
|
+
}
|
|
69
|
+
}
|