@healthzkit/redis 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,23 @@
1
+ # vite-plus-starter
2
+
3
+ A starter for creating a Vite Plus project.
4
+
5
+ ## Development
6
+
7
+ - Install dependencies:
8
+
9
+ ```bash
10
+ vp install
11
+ ```
12
+
13
+ - Run the unit tests:
14
+
15
+ ```bash
16
+ vp test
17
+ ```
18
+
19
+ - Build the library:
20
+
21
+ ```bash
22
+ vp pack
23
+ ```
@@ -0,0 +1,4 @@
1
+ import { IoRedisAdapterOptions, ioredisAdapter } from "./ioredis.mjs";
2
+ import { NodeRedisAdapterOptions, nodeRedisAdapter } from "./redis.mjs";
3
+ import { UpstashAdapterOptions, upstashAdapter } from "./upstash.mjs";
4
+ export { type IoRedisAdapterOptions, type NodeRedisAdapterOptions, type UpstashAdapterOptions, ioredisAdapter, nodeRedisAdapter, upstashAdapter };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{ioredisAdapter as e}from"./ioredis.mjs";import{nodeRedisAdapter as t}from"./redis.mjs";import{upstashAdapter as n}from"./upstash.mjs";export{e as ioredisAdapter,t as nodeRedisAdapter,n as upstashAdapter};
@@ -0,0 +1,18 @@
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
2
+ import { Redis, RedisOptions } from "ioredis";
3
+
4
+ //#region src/ioredis.d.ts
5
+ interface IoRedisAdapterOptionsWithClient extends BaseRedisOptions<Redis> {
6
+ client: Redis;
7
+ connectionString?: never;
8
+ redisOptions?: never;
9
+ }
10
+ interface IoRedisAdapterOptionsWithConnectionString extends BaseRedisOptions<Redis> {
11
+ connectionString: string;
12
+ redisOptions?: RedisOptions;
13
+ client?: never;
14
+ }
15
+ type IoRedisAdapterOptions = IoRedisAdapterOptionsWithClient | IoRedisAdapterOptionsWithConnectionString;
16
+ declare function ioredisAdapter(options: IoRedisAdapterOptions): HealthAdapter;
17
+ //#endregion
18
+ export { IoRedisAdapterOptions, IoRedisAdapterOptionsWithClient, IoRedisAdapterOptionsWithConnectionString, ioredisAdapter };
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./shared-BA6-D1db.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();return await e.call(n.command??`PING`),t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as ioredisAdapter};
@@ -0,0 +1,19 @@
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
2
+ import { RedisClientOptions, RedisClientType, RespVersions } from "redis";
3
+
4
+ //#region src/redis.d.ts
5
+ type NodeRedisClient = Pick<RedisClientType<any, any, any, RespVersions>, "sendCommand" | "isOpen" | "connect">;
6
+ interface NodeRedisAdapterOptionsWithClient extends BaseRedisOptions<NodeRedisClient> {
7
+ client: NodeRedisClient;
8
+ connectionString?: never;
9
+ redisOptions?: never;
10
+ }
11
+ interface NodeRedisAdapterOptionsWithConnectionString extends BaseRedisOptions<NodeRedisClient> {
12
+ connectionString: string;
13
+ redisOptions?: RedisClientOptions;
14
+ client?: never;
15
+ }
16
+ type NodeRedisAdapterOptions = NodeRedisAdapterOptionsWithClient | NodeRedisAdapterOptionsWithConnectionString;
17
+ declare function nodeRedisAdapter(options: NodeRedisAdapterOptions): HealthAdapter;
18
+ //#endregion
19
+ export { NodeRedisAdapterOptions, NodeRedisAdapterOptionsWithClient, NodeRedisAdapterOptionsWithConnectionString, nodeRedisAdapter };
package/dist/redis.mjs ADDED
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./shared-BA6-D1db.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();return await e.sendCommand((n.command??`PING`).split(` `)),t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as nodeRedisAdapter};
@@ -0,0 +1 @@
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};
@@ -0,0 +1,28 @@
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 };
@@ -0,0 +1,18 @@
1
+ import { n as HealthAdapter, t as BaseRedisOptions } from "./shared-Bt0JlNBM.mjs";
2
+ import { Redis } from "@upstash/redis";
3
+
4
+ //#region src/upstash.d.ts
5
+ interface UpstashAdapterOptionsWithClient extends BaseRedisOptions<Redis> {
6
+ client: Redis;
7
+ url?: never;
8
+ token?: never;
9
+ }
10
+ interface UpstashAdapterOptionsWithCredentials extends BaseRedisOptions<Redis> {
11
+ url: string;
12
+ token: string;
13
+ client?: never;
14
+ }
15
+ type UpstashAdapterOptions = UpstashAdapterOptionsWithClient | UpstashAdapterOptionsWithCredentials;
16
+ declare function upstashAdapter(options: UpstashAdapterOptions): HealthAdapter;
17
+ //#endregion
18
+ export { UpstashAdapterOptions, UpstashAdapterOptionsWithClient, UpstashAdapterOptionsWithCredentials, upstashAdapter };
@@ -0,0 +1 @@
1
+ import{n as e,r as t}from"./shared-BA6-D1db.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();return t(Date.now()-r,n.metadata?await n.metadata(e):void 0)}catch(t){return e(t)}}}}export{n as upstashAdapter};
package/package.json ADDED
@@ -0,0 +1,51 @@
1
+ {
2
+ "name": "@healthzkit/redis",
3
+ "version": "0.0.1",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "type": "module",
8
+ "exports": {
9
+ ".": "./dist/index.mjs",
10
+ "./ioredis": "./dist/ioredis.mjs",
11
+ "./redis": "./dist/redis.mjs",
12
+ "./upstash": "./dist/upstash.mjs",
13
+ "./package.json": "./package.json"
14
+ },
15
+ "publishConfig": {
16
+ "access": "public"
17
+ },
18
+ "devDependencies": {
19
+ "@types/node": "^25.5.0",
20
+ "@typescript/native-preview": "7.0.0-dev.20260328.1",
21
+ "@upstash/redis": "^1.38.0",
22
+ "bumpp": "^11.0.1",
23
+ "ioredis": "^5.10.1",
24
+ "redis": "^5.12.1",
25
+ "typescript": "^6.0.2",
26
+ "vite-plus": "^0.1.14",
27
+ "healthzkit": "0.0.1"
28
+ },
29
+ "peerDependencies": {
30
+ "@upstash/redis": ">=1.0.0",
31
+ "ioredis": ">=5.0.0",
32
+ "redis": ">=4.0.0"
33
+ },
34
+ "peerDependenciesMeta": {
35
+ "ioredis": {
36
+ "optional": true
37
+ },
38
+ "redis": {
39
+ "optional": true
40
+ },
41
+ "@upstash/redis": {
42
+ "optional": true
43
+ }
44
+ },
45
+ "scripts": {
46
+ "build": "vp pack",
47
+ "dev": "vp pack --watch",
48
+ "test": "vp test",
49
+ "check": "vp check"
50
+ }
51
+ }