@healthzkit/minio 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/README.md ADDED
@@ -0,0 +1,132 @@
1
+ # @healthzkit/minio
2
+
3
+ MinIO health adapters for [healthzkit](https://healthzkit.dev). The adapter calls **`listBuckets()`** on the official **[`minio`](https://github.com/minio/minio-js)** client and returns **`ok`** with round-trip latency on success.
4
+
5
+ Install **`minio`** as a peer dependency (v7.1+ or v8).
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install healthzkit @healthzkit/minio minio
11
+ ```
12
+
13
+ The package is ESM-only (`"type": "module"`).
14
+
15
+ ## Quick start
16
+
17
+ ```ts
18
+ import { createHealthKit } from "healthzkit";
19
+ import { minioAdapter } from "@healthzkit/minio";
20
+
21
+ const kit = createHealthKit({
22
+ checks: [
23
+ {
24
+ name: "minio",
25
+ type: ["readiness"],
26
+ adapter: minioAdapter({
27
+ config: {
28
+ endPoint: process.env.MINIO_ENDPOINT ?? "localhost",
29
+ port: Number(process.env.MINIO_PORT ?? 9000),
30
+ useSSL: process.env.MINIO_USE_SSL === "true",
31
+ accessKey: process.env.MINIO_ACCESS_KEY!,
32
+ secretKey: process.env.MINIO_SECRET_KEY!,
33
+ },
34
+ }),
35
+ },
36
+ ],
37
+ });
38
+ ```
39
+
40
+ Use a subpath import when you want a dedicated entry for bundlers:
41
+
42
+ | Import | Exports |
43
+ | ------------------------- | -------------- |
44
+ | `@healthzkit/minio` | `minioAdapter` |
45
+ | `@healthzkit/minio/minio` | `minioAdapter` |
46
+
47
+ Both resolve to the same factory.
48
+
49
+ ## `minioAdapter`
50
+
51
+ **Peer:** `minio` >= 7.1.0 or >= 8.0.0.
52
+
53
+ Each check runs **`client.listBuckets()`** and records round-trip latency in **`metadata.latencyMs`**.
54
+
55
+ ### Config
56
+
57
+ Pass **`config`** as [`ClientOptions`](https://github.com/minio/minio-js/blob/master/docs/API.md#new-clientendpoint-port-usessl-accesskey-secretkey-region-transport-sessiontoken-partsize) for the official client. The adapter lazily imports **`minio`**, creates a shared **`Client`**, and reuses it across checks.
58
+
59
+ ```ts
60
+ import { minioAdapter } from "@healthzkit/minio";
61
+
62
+ const adapter = minioAdapter({
63
+ config: {
64
+ endPoint: "localhost",
65
+ port: 9000,
66
+ useSSL: false,
67
+ accessKey: "minioadmin",
68
+ secretKey: "minioadmin",
69
+ },
70
+ });
71
+ ```
72
+
73
+ ### Existing client
74
+
75
+ Pass **`client`** as an existing **`Client`** instance. The adapter reuses that client across checks (no internal lifecycle management).
76
+
77
+ ```ts
78
+ import { Client } from "minio";
79
+ import { minioAdapter } from "@healthzkit/minio/minio";
80
+
81
+ const client = new Client({
82
+ endPoint: process.env.MINIO_ENDPOINT!,
83
+ port: 9000,
84
+ useSSL: false,
85
+ accessKey: process.env.MINIO_ACCESS_KEY!,
86
+ secretKey: process.env.MINIO_SECRET_KEY!,
87
+ });
88
+
89
+ const adapter = minioAdapter({
90
+ client,
91
+ metadata: () => ({ endpoint: process.env.MINIO_ENDPOINT }),
92
+ });
93
+ ```
94
+
95
+ Provide **`config`** or **`client`**, not both.
96
+
97
+ ## Options
98
+
99
+ | Option | Description |
100
+ | -------------- | ----------------------------------------------------------------------------------------------------- |
101
+ | **`config`** | `ClientOptions` for a lazily created client. |
102
+ | **`client`** | Existing `minio` `Client`. |
103
+ | **`metadata`** | Optional `(client) => Record<string, unknown>` (sync or async) merged into metadata with `latencyMs`. |
104
+
105
+ ## Check result
106
+
107
+ On success:
108
+
109
+ ```json
110
+ {
111
+ "status": "ok",
112
+ "metadata": { "latencyMs": 24 }
113
+ }
114
+ ```
115
+
116
+ On failure, `status` is **`fail`** and `error` is set (see [healthzkit](https://healthzkit.dev) for how that rolls up into probe responses).
117
+
118
+ ## Scheduling
119
+
120
+ For object storage that should not be queried on every probe, pair this adapter with a **`schedule`** on the check so readiness reads cached results. See the **Scheduling** section in the `healthzkit` README.
121
+
122
+ ## Development (this repo)
123
+
124
+ From the package directory:
125
+
126
+ ```bash
127
+ vp install
128
+ vp test
129
+ vp pack
130
+ ```
131
+
132
+ See the repo root `AGENTS.md` for Vite+ / `vp` conventions.
@@ -0,0 +1,2 @@
1
+ import { i as minioAdapter, t as MinioAdapterOptions } from "./minio-CA-ZkiEM.mjs";
2
+ export { type MinioAdapterOptions, minioAdapter };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{t as e}from"./minio-DICU8kyF.mjs";export{e as minioAdapter};
@@ -0,0 +1,26 @@
1
+ import { Client, ClientOptions } from "minio";
2
+ import { HealthAdapter } from "healthzkit";
3
+
4
+ //#region src/shared.d.ts
5
+ type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>> | Record<string, unknown>;
6
+ interface BaseMinioOptions<TClient> {
7
+ /**
8
+ * Optional function to populate metadata in the check result.
9
+ * Receives the resolved client so you can run additional operations.
10
+ */
11
+ metadata?: MetadataFn<TClient>;
12
+ }
13
+ //#endregion
14
+ //#region src/minio.d.ts
15
+ interface MinioAdapterOptionsWithClient extends BaseMinioOptions<Client> {
16
+ client: Client;
17
+ config?: never;
18
+ }
19
+ interface MinioAdapterOptionsWithConfig extends BaseMinioOptions<Client> {
20
+ config: ClientOptions;
21
+ client?: never;
22
+ }
23
+ type MinioAdapterOptions = MinioAdapterOptionsWithClient | MinioAdapterOptionsWithConfig;
24
+ declare function minioAdapter(options: MinioAdapterOptions): HealthAdapter;
25
+ //#endregion
26
+ export { minioAdapter as i, MinioAdapterOptionsWithClient as n, MinioAdapterOptionsWithConfig as r, MinioAdapterOptions as t };
@@ -0,0 +1 @@
1
+ function e(e,t){return{status:`ok`,metadata:{...t,latencyMs:e}}}function t(e){return{status:`fail`,error:e instanceof Error?e:Error(String(e))}}function n(n){let r=null,i=null;async function a(){return`client`in n&&n.client?n.client:r||(i||=(async()=>{try{let{Client:e}=await import(`minio`),t=new e(n.config);return r=t,t}finally{i=null}})(),i)}return{async check(){try{let t=await a(),r=Date.now();await t.listBuckets();let i=Date.now()-r,o=n.metadata?n.metadata(t):void 0;return e(i,o instanceof Promise?await o:o)}catch(e){return t(e)}}}}export{n as t};
@@ -0,0 +1,2 @@
1
+ import { i as minioAdapter, n as MinioAdapterOptionsWithClient, r as MinioAdapterOptionsWithConfig, t as MinioAdapterOptions } from "./minio-CA-ZkiEM.mjs";
2
+ export { MinioAdapterOptions, MinioAdapterOptionsWithClient, MinioAdapterOptionsWithConfig, minioAdapter };
package/dist/minio.mjs ADDED
@@ -0,0 +1 @@
1
+ import{t as e}from"./minio-DICU8kyF.mjs";export{e as minioAdapter};
package/package.json ADDED
@@ -0,0 +1,46 @@
1
+ {
2
+ "name": "@healthzkit/minio",
3
+ "version": "0.0.1",
4
+ "license": "AGPL-3.0-only",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alasti-company/healthzkit.dev",
8
+ "directory": "packages/minio"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "type": "module",
14
+ "exports": {
15
+ ".": "./dist/index.mjs",
16
+ "./minio": "./dist/minio.mjs",
17
+ "./package.json": "./package.json"
18
+ },
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "scripts": {
23
+ "build": "vp pack",
24
+ "dev": "vp pack --watch",
25
+ "test": "vp test",
26
+ "check": "vp check",
27
+ "prepublishOnly": "vp run build"
28
+ },
29
+ "devDependencies": {
30
+ "@types/node": "^25.6.2",
31
+ "@typescript/native-preview": "7.0.0-dev.20260509.2",
32
+ "bumpp": "^11.1.0",
33
+ "healthzkit": "workspace:*",
34
+ "minio": "8.0.7",
35
+ "typescript": "^6.0.3",
36
+ "vite-plus": "^0.1.20"
37
+ },
38
+ "peerDependencies": {
39
+ "minio": ">=7.1.0 || >=8.0.0"
40
+ },
41
+ "peerDependenciesMeta": {
42
+ "minio": {
43
+ "optional": false
44
+ }
45
+ }
46
+ }