@powfix/core-js 0.11.1 → 0.11.3

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.
@@ -6,7 +6,7 @@ export declare class RedisPublisher extends RedisClient {
6
6
  stop(): Promise<RedisClient.Status>;
7
7
  setLogging(logging: RedisPublisher.LOGGING): void;
8
8
  getLogging(): RedisPublisher.LOGGING;
9
- publish: (channel: string, data: string | object) => Promise<void>;
9
+ publish(channel: string, data: string | object): Promise<void>;
10
10
  }
11
11
  export declare namespace RedisPublisher {
12
12
  type LOGGING = 'none' | 'length' | 'data';
@@ -15,24 +15,6 @@ class RedisPublisher extends RedisClient_1.RedisClient {
15
15
  constructor(options) {
16
16
  super(options);
17
17
  this.logging = 'length';
18
- // Make public method
19
- this.publish = (channel, data) => __awaiter(this, void 0, void 0, function* () {
20
- const stringifyData = typeof data !== 'string' ? JSON.stringify(data) : data;
21
- switch (this.logging) {
22
- case "none": {
23
- break;
24
- }
25
- case "length": {
26
- console.log(Date.now(), 'Server ---> Redis', channel, stringifyData.length);
27
- break;
28
- }
29
- case "data": {
30
- console.log(Date.now(), 'Server ---> Redis', channel, stringifyData);
31
- break;
32
- }
33
- }
34
- yield this.client.publish(channel, stringifyData);
35
- });
36
18
  console.log(Date.now(), "RedisPublisher", 'initialized');
37
19
  }
38
20
  start() {
@@ -40,7 +22,7 @@ class RedisPublisher extends RedisClient_1.RedisClient {
40
22
  start: { get: () => super.start }
41
23
  });
42
24
  return __awaiter(this, void 0, void 0, function* () {
43
- return yield _super.start.call(this);
25
+ return _super.start.call(this);
44
26
  });
45
27
  }
46
28
  stop() {
@@ -48,7 +30,7 @@ class RedisPublisher extends RedisClient_1.RedisClient {
48
30
  stop: { get: () => super.stop }
49
31
  });
50
32
  return __awaiter(this, void 0, void 0, function* () {
51
- return yield _super.stop.call(this);
33
+ return _super.stop.call(this);
52
34
  });
53
35
  }
54
36
  setLogging(logging) {
@@ -57,5 +39,25 @@ class RedisPublisher extends RedisClient_1.RedisClient {
57
39
  getLogging() {
58
40
  return this.logging;
59
41
  }
42
+ // Make public method
43
+ publish(channel, data) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ const stringifyData = typeof data !== 'string' ? JSON.stringify(data) : data;
46
+ switch (this.logging) {
47
+ case "none": {
48
+ break;
49
+ }
50
+ case "length": {
51
+ console.log(Date.now(), 'Server ---> Redis', channel, stringifyData.length);
52
+ break;
53
+ }
54
+ case "data": {
55
+ console.log(Date.now(), 'Server ---> Redis', channel, stringifyData);
56
+ break;
57
+ }
58
+ }
59
+ yield this.client.publish(channel, stringifyData);
60
+ });
61
+ }
60
62
  }
61
63
  exports.RedisPublisher = RedisPublisher;
@@ -2,8 +2,8 @@ import { RedisClient } from "./RedisClient";
2
2
  import { PubSubListener } from "@redis/client/dist/lib/client/pub-sub";
3
3
  export declare class RedisSubscriber extends RedisClient {
4
4
  constructor(options?: RedisClient.RedisClientOptions);
5
- subscribe: <T extends boolean = false>(channels: string | string[], listener: PubSubListener<T>, bufferMode?: T | undefined) => Promise<void>;
6
- unsubscribe: <T extends boolean = false>(channels: string | string[], listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined) => Promise<void>;
5
+ subscribe<T extends boolean = false>(channels: string | string[], listener: PubSubListener<T>, bufferMode?: T | undefined): Promise<void>;
6
+ unsubscribe<T extends boolean = false>(channels: string | string[], listener?: PubSubListener<T> | undefined, bufferMode?: T | undefined): Promise<void>;
7
7
  start(): Promise<RedisClient.Status>;
8
8
  stop(): Promise<RedisClient.Status>;
9
9
  protected registerListeners(): Promise<void>;
@@ -14,7 +14,10 @@ const RedisClient_1 = require("./RedisClient");
14
14
  class RedisSubscriber extends RedisClient_1.RedisClient {
15
15
  constructor(options) {
16
16
  super(options);
17
- this.subscribe = (channels, listener, bufferMode) => __awaiter(this, void 0, void 0, function* () {
17
+ console.log(Date.now(), 'Subscriber', 'initialized');
18
+ }
19
+ subscribe(channels, listener, bufferMode) {
20
+ return __awaiter(this, void 0, void 0, function* () {
18
21
  for (const channel of Array.isArray(channels) ? channels : [channels]) {
19
22
  if ((/\*/g).test(channel)) {
20
23
  yield this.client.pSubscribe(channel, listener, bufferMode);
@@ -24,7 +27,9 @@ class RedisSubscriber extends RedisClient_1.RedisClient {
24
27
  }
25
28
  }
26
29
  });
27
- this.unsubscribe = (channels, listener, bufferMode) => __awaiter(this, void 0, void 0, function* () {
30
+ }
31
+ unsubscribe(channels, listener, bufferMode) {
32
+ return __awaiter(this, void 0, void 0, function* () {
28
33
  for (const channel of Array.isArray(channels) ? channels : [channels]) {
29
34
  if ((/\*/g).test(channel)) {
30
35
  yield this.client.pUnsubscribe(channel, listener, bufferMode);
@@ -34,7 +39,6 @@ class RedisSubscriber extends RedisClient_1.RedisClient {
34
39
  }
35
40
  }
36
41
  });
37
- console.log(Date.now(), 'Subscriber', 'initialized');
38
42
  }
39
43
  start() {
40
44
  const _super = Object.create(null, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powfix/core-js",
3
- "version": "0.11.1",
3
+ "version": "0.11.3",
4
4
  "description": "core package",
5
5
  "author": "Kwon Kyung-Min <powfix@gmail.com>",
6
6
  "private": false,
@@ -28,7 +28,7 @@
28
28
  "base-64": "^1.0.0",
29
29
  "eventemitter3": "^5.0.1",
30
30
  "jwt-decode": "^4.0.0",
31
- "redis": "4.7.0",
31
+ "redis": "^4.6.11",
32
32
  "uuid": "9.0.1"
33
33
  },
34
34
  "devDependencies": {