@declaro/redis 2.0.0-beta.39 → 2.0.0-beta.41

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.
@@ -0,0 +1 @@
1
+ export {};
@@ -18,4 +18,4 @@ export declare function sendMessage<T = string>(context: Context, channel: strin
18
18
  * @param messageHandler A function to run whenever messages are received
19
19
  * @returns A dedicated connection to handle the subscription on. NOTE: Close this connection to unsubscribe.
20
20
  */
21
- export declare function onMessage<T = string>(context: Context, channel: string | string[], messageHandler: MessageHandler<T>): import("ioredis/built/Redis").default;
21
+ export declare function onMessage<T = string>(context: Context, channel: string | string[], messageHandler: MessageHandler<T>): import("ioredis").default;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,6 +9,11 @@ export declare const REDIS_CLIENT_KEY: unique symbol;
9
9
  export declare const REDIS_PUB_KEY: unique symbol;
10
10
  export declare const REDIS_SUB_KEY: unique symbol;
11
11
  export declare const REDIS_OPTIONS_KEY: unique symbol;
12
+ /**
13
+ * @deprecated Use context's DI system instead
14
+ * @param options The options to pass to the Redis client
15
+ * @returns
16
+ */
12
17
  export declare const redisMiddleware: (options?: RedisOptions) => (context: Context) => Promise<void>;
13
18
  /**
14
19
  * Get the centralized redis connection
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@declaro/redis",
3
- "version": "2.0.0-beta.39",
3
+ "version": "2.0.0-beta.41",
4
4
  "description": "Redis tools for Declaro",
5
- "main": "dist/pkg.cjs",
6
- "module": "dist/pkg.mjs",
7
- "types": "dist/index.d.ts",
5
+ "main": "dist/node/index.js",
6
+ "module": "dist/node/index.js",
7
+ "types": "dist/ts/index.d.ts",
8
8
  "author": "Emmert Technology LLC",
9
9
  "type": "module",
10
10
  "license": "MIT",
@@ -12,13 +12,16 @@
12
12
  "access": "public"
13
13
  },
14
14
  "scripts": {
15
- "dev": "vite build --watch",
16
- "build": "vite build",
17
- "preview": "vite preview",
18
- "test": "vitest"
15
+ "dev": "bun run scripts/build.ts --watch",
16
+ "clean": "bun rimraf dist",
17
+ "build:typedefs": "bun tsc --emitDeclarationOnly --outDir dist/ts -p tsconfig.json",
18
+ "build:js": "bun run scripts/build.ts",
19
+ "build": "bun run clean && bun run build:js && bun run build:typedefs",
20
+ "test": "bun test",
21
+ "test:watch": "bun test --watch"
19
22
  },
20
23
  "devDependencies": {
21
- "@declaro/core": "^2.0.0-beta.39",
24
+ "@declaro/core": "^2.0.0-beta.41",
22
25
  "@types/ioredis-mock": "^8.2.5",
23
26
  "@vitest/coverage-v8": "^0.32.2",
24
27
  "ioredis": "^5.5.0",
@@ -41,5 +44,11 @@
41
44
  "url": "https://github.com/emmertio/declaro/issues"
42
45
  },
43
46
  "homepage": "https://github.com/emmertio/declaro/tree/main#readme",
44
- "gitHead": "b9c20c5f46fb353d6d9c73b27e2bf1fc392a7038"
47
+ "gitHead": "7e6ea0623a29e76603adab78bdbb704bdb10394e",
48
+ "exports": {
49
+ "import": "./dist/browser/index.js",
50
+ "require": "./dist/node/index.js",
51
+ "types": "./dist/ts/index.d.ts",
52
+ "bun": "./dist/bun/index.js"
53
+ }
45
54
  }
@@ -0,0 +1,24 @@
1
+ import { build } from 'bun'
2
+ import { resolve } from 'path'
3
+
4
+ const defaults = {
5
+ entrypoints: [resolve(__dirname, '../src/index.ts')],
6
+ }
7
+
8
+ await Promise.all([
9
+ build({
10
+ ...defaults,
11
+ target: 'node',
12
+ format: 'cjs',
13
+ splitting: true,
14
+ outdir: 'dist/node',
15
+ sourcemap: 'linked',
16
+ }),
17
+ build({
18
+ ...defaults,
19
+ target: 'bun',
20
+ splitting: true,
21
+ outdir: 'dist/bun',
22
+ sourcemap: 'linked',
23
+ }),
24
+ ])
@@ -12,6 +12,11 @@ export const REDIS_PUB_KEY = Symbol()
12
12
  export const REDIS_SUB_KEY = Symbol()
13
13
  export const REDIS_OPTIONS_KEY = Symbol()
14
14
 
15
+ /**
16
+ * @deprecated Use context's DI system instead
17
+ * @param options The options to pass to the Redis client
18
+ * @returns
19
+ */
15
20
  export const redisMiddleware = (options?: RedisOptions) => async (context: Context) => {
16
21
  context.provide(REDIS_OPTIONS_KEY, options)
17
22
 
@@ -19,15 +24,16 @@ export const redisMiddleware = (options?: RedisOptions) => async (context: Conte
19
24
  const redis = new Redis(options)
20
25
 
21
26
  context.provide(REDIS_CLIENT_KEY, redis)
22
- await context.emit(RedisEvents.Connect, redis)
27
+ await context.emit(RedisEvents.Connect)
23
28
  })
24
29
 
25
30
  context.on(App.Events.Destroy, async (context) => {
26
31
  const redis = useRedis(context)
27
- await context.emit(RedisEvents.Destroy, redis)
32
+ await context.emit(RedisEvents.Destroy)
28
33
  })
29
34
 
30
- context.on(RedisEvents.Destroy, async (context, redis: RedisInstance) => {
35
+ context.on(RedisEvents.Destroy, async (context) => {
36
+ const redis = useRedis(context)
31
37
  await redis.quit()
32
38
  })
33
39
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,11 @@
1
1
  {
2
2
  "extends": ["../../tsconfig.json"],
3
- "compilerOptions": {},
3
+ "compilerOptions": {
4
+ "esModuleInterop": true,
5
+ "allowSyntheticDefaultImports": true,
6
+ "declaration": true,
7
+ "sourceMap": true
8
+ },
4
9
  "include": ["src/*.ts", "src/**/*.ts", "src/**/*.d.ts"],
5
10
  "buildOptions": {
6
11
  "outDir": "dist"