@healthzkit/redis 0.0.2 → 0.0.4
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/ioredis.d.mts +1 -1
- package/dist/ioredis.mjs +1 -1
- package/dist/redis.d.mts +1 -1
- package/dist/redis.mjs +1 -1
- package/dist/shared-DNaBfhKs.d.mts +17 -0
- package/dist/shared-DTLVNl-N.mjs +1 -0
- package/dist/upstash.d.mts +1 -1
- package/dist/upstash.mjs +1 -1
- package/package.json +8 -5
- package/dist/shared-BA6-D1db.mjs +0 -1
- package/dist/shared-Bt0JlNBM.d.mts +0 -28
package/dist/ioredis.d.mts
CHANGED
package/dist/ioredis.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./shared-
|
|
1
|
+
import{n as e,r as t}from"./shared-DTLVNl-N.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{Redis:e}=await import(`ioredis`);r=new e(n.connectionString,{maxRetriesPerRequest:1,enableReadyCheck:!1,...n.redisOptions})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`ioredisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let e=await i(),r=Date.now();await e.call(n.command??`PING`);let a=Date.now()-r,o=n.metadata?n.metadata(e):void 0;return t(a,o instanceof Promise?await o:o)}catch(t){return e(t)}}}}export{n as ioredisAdapter};
|
package/dist/redis.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-
|
|
1
|
+
import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-DNaBfhKs.mjs";
|
|
2
2
|
import { RedisClientOptions, RedisClientType, RespVersions } from "redis";
|
|
3
3
|
|
|
4
4
|
//#region src/redis.d.ts
|
package/dist/redis.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./shared-
|
|
1
|
+
import{n as e,r as t}from"./shared-DTLVNl-N.mjs";function n(n){let r=null;async function i(){if(`connectionString`in n&&n.connectionString){if(!r){let{createClient:e}=await import(`redis`),t=e({url:n.connectionString,...n.redisOptions});await t.connect(),r=t}return r}if(`client`in n&&n.client!==void 0){let e=n.client;return e.isOpen||await e.connect(),e}throw Error(`nodeRedisAdapter: provide a non-empty connectionString or a client`)}return{async check(){try{let e=await i(),r=Date.now();await e.sendCommand((n.command??`PING`).split(` `));let a=Date.now()-r,o=n.metadata?n.metadata(e):void 0;return t(a,o instanceof Promise?await o:o)}catch(t){return e(t)}}}}export{n as nodeRedisAdapter};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { HealthAdapter, MetadataFn } from "@healthzkit/shared";
|
|
2
|
+
|
|
3
|
+
//#region src/shared.d.ts
|
|
4
|
+
interface BaseRedisOptions<TClient> {
|
|
5
|
+
/**
|
|
6
|
+
* Command to run as the healthcheck.
|
|
7
|
+
* @default "PING"
|
|
8
|
+
*/
|
|
9
|
+
command?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Optional function to populate metadata in the check result.
|
|
12
|
+
* Receives the resolved client so you can run additional commands.
|
|
13
|
+
*/
|
|
14
|
+
metadata?: MetadataFn<TClient>;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
export { HealthAdapter as n, BaseRedisOptions as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buildErrorResult as e,buildResult as t}from"@healthzkit/shared";const n=`PING`;export{e as n,t as r,n as t};
|
package/dist/upstash.d.mts
CHANGED
package/dist/upstash.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as e,r as t}from"./shared-
|
|
1
|
+
import{n as e,r as t}from"./shared-DTLVNl-N.mjs";function n(n){let r=null;async function i(){if(`url`in n&&n.url){if(!r){let{Redis:e}=await import(`@upstash/redis`);r=new e({url:n.url,token:n.token})}return r}if(`client`in n&&n.client!==void 0)return n.client;throw Error(`upstashAdapter: provide url and token, or a client`)}return{async check(){try{let e=await i(),r=Date.now();if(n.command&&n.command!==`PING`){let[t,...r]=n.command.split(` `);await e.exec([t,...r])}else await e.ping();let a=Date.now()-r,o=n.metadata?n.metadata(e):void 0;return t(a,o instanceof Promise?await o:o)}catch(t){return e(t)}}}}export{n as upstashAdapter};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@healthzkit/redis",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,16 +21,19 @@
|
|
|
21
21
|
"publishConfig": {
|
|
22
22
|
"access": "public"
|
|
23
23
|
},
|
|
24
|
+
"dependencies": {
|
|
25
|
+
"@healthzkit/shared": "0.0.0"
|
|
26
|
+
},
|
|
24
27
|
"devDependencies": {
|
|
25
|
-
"@types/node": "^
|
|
28
|
+
"@types/node": "^24",
|
|
26
29
|
"@typescript/native-preview": "7.0.0-dev.20260328.1",
|
|
27
30
|
"@upstash/redis": "^1.38.0",
|
|
28
31
|
"bumpp": "^11.0.1",
|
|
29
32
|
"ioredis": "^5.10.1",
|
|
30
33
|
"redis": "^5.12.1",
|
|
31
|
-
"typescript": "^
|
|
32
|
-
"vite-plus": "
|
|
33
|
-
"healthzkit": "0.0.
|
|
34
|
+
"typescript": "^5",
|
|
35
|
+
"vite-plus": "latest",
|
|
36
|
+
"healthzkit": "0.0.3"
|
|
34
37
|
},
|
|
35
38
|
"peerDependencies": {
|
|
36
39
|
"@upstash/redis": ">=1.0.0",
|
package/dist/shared-BA6-D1db.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const e=`PING`;function t(e,t){return{status:`ok`,metadata:{latencyMs:e,...t}}}function n(e){return{status:`fail`,error:e instanceof Error?e:Error(String(e))}}export{n,t as r,e as t};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
//#region ../healthzkit/dist/index.d.mts
|
|
2
|
-
//#region src/types.d.ts
|
|
3
|
-
type CheckStatus = "ok" | "degraded" | "fail";
|
|
4
|
-
interface AdapterResult {
|
|
5
|
-
status: CheckStatus;
|
|
6
|
-
error?: Error | string;
|
|
7
|
-
metadata?: Record<string, unknown>;
|
|
8
|
-
}
|
|
9
|
-
interface HealthAdapter {
|
|
10
|
-
check(): Promise<AdapterResult>;
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/shared.d.ts
|
|
14
|
-
type MetadataFn<TClient> = (client: TClient) => Promise<Record<string, unknown>>;
|
|
15
|
-
interface BaseRedisOptions<TClient> {
|
|
16
|
-
/**
|
|
17
|
-
* Command to run as the healthcheck.
|
|
18
|
-
* @default "PING"
|
|
19
|
-
*/
|
|
20
|
-
command?: string;
|
|
21
|
-
/**
|
|
22
|
-
* Optional function to populate metadata in the check result.
|
|
23
|
-
* Receives the resolved client so you can run additional commands.
|
|
24
|
-
*/
|
|
25
|
-
metadata?: MetadataFn<TClient>;
|
|
26
|
-
}
|
|
27
|
-
//#endregion
|
|
28
|
-
export { HealthAdapter as n, BaseRedisOptions as t };
|