@openstatus/health-meilisearch 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 ADDED
@@ -0,0 +1,76 @@
1
+ # @openstatus/health-meilisearch
2
+
3
+ [Meilisearch](https://www.meilisearch.com/) probe for
4
+ [`@openstatus/health`](https://jsr.io/@openstatus/health). Sends
5
+ `GET {host}/health` and fails the check unless the instance answers 2xx
6
+ with `{ "status": "available" }` — with `fetch` alone, on every runtime,
7
+ against Meilisearch Cloud or your own instance.
8
+
9
+ ```sh
10
+ deno add jsr:@openstatus/health jsr:@openstatus/health-meilisearch
11
+ npm install @openstatus/health @openstatus/health-meilisearch
12
+ ```
13
+
14
+ ```ts
15
+ import { createHealthHandler, readEnv } from "@openstatus/health";
16
+ import { meilisearchProbe } from "@openstatus/health-meilisearch";
17
+
18
+ const host = readEnv("MEILISEARCH_HOST");
19
+
20
+ Deno.serve(
21
+ createHealthHandler({
22
+ probes: [
23
+ // the factory validates `host` at construction, so pass a placeholder
24
+ // and let `skip` keep the unconfigured check from running.
25
+ meilisearchProbe({
26
+ host: host ?? "http://localhost:7700",
27
+ skip: () => host == null,
28
+ }),
29
+ ],
30
+ }),
31
+ );
32
+ ```
33
+
34
+ `host` is the instance URL — `https://ms-xxx.meilisearch.io` on Cloud or
35
+ `http://localhost:7700` locally. `/health` is the endpoint Meilisearch
36
+ documents for exactly this: it needs no API key, has no side effects and
37
+ answers `available` only once the instance is ready to serve. Pass `apiKey`
38
+ to send one anyway when a proxy in front of the instance requires it. Like
39
+ every probe here, this one never reads the environment itself — pass the
40
+ values in, and use `skip` for environments where Meilisearch is not
41
+ configured.
42
+
43
+ ```ts
44
+ meilisearchProbe({
45
+ host,
46
+ apiKey: env.MEILISEARCH_API_KEY,
47
+ // optional overrides from the Probe contract
48
+ name: "meili",
49
+ critical: true,
50
+ timeoutMs: 1000,
51
+ skip: () => env.MEILISEARCH_HOST == null,
52
+ });
53
+ ```
54
+
55
+ Non-critical by default: search is usually one feature of a service rather
56
+ than its request path, so an outage degrades the report instead of taking
57
+ the service out of rotation. Set `critical: true` when requests cannot be
58
+ served without it.
59
+
60
+ ## About openstatus
61
+
62
+ [openstatus](https://www.openstatus.dev/) is the open-source uptime monitoring
63
+ and status page platform. This package is part of
64
+ [`@openstatus/health`](https://github.com/openstatusHQ/health), the `/health`
65
+ endpoints behind openstatus's own services, extracted so any JavaScript server
66
+ can expose one. Point an
67
+ [openstatus monitor](https://www.openstatus.dev/docs/reference/http-monitor)
68
+ at the endpoint and assert on `status` in the body to be alerted on
69
+ `degraded` before it becomes `unhealthy`.
70
+
71
+ Source: [github.com/openstatusHQ/health](https://github.com/openstatusHQ/health).
72
+ Issues and PRs welcome.
73
+
74
+ ## License
75
+
76
+ [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,42 @@
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 meilisearchDefaultName = "search";
7
+ /** A probe that expects `GET {host}/health` to answer 2xx with `status: "available"`; non-critical by default. Throws `ProbeConfigError` for an invalid `host` or an empty `apiKey`. */
8
+ function meilisearchProbe(options) {
9
+ const doFetch = options.fetch ?? globalThis.fetch;
10
+ const url = (0, __openstatus_health.probeUrl)({
11
+ probe: "meilisearchProbe",
12
+ field: "host",
13
+ value: options.host,
14
+ path: "/health"
15
+ });
16
+ if (options.apiKey != null && options.apiKey.length === 0) throw new __openstatus_health.ProbeConfigError("meilisearchProbe", "apiKey", "must not be empty");
17
+ const headers = options.apiKey == null ? void 0 : { authorization: `Bearer ${options.apiKey}` };
18
+ return {
19
+ name: options.name ?? meilisearchDefaultName,
20
+ critical: options.critical ?? false,
21
+ timeoutMs: options.timeoutMs,
22
+ skip: options.skip,
23
+ run: async (signal) => {
24
+ const res = await doFetch(url, {
25
+ method: "GET",
26
+ headers,
27
+ signal
28
+ });
29
+ if (!res.ok) {
30
+ await res.body?.cancel();
31
+ throw new Error(`unexpected status ${res.status}`);
32
+ }
33
+ const body = await res.json().catch(() => null);
34
+ const status = body?.status;
35
+ if (status !== "available") throw new Error(`unexpected health status ${JSON.stringify(status)}`);
36
+ }
37
+ };
38
+ }
39
+
40
+ //#endregion
41
+ exports.meilisearchDefaultName = meilisearchDefaultName;
42
+ exports.meilisearchProbe = meilisearchProbe;
package/dist/mod.d.cts ADDED
@@ -0,0 +1,21 @@
1
+ import { Probe, ProbeOverrides } from "@openstatus/health";
2
+
3
+ //#region src/mod.d.ts
4
+
5
+ /** Probe name when `name` is unset. */
6
+ declare const meilisearchDefaultName = "search";
7
+ /** Options for `meilisearchProbe()`. */
8
+ interface MeilisearchProbeOptions extends ProbeOverrides {
9
+ /** The instance URL, e.g. `https://ms-xxx.meilisearch.io` or `http://localhost:7700`. */
10
+ readonly host: string | URL;
11
+ /** An API key, sent as a bearer token. `/health` does not need one. */
12
+ readonly apiKey?: string;
13
+ /** Replacement `fetch`, for tests. */
14
+ readonly fetch?: typeof fetch;
15
+ }
16
+ /** A probe that expects `GET {host}/health` to answer 2xx with `status: "available"`; non-critical by default. Throws `ProbeConfigError` for an invalid `host` or an empty `apiKey`. */
17
+ declare function meilisearchProbe(options: MeilisearchProbeOptions): Probe;
18
+ //# sourceMappingURL=mod.d.ts.map
19
+ //#endregion
20
+ export { MeilisearchProbeOptions, meilisearchDefaultName, meilisearchProbe };
21
+ //# sourceMappingURL=mod.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAkCyE,cAb5D,sBAAA,GAa4D,QAAA;;UAVxD,uBAAA,SAAgC;;0BAEvB;;;;0BAIA;;;iBAIV,gBAAA,UAA0B,0BAA0B"}
package/dist/mod.d.ts ADDED
@@ -0,0 +1,21 @@
1
+ import { Probe, ProbeOverrides } from "@openstatus/health";
2
+
3
+ //#region src/mod.d.ts
4
+
5
+ /** Probe name when `name` is unset. */
6
+ declare const meilisearchDefaultName = "search";
7
+ /** Options for `meilisearchProbe()`. */
8
+ interface MeilisearchProbeOptions extends ProbeOverrides {
9
+ /** The instance URL, e.g. `https://ms-xxx.meilisearch.io` or `http://localhost:7700`. */
10
+ readonly host: string | URL;
11
+ /** An API key, sent as a bearer token. `/health` does not need one. */
12
+ readonly apiKey?: string;
13
+ /** Replacement `fetch`, for tests. */
14
+ readonly fetch?: typeof fetch;
15
+ }
16
+ /** A probe that expects `GET {host}/health` to answer 2xx with `status: "available"`; non-critical by default. Throws `ProbeConfigError` for an invalid `host` or an empty `apiKey`. */
17
+ declare function meilisearchProbe(options: MeilisearchProbeOptions): Probe;
18
+ //# sourceMappingURL=mod.d.ts.map
19
+ //#endregion
20
+ export { MeilisearchProbeOptions, meilisearchDefaultName, meilisearchProbe };
21
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;AAkCyE,cAb5D,sBAAA,GAa4D,QAAA;;UAVxD,uBAAA,SAAgC;;0BAEvB;;;;0BAIA;;;iBAIV,gBAAA,UAA0B,0BAA0B"}
package/dist/mod.js ADDED
@@ -0,0 +1,41 @@
1
+ import { ProbeConfigError, probeUrl } from "@openstatus/health";
2
+
3
+ //#region src/mod.ts
4
+ /** Probe name when `name` is unset. */
5
+ const meilisearchDefaultName = "search";
6
+ /** A probe that expects `GET {host}/health` to answer 2xx with `status: "available"`; non-critical by default. Throws `ProbeConfigError` for an invalid `host` or an empty `apiKey`. */
7
+ function meilisearchProbe(options) {
8
+ const doFetch = options.fetch ?? globalThis.fetch;
9
+ const url = probeUrl({
10
+ probe: "meilisearchProbe",
11
+ field: "host",
12
+ value: options.host,
13
+ path: "/health"
14
+ });
15
+ if (options.apiKey != null && options.apiKey.length === 0) throw new ProbeConfigError("meilisearchProbe", "apiKey", "must not be empty");
16
+ const headers = options.apiKey == null ? void 0 : { authorization: `Bearer ${options.apiKey}` };
17
+ return {
18
+ name: options.name ?? meilisearchDefaultName,
19
+ critical: options.critical ?? false,
20
+ timeoutMs: options.timeoutMs,
21
+ skip: options.skip,
22
+ run: async (signal) => {
23
+ const res = await doFetch(url, {
24
+ method: "GET",
25
+ headers,
26
+ signal
27
+ });
28
+ if (!res.ok) {
29
+ await res.body?.cancel();
30
+ throw new Error(`unexpected status ${res.status}`);
31
+ }
32
+ const body = await res.json().catch(() => null);
33
+ const status = body?.status;
34
+ if (status !== "available") throw new Error(`unexpected health status ${JSON.stringify(status)}`);
35
+ }
36
+ };
37
+ }
38
+
39
+ //#endregion
40
+ export { meilisearchDefaultName, meilisearchProbe };
41
+ //# sourceMappingURL=mod.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.js","names":["options: MeilisearchProbeOptions","body: { readonly status?: string } | null"],"sources":["../src/mod.ts"],"sourcesContent":["/**\n * Meilisearch probe for `@openstatus/health`, against `/health`, which must\n * report `status: \"available\"`.\n *\n * ```ts\n * import { meilisearchProbe } from \"@openstatus/health-meilisearch\";\n *\n * const probe = meilisearchProbe({ host: env.MEILISEARCH_HOST });\n * ```\n *\n * @module\n */\n\nimport {\n type Probe,\n ProbeConfigError,\n type ProbeOverrides,\n probeUrl,\n} from \"@openstatus/health\";\n\n/** Probe name when `name` is unset. */\nexport const meilisearchDefaultName = \"search\";\n\n/** Options for `meilisearchProbe()`. */\nexport interface MeilisearchProbeOptions extends ProbeOverrides {\n /** The instance URL, e.g. `https://ms-xxx.meilisearch.io` or `http://localhost:7700`. */\n readonly host: string | URL;\n /** An API key, sent as a bearer token. `/health` does not need one. */\n readonly apiKey?: string;\n /** Replacement `fetch`, for tests. */\n readonly fetch?: typeof fetch;\n}\n\n/** A probe that expects `GET {host}/health` to answer 2xx with `status: \"available\"`; non-critical by default. Throws `ProbeConfigError` for an invalid `host` or an empty `apiKey`. */\nexport function meilisearchProbe(options: MeilisearchProbeOptions): Probe {\n const doFetch = options.fetch ?? globalThis.fetch;\n const url = probeUrl({\n probe: \"meilisearchProbe\",\n field: \"host\",\n value: options.host,\n path: \"/health\",\n });\n if (options.apiKey != null && options.apiKey.length === 0) {\n throw new ProbeConfigError(\n \"meilisearchProbe\",\n \"apiKey\",\n \"must not be empty\",\n );\n }\n const headers = options.apiKey == null\n ? undefined\n : { authorization: `Bearer ${options.apiKey}` };\n return {\n name: options.name ?? meilisearchDefaultName,\n critical: options.critical ?? false,\n timeoutMs: options.timeoutMs,\n skip: options.skip,\n run: async (signal) => {\n const res = await doFetch(url, { method: \"GET\", headers, signal });\n if (!res.ok) {\n await res.body?.cancel();\n throw new Error(`unexpected status ${res.status}`);\n }\n const body: { readonly status?: string } | null = await res.json()\n .catch(() => null);\n const status = body?.status;\n if (status !== \"available\") {\n throw new Error(`unexpected health status ${JSON.stringify(status)}`);\n }\n },\n };\n}\n"],"mappings":";;;;AAqBA,MAAa,yBAAyB;;AAatC,SAAgB,iBAAiBA,SAAyC;CACxE,MAAM,UAAU,QAAQ,SAAS,WAAW;CAC5C,MAAM,MAAM,SAAS;EACnB,OAAO;EACP,OAAO;EACP,OAAO,QAAQ;EACf,MAAM;CACP,EAAC;AACF,KAAI,QAAQ,UAAU,QAAQ,QAAQ,OAAO,WAAW,EACtD,OAAM,IAAI,iBACR,oBACA,UACA;CAGJ,MAAM,UAAU,QAAQ,UAAU,gBAE9B,EAAE,gBAAgB,SAAS,QAAQ,OAAO,EAAG;AACjD,QAAO;EACL,MAAM,QAAQ,QAAQ;EACtB,UAAU,QAAQ,YAAY;EAC9B,WAAW,QAAQ;EACnB,MAAM,QAAQ;EACd,KAAK,OAAO,WAAW;GACrB,MAAM,MAAM,MAAM,QAAQ,KAAK;IAAE,QAAQ;IAAO;IAAS;GAAQ,EAAC;AAClE,QAAK,IAAI,IAAI;AACX,UAAM,IAAI,MAAM,QAAQ;AACxB,UAAM,IAAI,OAAO,oBAAoB,IAAI,OAAO;GACjD;GACD,MAAMC,OAA4C,MAAM,IAAI,MAAM,CAC/D,MAAM,MAAM,KAAK;GACpB,MAAM,SAAS,MAAM;AACrB,OAAI,WAAW,YACb,OAAM,IAAI,OAAO,2BAA2B,KAAK,UAAU,OAAO,CAAC;EAEtE;CACF;AACF"}
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@openstatus/health-meilisearch",
3
+ "version": "0.1.4-dev.0",
4
+ "description": "Meilisearch probe for @openstatus/health",
5
+ "keywords": [
6
+ "openstatus",
7
+ "health",
8
+ "healthcheck",
9
+ "meilisearch",
10
+ "search"
11
+ ],
12
+ "license": "MIT",
13
+ "author": {
14
+ "name": "openstatus",
15
+ "url": "https://www.openstatus.dev/"
16
+ },
17
+ "homepage": "https://github.com/openstatusHQ/health",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/openstatusHQ/health.git",
21
+ "directory": "packages/meilisearch/"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/openstatusHQ/health/issues"
25
+ },
26
+ "type": "module",
27
+ "module": "./dist/mod.js",
28
+ "main": "./dist/mod.cjs",
29
+ "types": "./dist/mod.d.ts",
30
+ "exports": {
31
+ ".": {
32
+ "types": {
33
+ "import": "./dist/mod.d.ts",
34
+ "require": "./dist/mod.d.cts"
35
+ },
36
+ "import": "./dist/mod.js",
37
+ "require": "./dist/mod.cjs"
38
+ },
39
+ "./package.json": "./package.json"
40
+ },
41
+ "sideEffects": false,
42
+ "files": [
43
+ "dist/"
44
+ ],
45
+ "engines": {
46
+ "node": ">=22"
47
+ },
48
+ "peerDependencies": {
49
+ "@openstatus/health": "^0.1.4-dev.0"
50
+ },
51
+ "devDependencies": {
52
+ "tsdown": "^0.12.7",
53
+ "typescript": "^5.8.3"
54
+ },
55
+ "scripts": {
56
+ "build": "tsdown",
57
+ "prepack": "tsdown",
58
+ "test": "node --experimental-transform-types --test"
59
+ }
60
+ }