mielk-fn 1.1.0 → 1.2.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.
@@ -0,0 +1,2 @@
1
+ import { getRedisClient } from './redisClient.js';
2
+ export { getRedisClient };
@@ -0,0 +1,2 @@
1
+ import { getRedisClient } from './redisClient.js';
2
+ export { getRedisClient };
@@ -0,0 +1,2 @@
1
+ import { RedisClientType } from 'redis';
2
+ export declare function getRedisClient(): Promise<RedisClientType>;
@@ -0,0 +1,13 @@
1
+ import { createClient } from 'redis';
2
+ const redisClient = createClient({
3
+ url: 'redis://localhost:6379',
4
+ });
5
+ redisClient.on('error', (err) => console.error('Redis error:', err));
6
+ let connected = false;
7
+ export async function getRedisClient() {
8
+ if (!connected) {
9
+ await redisClient.connect();
10
+ connected = true;
11
+ }
12
+ return redisClient;
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mielk-fn",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "keywords": [],
5
5
  "author": "mielk",
6
6
  "description": "Generic functions used in various projects",
@@ -38,6 +38,11 @@
38
38
  "import": "./dist/objects/index.js",
39
39
  "default": "./dist/objects/index.js"
40
40
  },
41
+ "./redis": {
42
+ "types": "./dist/redis/index.d.ts",
43
+ "import": "./dist/redis/index.js",
44
+ "default": "./dist/redis/index.js"
45
+ },
41
46
  "./regex": {
42
47
  "types": "./dist/regex/index.d.ts",
43
48
  "import": "./dist/regex/index.js",
@@ -48,11 +53,6 @@
48
53
  "import": "./dist/strings/index.js",
49
54
  "default": "./dist/strings/index.js"
50
55
  },
51
- "./tags": {
52
- "types": "./dist/tags/index.d.ts",
53
- "import": "./dist/tags/index.js",
54
- "default": "./dist/tags/index.js"
55
- },
56
56
  "./types": {
57
57
  "types": "./dist/types/index.d.ts",
58
58
  "import": "./dist/types/index.js",
@@ -87,5 +87,8 @@
87
87
  },
88
88
  "files": [
89
89
  "dist"
90
- ]
90
+ ],
91
+ "dependencies": {
92
+ "redis": "^5.11.0"
93
+ }
91
94
  }
@@ -1,7 +0,0 @@
1
- export type Tag = {
2
- prefix: string;
3
- tag: string;
4
- };
5
- export declare const joinPrefixes: (parentPrefix: string, prefix: string) => string;
6
- export declare const createTag: (parentPrefix: string, prefix: string, tag: string) => Tag;
7
- export declare const msgTag: (tag: Tag) => string;
@@ -1,3 +0,0 @@
1
- export const joinPrefixes = (parentPrefix, prefix) => [parentPrefix, prefix].join('/');
2
- export const createTag = (parentPrefix, prefix, tag) => ({ prefix: [parentPrefix, prefix].join('/'), tag });
3
- export const msgTag = (tag) => [tag.prefix, tag.tag].join(':');