prime-sdk 1.1.3 → 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.
- package/README.md +115 -0
- package/dist/app.module.js +15 -1
- package/dist/app.module.js.map +1 -1
- package/dist/app.service.d.ts +3 -1
- package/dist/app.service.js +14 -10
- package/dist/app.service.js.map +1 -1
- package/dist/external/redis/interfaces/redis.interface.d.ts +7 -0
- package/dist/external/redis/interfaces/redis.interface.js +5 -0
- package/dist/external/redis/interfaces/redis.interface.js.map +1 -0
- package/dist/external/redis/redis.provider.d.ts +5 -0
- package/dist/external/redis/redis.provider.js +46 -0
- package/dist/external/redis/redis.provider.js.map +1 -0
- package/dist/external/redis/redis.service.d.ts +10 -0
- package/dist/external/redis/redis.service.js +45 -0
- package/dist/external/redis/redis.service.js.map +1 -0
- package/dist/external/redis/types/ioredis.types.d.ts +19 -0
- package/dist/external/redis/types/ioredis.types.js +9 -0
- package/dist/external/redis/types/ioredis.types.js.map +1 -0
- package/dist/index.d.ts +17 -1
- package/dist/index.js +33 -1
- package/dist/index.js.map +1 -1
- package/dist/lib/cache/cache.d.ts +10 -0
- package/dist/lib/cache/cache.js +38 -0
- package/dist/lib/cache/cache.js.map +1 -0
- package/dist/lib/cache/cache.module.d.ts +5 -0
- package/dist/lib/cache/cache.module.js +37 -0
- package/dist/lib/cache/cache.module.js.map +1 -0
- package/dist/lib/cache/interfaces/cache.interface.d.ts +7 -0
- package/dist/lib/cache/interfaces/cache.interface.js +5 -0
- package/dist/lib/cache/interfaces/cache.interface.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -1
- package/src/app.module.ts +15 -1
- package/src/app.service.ts +14 -2
- package/src/external/redis/interfaces/redis.interface.ts +13 -0
- package/src/external/redis/redis.provider.ts +41 -0
- package/src/external/redis/redis.service.ts +32 -0
- package/src/external/redis/types/ioredis.types.ts +23 -0
- package/src/index.ts +15 -0
- package/src/lib/cache/cache.module.ts +28 -0
- package/src/lib/cache/cache.ts +22 -0
- package/src/lib/cache/interfaces/cache.interface.ts +13 -0
package/README.md
CHANGED
|
@@ -151,6 +151,121 @@ export class AppService implements IConsumer {
|
|
|
151
151
|
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
### Cache (Redis)
|
|
155
|
+
|
|
156
|
+
1. Install the module
|
|
157
|
+
|
|
158
|
+
2. Define whether you are working with a Redis cluster (e.g., ElasticCache) or a simple Redis (e.g., Docker).
|
|
159
|
+
|
|
160
|
+
3. Example of basic configuration :
|
|
161
|
+
|
|
162
|
+
3.1. Simple Redis:
|
|
163
|
+
|
|
164
|
+
```
|
|
165
|
+
CacheModule.forRoot({
|
|
166
|
+
type: TypeRedis.SIMPLE,
|
|
167
|
+
connection: {
|
|
168
|
+
host: 'http://redis-service',
|
|
169
|
+
port: 6379,
|
|
170
|
+
},
|
|
171
|
+
redisOptions: {
|
|
172
|
+
password: '000000',
|
|
173
|
+
},
|
|
174
|
+
}),
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
3.2. Cluster Redis:
|
|
179
|
+
|
|
180
|
+
```
|
|
181
|
+
CacheModule.forRoot({
|
|
182
|
+
type: TypeRedis.CLUSTER,
|
|
183
|
+
nodes: [
|
|
184
|
+
{
|
|
185
|
+
host: 'clustercfg.000-00000-cache.0000.use1.cache.amazonaws.com',
|
|
186
|
+
port: 6379,
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
clusterOptions: {
|
|
190
|
+
slotsRefreshTimeout: 3000,
|
|
191
|
+
dnsLookup: (address, callback) => callback(null, address),
|
|
192
|
+
redisOptions: {
|
|
193
|
+
password: '00000',
|
|
194
|
+
showFriendlyErrorStack: true,
|
|
195
|
+
tls: {},
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
4. Interfaces and Types:
|
|
203
|
+
|
|
204
|
+
```
|
|
205
|
+
enum TypeRedis {
|
|
206
|
+
SIMPLE = 'simple',
|
|
207
|
+
CLUSTER = 'cluster',
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
type Connection = {
|
|
211
|
+
port: number;
|
|
212
|
+
host: string;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
type SimpleRedisSetup = {
|
|
216
|
+
type: TypeRedis.SIMPLE;
|
|
217
|
+
connection: Connection;
|
|
218
|
+
redisOptions?: RedisOptions;
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
type ClusterRedisSetup = {
|
|
222
|
+
type: TypeRedis.CLUSTER;
|
|
223
|
+
nodes: Connection[];
|
|
224
|
+
clusterOptions?: ClusterOptions;
|
|
225
|
+
};
|
|
226
|
+
|
|
227
|
+
interface ICache {
|
|
228
|
+
set(
|
|
229
|
+
key: string,
|
|
230
|
+
value: Date | number | Buffer | string,
|
|
231
|
+
ttl?: number,
|
|
232
|
+
): Promise<void>;
|
|
233
|
+
|
|
234
|
+
get(key: string): Promise<string>;
|
|
235
|
+
|
|
236
|
+
delete(key: string): Promise<void>;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
For more information about RedisOptions and ClusterOptions, refer to the ioredis documentation:
|
|
242
|
+
|
|
243
|
+
https://www.npmjs.com/package/ioredis
|
|
244
|
+
|
|
245
|
+
5. Example of usage
|
|
246
|
+
|
|
247
|
+
```
|
|
248
|
+
@Injectable()
|
|
249
|
+
export class AppService {
|
|
250
|
+
constructor(@Inject(ICache) private readonly cache: ICache) {}
|
|
251
|
+
|
|
252
|
+
async set( key: string,
|
|
253
|
+
value: string | number | Date | Buffer,
|
|
254
|
+
ttl?: number): Promise<void> {
|
|
255
|
+
await this.cache.set(key, value, ttl);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
async get(key: string): Promise<string> {
|
|
259
|
+
return await this.cache.get(key);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
async del(key: string): Promise<void> {
|
|
263
|
+
return await this.cache.delete(key);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
```
|
|
268
|
+
|
|
154
269
|
|
|
155
270
|
#### Next steps
|
|
156
271
|
|
package/dist/app.module.js
CHANGED
|
@@ -14,6 +14,10 @@ const storage_module_1 = require("./lib/storage/storage.module");
|
|
|
14
14
|
const event_module_1 = require("./lib/events/event.module");
|
|
15
15
|
const crypto_module_1 = require("./lib/crypto/crypto.module");
|
|
16
16
|
const email_module_1 = require("./lib/email/email.module");
|
|
17
|
+
const cache_module_1 = require("./lib/cache/cache.module");
|
|
18
|
+
const ioredis_types_1 = require("./external/redis/types/ioredis.types");
|
|
19
|
+
const cache_interface_1 = require("./lib/cache/interfaces/cache.interface");
|
|
20
|
+
const cache_1 = require("./lib/cache/cache");
|
|
17
21
|
let AppModule = class AppModule {
|
|
18
22
|
};
|
|
19
23
|
exports.AppModule = AppModule;
|
|
@@ -60,8 +64,18 @@ exports.AppModule = AppModule = __decorate([
|
|
|
60
64
|
endpoint: 'http://localhost:4566/',
|
|
61
65
|
region: 'us-east-1',
|
|
62
66
|
}),
|
|
67
|
+
cache_module_1.CacheModule.forRoot({
|
|
68
|
+
type: ioredis_types_1.TypeRedis.SIMPLE,
|
|
69
|
+
connection: {
|
|
70
|
+
host: 'localhost',
|
|
71
|
+
port: 6379,
|
|
72
|
+
},
|
|
73
|
+
redisOptions: {
|
|
74
|
+
db: 5,
|
|
75
|
+
},
|
|
76
|
+
}),
|
|
63
77
|
],
|
|
64
|
-
providers: [app_service_1.AppService],
|
|
78
|
+
providers: [app_service_1.AppService, { provide: cache_interface_1.ICache, useClass: cache_1.Cache }],
|
|
65
79
|
exports: [],
|
|
66
80
|
})
|
|
67
81
|
], AppModule);
|
package/dist/app.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+CAA2C;AAC3C,2DAAuD;AACvD,iEAA6D;AAC7D,4DAAwD;AACxD,8DAA0D;AAC1D,2DAAuD;
|
|
1
|
+
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,+CAA2C;AAC3C,2DAAuD;AACvD,iEAA6D;AAC7D,4DAAwD;AACxD,8DAA0D;AAC1D,2DAAuD;AACvD,2DAAuD;AACvD,wEAAiE;AACjE,4EAAgE;AAChE,6CAA0C;AA2DnC,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,8BAAS;oBAAT,SAAS;IAxDrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE;YACP,0BAAW,CAAC,OAAO,CAAC;gBAClB,WAAW,EAAE;oBACX,WAAW,EAAE,WAAW;oBACxB,eAAe,EAAE,WAAW;iBAC7B;gBACD,QAAQ,EAAE,wBAAwB;gBAClC,MAAM,EAAE,WAAW;aACpB,CAAC;YACF,8BAAa,CAAC,OAAO,CAAC;gBACpB,WAAW,EAAE;oBACX,WAAW,EAAE,WAAW;oBACxB,eAAe,EAAE,WAAW;iBAC7B;gBACD,QAAQ,EAAE,qCAAqC;gBAC/C,MAAM,EAAE,WAAW;aACpB,CAAC;YACF,0BAAW,CAAC,OAAO,CAAC;gBAClB,WAAW,EAAE;oBACX,WAAW,EAAE,WAAW;oBACxB,eAAe,EAAE,WAAW;iBAC7B;gBACD,QAAQ,EAAE,wBAAwB;gBAClC,MAAM,EAAE,WAAW;aACpB,CAAC;YACF,4BAAY,CAAC,OAAO,CAAC;gBACnB,WAAW,EAAE;oBACX,WAAW,EAAE,WAAW;oBACxB,eAAe,EAAE,WAAW;iBAC7B;gBACD,QAAQ,EAAE,wBAAwB;gBAClC,MAAM,EAAE,WAAW;aACpB,CAAC;YACF,0BAAW,CAAC,OAAO,CAAC;gBAClB,WAAW,EAAE;oBACX,WAAW,EAAE,WAAW;oBACxB,eAAe,EAAE,WAAW;iBAC7B;gBACD,QAAQ,EAAE,wBAAwB;gBAClC,MAAM,EAAE,WAAW;aACpB,CAAC;YACF,0BAAW,CAAC,OAAO,CAAC;gBAClB,IAAI,EAAE,yBAAS,CAAC,MAAM;gBACtB,UAAU,EAAE;oBACV,IAAI,EAAE,WAAW;oBACjB,IAAI,EAAE,IAAI;iBACX;gBACD,YAAY,EAAE;oBACZ,EAAE,EAAE,CAAC;iBACN;aACF,CAAC;SACH;QACD,SAAS,EAAE,CAAC,wBAAU,EAAE,EAAE,OAAO,EAAE,wBAAM,EAAE,QAAQ,EAAE,aAAK,EAAE,CAAC;QAC7D,OAAO,EAAE,EAAE;KACZ,CAAC;GACW,SAAS,CAAG"}
|
package/dist/app.service.d.ts
CHANGED
|
@@ -3,11 +3,13 @@ import { Message } from '@aws-sdk/client-sqs';
|
|
|
3
3
|
import { Queue } from './lib/queue/queue';
|
|
4
4
|
import { Storage } from './lib/storage/storage';
|
|
5
5
|
import { Events } from './lib/events/events';
|
|
6
|
+
import { ICache } from './lib/cache/interfaces/cache.interface';
|
|
6
7
|
export declare class AppService implements IConsumer {
|
|
7
8
|
private readonly queueHandler;
|
|
8
9
|
private readonly storage;
|
|
9
10
|
private readonly event;
|
|
10
|
-
|
|
11
|
+
private readonly cache;
|
|
12
|
+
constructor(queueHandler: Queue, storage: Storage, event: Events, cache: ICache);
|
|
11
13
|
handleMessage(message: Message | Message[]): Promise<void>;
|
|
12
14
|
handleError(error: unknown): Promise<void>;
|
|
13
15
|
}
|
package/dist/app.service.js
CHANGED
|
@@ -8,17 +8,22 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.AppService = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
14
17
|
const queue_1 = require("./lib/queue/queue");
|
|
15
18
|
const storage_1 = require("./lib/storage/storage");
|
|
16
19
|
const events_1 = require("./lib/events/events");
|
|
20
|
+
const cache_interface_1 = require("./lib/cache/interfaces/cache.interface");
|
|
17
21
|
let AppService = class AppService {
|
|
18
|
-
constructor(queueHandler, storage, event) {
|
|
22
|
+
constructor(queueHandler, storage, event, cache) {
|
|
19
23
|
this.queueHandler = queueHandler;
|
|
20
24
|
this.storage = storage;
|
|
21
25
|
this.event = event;
|
|
26
|
+
this.cache = cache;
|
|
22
27
|
this.queueHandler.handler({
|
|
23
28
|
QueueUrl: `${'teste'}`,
|
|
24
29
|
context: this,
|
|
@@ -26,20 +31,18 @@ let AppService = class AppService {
|
|
|
26
31
|
waitTimeSeconds: 20,
|
|
27
32
|
});
|
|
28
33
|
}
|
|
29
|
-
handleMessage(message) {
|
|
34
|
+
async handleMessage(message) {
|
|
30
35
|
console.log(message);
|
|
36
|
+
const key = `data:${new Date().toISOString()}`;
|
|
37
|
+
this.cache.set(key, JSON.stringify(message));
|
|
38
|
+
const value = await this.cache.get(key);
|
|
39
|
+
console.log(value);
|
|
40
|
+
this.cache.delete(key);
|
|
31
41
|
const data = JSON.stringify({ teste: new Date().toISOString() });
|
|
32
42
|
this.event.triggerEvent({
|
|
33
43
|
topic: 'arn:aws:sns:us-east-1:000000000000:teste-topic',
|
|
34
44
|
message: data,
|
|
35
45
|
});
|
|
36
|
-
const file = Buffer.from(data, 'utf-8');
|
|
37
|
-
this.storage.uploadFile({
|
|
38
|
-
bucket: 'sample-bucket',
|
|
39
|
-
file: file,
|
|
40
|
-
nameFile: 'teste.txt',
|
|
41
|
-
path: 'prime-sdk',
|
|
42
|
-
});
|
|
43
46
|
return;
|
|
44
47
|
}
|
|
45
48
|
handleError(error) {
|
|
@@ -50,8 +53,9 @@ let AppService = class AppService {
|
|
|
50
53
|
exports.AppService = AppService;
|
|
51
54
|
exports.AppService = AppService = __decorate([
|
|
52
55
|
(0, common_1.Injectable)(),
|
|
56
|
+
__param(3, (0, common_1.Inject)(cache_interface_1.ICache)),
|
|
53
57
|
__metadata("design:paramtypes", [queue_1.Queue,
|
|
54
58
|
storage_1.Storage,
|
|
55
|
-
events_1.Events])
|
|
59
|
+
events_1.Events, Object])
|
|
56
60
|
], AppService);
|
|
57
61
|
//# sourceMappingURL=app.service.js.map
|
package/dist/app.service.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAGpD,6CAA0C;AAC1C,mDAAgD;AAChD,gDAA6C;AAC7C,4EAAgE;AAGzD,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,YACmB,YAAmB,EACnB,OAAgB,EAChB,KAAa,EACG,KAAa;QAH7B,iBAAY,GAAZ,YAAY,CAAO;QACnB,YAAO,GAAP,OAAO,CAAS;QAChB,UAAK,GAAL,KAAK,CAAQ;QACG,UAAK,GAAL,KAAK,CAAQ;QAE9C,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC;YACxB,QAAQ,EAAE,GAAG,OAAO,EAAE;YACtB,OAAO,EAAE,IAAI;YACb,IAAI,EAAE,CAAC;YACP,eAAe,EAAE,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,OAA4B;QAC9C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,MAAM,GAAG,GAAG,QAAQ,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC;QAC/C,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAE7C,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAExC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAEnB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAEvB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;QAEjE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;YACtB,KAAK,EAAE,gDAAgD;YACvD,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAWH,OAAO;IACT,CAAC;IAED,WAAW,CAAC,KAAc;QACxB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QACnB,OAAO;IACT,CAAC;CACF,CAAA;AAlDY,gCAAU;qBAAV,UAAU;IADtB,IAAA,mBAAU,GAAE;IAMR,WAAA,IAAA,eAAM,EAAC,wBAAM,CAAC,CAAA;qCAHgB,aAAK;QACV,iBAAO;QACT,eAAM;GAJrB,UAAU,CAkDtB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export interface IRedisService {
|
|
3
|
+
setRedisKey(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<void>;
|
|
4
|
+
getRedisKey(key: string): Promise<string>;
|
|
5
|
+
deleteRedisKey(key: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare const IRedisService: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.interface.js","sourceRoot":"","sources":["../../../../src/external/redis/interfaces/redis.interface.ts"],"names":[],"mappings":";;;AAYa,QAAA,aAAa,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var RedisModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RedisModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const ioredis_1 = require("ioredis");
|
|
13
|
+
const ioredis_types_1 = require("./types/ioredis.types");
|
|
14
|
+
const RedisProvider = (params) => {
|
|
15
|
+
return {
|
|
16
|
+
provide: 'CONNECTION_REDIS',
|
|
17
|
+
useFactory: () => {
|
|
18
|
+
switch (params.type) {
|
|
19
|
+
case ioredis_types_1.TypeRedis.SIMPLE:
|
|
20
|
+
return new ioredis_1.Redis({
|
|
21
|
+
port: params.connection.port,
|
|
22
|
+
host: params.connection.host,
|
|
23
|
+
...(params.redisOptions && { ...params.redisOptions }),
|
|
24
|
+
});
|
|
25
|
+
case ioredis_types_1.TypeRedis.CLUSTER:
|
|
26
|
+
const cluster = new ioredis_1.Redis.Cluster(params.nodes, params.clusterOptions);
|
|
27
|
+
return cluster;
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
let RedisModule = RedisModule_1 = class RedisModule {
|
|
33
|
+
static forRoot(params) {
|
|
34
|
+
const redisProvider = RedisProvider(params);
|
|
35
|
+
return {
|
|
36
|
+
module: RedisModule_1,
|
|
37
|
+
providers: [redisProvider],
|
|
38
|
+
exports: [redisProvider],
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
exports.RedisModule = RedisModule;
|
|
43
|
+
exports.RedisModule = RedisModule = RedisModule_1 = __decorate([
|
|
44
|
+
(0, common_1.Module)({})
|
|
45
|
+
], RedisModule);
|
|
46
|
+
//# sourceMappingURL=redis.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.provider.js","sourceRoot":"","sources":["../../../src/external/redis/redis.provider.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,qCAAyC;AACzC,yDAI+B;AAE/B,MAAM,aAAa,GAAG,CAAC,MAA4C,EAAE,EAAE;IACrE,OAAO;QACL,OAAO,EAAE,kBAAkB;QAC3B,UAAU,EAAE,GAAoB,EAAE;YAChC,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;gBACpB,KAAK,yBAAS,CAAC,MAAM;oBACnB,OAAO,IAAI,eAAK,CAAC;wBACf,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;wBAC5B,IAAI,EAAE,MAAM,CAAC,UAAU,CAAC,IAAI;wBAC5B,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,EAAE,GAAG,MAAM,CAAC,YAAY,EAAE,CAAC;qBACvD,CAAC,CAAC;gBACL,KAAK,yBAAS,CAAC,OAAO;oBACpB,MAAM,OAAO,GAAG,IAAI,eAAK,CAAC,OAAO,CAC/B,MAAM,CAAC,KAAK,EACZ,MAAM,CAAC,cAAc,CACtB,CAAC;oBACF,OAAO,OAAO,CAAC;YACnB,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC,CAAC;AAGK,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,MAA4C;QACzD,MAAM,aAAa,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QAC5C,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,SAAS,EAAE,CAAC,aAAa,CAAC;YAC1B,OAAO,EAAE,CAAC,aAAa,CAAC;SACzB,CAAC;IACJ,CAAC;CACF,CAAA;AATY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CASvB"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Cluster, Redis } from 'ioredis';
|
|
3
|
+
import { IRedisService } from './interfaces/redis.interface';
|
|
4
|
+
export declare class RedisService implements IRedisService {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: Cluster | Redis);
|
|
7
|
+
setRedisKey(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<void>;
|
|
8
|
+
getRedisKey(key: string): Promise<string>;
|
|
9
|
+
deleteRedisKey(key: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.RedisService = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
let RedisService = class RedisService {
|
|
18
|
+
constructor(client) {
|
|
19
|
+
this.client = client;
|
|
20
|
+
}
|
|
21
|
+
async setRedisKey(key, value, ttl) {
|
|
22
|
+
if (value instanceof Date) {
|
|
23
|
+
value = value.toISOString();
|
|
24
|
+
}
|
|
25
|
+
if (ttl) {
|
|
26
|
+
await this.client.set(key, value, 'EX', ttl);
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
await this.client.set(key, value);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async getRedisKey(key) {
|
|
33
|
+
return await this.client.get(key);
|
|
34
|
+
}
|
|
35
|
+
async deleteRedisKey(key) {
|
|
36
|
+
await this.client.del(key);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
exports.RedisService = RedisService;
|
|
40
|
+
exports.RedisService = RedisService = __decorate([
|
|
41
|
+
(0, common_1.Injectable)(),
|
|
42
|
+
__param(0, (0, common_1.Inject)('CONNECTION_REDIS')),
|
|
43
|
+
__metadata("design:paramtypes", [Object])
|
|
44
|
+
], RedisService);
|
|
45
|
+
//# sourceMappingURL=redis.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"redis.service.js","sourceRoot":"","sources":["../../../src/external/redis/redis.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAK7C,IAAM,YAAY,GAAlB,MAAM,YAAY;IACvB,YAC+C,MAAuB;QAAvB,WAAM,GAAN,MAAM,CAAiB;IACnE,CAAC;IAEJ,KAAK,CAAC,WAAW,CACf,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YAC1B,KAAK,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC9B,CAAC;QACD,IAAI,GAAG,EAAE,CAAC;YACR,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QAC/C,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IACD,KAAK,CAAC,WAAW,CAAC,GAAW;QAC3B,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW;QAC9B,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF,CAAA;AA1BY,oCAAY;uBAAZ,YAAY;IADxB,IAAA,mBAAU,GAAE;IAGR,WAAA,IAAA,eAAM,EAAC,kBAAkB,CAAC,CAAA;;GAFlB,YAAY,CA0BxB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ClusterOptions, RedisOptions } from 'ioredis';
|
|
2
|
+
export declare enum TypeRedis {
|
|
3
|
+
SIMPLE = "simple",
|
|
4
|
+
CLUSTER = "cluster"
|
|
5
|
+
}
|
|
6
|
+
export type Connection = {
|
|
7
|
+
port: number;
|
|
8
|
+
host: string;
|
|
9
|
+
};
|
|
10
|
+
export type SimpleRedisSetup = {
|
|
11
|
+
type: TypeRedis.SIMPLE;
|
|
12
|
+
connection: Connection;
|
|
13
|
+
redisOptions?: RedisOptions;
|
|
14
|
+
};
|
|
15
|
+
export type ClusterRedisSetup = {
|
|
16
|
+
type: TypeRedis.CLUSTER;
|
|
17
|
+
nodes: Connection[];
|
|
18
|
+
clusterOptions?: ClusterOptions;
|
|
19
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TypeRedis = void 0;
|
|
4
|
+
var TypeRedis;
|
|
5
|
+
(function (TypeRedis) {
|
|
6
|
+
TypeRedis["SIMPLE"] = "simple";
|
|
7
|
+
TypeRedis["CLUSTER"] = "cluster";
|
|
8
|
+
})(TypeRedis || (exports.TypeRedis = TypeRedis = {}));
|
|
9
|
+
//# sourceMappingURL=ioredis.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ioredis.types.js","sourceRoot":"","sources":["../../../../src/external/redis/types/ioredis.types.ts"],"names":[],"mappings":";;;AAEA,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,gCAAmB,CAAA;AACrB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import { QueueModule } from './lib/queue/queue.module';
|
|
2
2
|
import { Queue } from './lib/queue/queue';
|
|
3
3
|
import { IConsumer } from './lib/queue/interfaces/consumer.interface';
|
|
4
|
-
|
|
4
|
+
import { StorageModule } from './lib/storage/storage.module';
|
|
5
|
+
import { Storage } from './lib/storage/storage';
|
|
6
|
+
import { IStorage } from './lib/storage/interfaces/storage.interface';
|
|
7
|
+
import { EventModule } from './lib/events/event.module';
|
|
8
|
+
import { Events } from './lib/events/events';
|
|
9
|
+
import { IEvent } from './lib/events/interfaces/event.interface';
|
|
10
|
+
import { EmailModule } from './lib/email/email.module';
|
|
11
|
+
import { Email } from './lib/email/email';
|
|
12
|
+
import { IEmail } from './lib/email/interfaces/email.interface';
|
|
13
|
+
import { CryptoModule } from './lib/crypto/crypto.module';
|
|
14
|
+
import { Crypto } from './lib/crypto/crypto';
|
|
15
|
+
import { ICrypto } from './lib/crypto/interfaces/crypto.interface';
|
|
16
|
+
import { CacheModule } from './lib/cache/cache.module';
|
|
17
|
+
import { Cache } from './lib/cache/cache';
|
|
18
|
+
import { ICache } from './lib/cache/interfaces/cache.interface';
|
|
19
|
+
import { SimpleRedisSetup, ClusterRedisSetup, TypeRedis } from './external/redis/types/ioredis.types';
|
|
20
|
+
export { QueueModule, Queue, IConsumer, StorageModule, Storage, IStorage, EventModule, Events, IEvent, EmailModule, Email, IEmail, CryptoModule, Crypto, ICrypto, CacheModule, Cache, ICache, SimpleRedisSetup, ClusterRedisSetup, TypeRedis, };
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IConsumer = exports.Queue = exports.QueueModule = void 0;
|
|
3
|
+
exports.TypeRedis = exports.ICache = exports.Cache = exports.CacheModule = exports.ICrypto = exports.Crypto = exports.CryptoModule = exports.IEmail = exports.Email = exports.EmailModule = exports.IEvent = exports.Events = exports.EventModule = exports.IStorage = exports.Storage = exports.StorageModule = exports.IConsumer = exports.Queue = exports.QueueModule = void 0;
|
|
4
4
|
const queue_module_1 = require("./lib/queue/queue.module");
|
|
5
5
|
Object.defineProperty(exports, "QueueModule", { enumerable: true, get: function () { return queue_module_1.QueueModule; } });
|
|
6
6
|
const queue_1 = require("./lib/queue/queue");
|
|
7
7
|
Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return queue_1.Queue; } });
|
|
8
8
|
const consumer_interface_1 = require("./lib/queue/interfaces/consumer.interface");
|
|
9
9
|
Object.defineProperty(exports, "IConsumer", { enumerable: true, get: function () { return consumer_interface_1.IConsumer; } });
|
|
10
|
+
const storage_module_1 = require("./lib/storage/storage.module");
|
|
11
|
+
Object.defineProperty(exports, "StorageModule", { enumerable: true, get: function () { return storage_module_1.StorageModule; } });
|
|
12
|
+
const storage_1 = require("./lib/storage/storage");
|
|
13
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return storage_1.Storage; } });
|
|
14
|
+
const storage_interface_1 = require("./lib/storage/interfaces/storage.interface");
|
|
15
|
+
Object.defineProperty(exports, "IStorage", { enumerable: true, get: function () { return storage_interface_1.IStorage; } });
|
|
16
|
+
const event_module_1 = require("./lib/events/event.module");
|
|
17
|
+
Object.defineProperty(exports, "EventModule", { enumerable: true, get: function () { return event_module_1.EventModule; } });
|
|
18
|
+
const events_1 = require("./lib/events/events");
|
|
19
|
+
Object.defineProperty(exports, "Events", { enumerable: true, get: function () { return events_1.Events; } });
|
|
20
|
+
const event_interface_1 = require("./lib/events/interfaces/event.interface");
|
|
21
|
+
Object.defineProperty(exports, "IEvent", { enumerable: true, get: function () { return event_interface_1.IEvent; } });
|
|
22
|
+
const email_module_1 = require("./lib/email/email.module");
|
|
23
|
+
Object.defineProperty(exports, "EmailModule", { enumerable: true, get: function () { return email_module_1.EmailModule; } });
|
|
24
|
+
const email_1 = require("./lib/email/email");
|
|
25
|
+
Object.defineProperty(exports, "Email", { enumerable: true, get: function () { return email_1.Email; } });
|
|
26
|
+
const email_interface_1 = require("./lib/email/interfaces/email.interface");
|
|
27
|
+
Object.defineProperty(exports, "IEmail", { enumerable: true, get: function () { return email_interface_1.IEmail; } });
|
|
28
|
+
const crypto_module_1 = require("./lib/crypto/crypto.module");
|
|
29
|
+
Object.defineProperty(exports, "CryptoModule", { enumerable: true, get: function () { return crypto_module_1.CryptoModule; } });
|
|
30
|
+
const crypto_1 = require("./lib/crypto/crypto");
|
|
31
|
+
Object.defineProperty(exports, "Crypto", { enumerable: true, get: function () { return crypto_1.Crypto; } });
|
|
32
|
+
const crypto_interface_1 = require("./lib/crypto/interfaces/crypto.interface");
|
|
33
|
+
Object.defineProperty(exports, "ICrypto", { enumerable: true, get: function () { return crypto_interface_1.ICrypto; } });
|
|
34
|
+
const cache_module_1 = require("./lib/cache/cache.module");
|
|
35
|
+
Object.defineProperty(exports, "CacheModule", { enumerable: true, get: function () { return cache_module_1.CacheModule; } });
|
|
36
|
+
const cache_1 = require("./lib/cache/cache");
|
|
37
|
+
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return cache_1.Cache; } });
|
|
38
|
+
const cache_interface_1 = require("./lib/cache/interfaces/cache.interface");
|
|
39
|
+
Object.defineProperty(exports, "ICache", { enumerable: true, get: function () { return cache_interface_1.ICache; } });
|
|
40
|
+
const ioredis_types_1 = require("./external/redis/types/ioredis.types");
|
|
41
|
+
Object.defineProperty(exports, "TypeRedis", { enumerable: true, get: function () { return ioredis_types_1.TypeRedis; } });
|
|
10
42
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,2DAAuD;AA8BrD,4FA9BO,0BAAW,OA8BP;AA7Bb,6CAA0C;AA8BxC,sFA9BO,aAAK,OA8BP;AA7BP,kFAAsE;AA8BpE,0FA9BO,8BAAS,OA8BP;AA5BX,iEAA6D;AA6B3D,8FA7BO,8BAAa,OA6BP;AA5Bf,mDAAgD;AA6B9C,wFA7BO,iBAAO,OA6BP;AA5BT,kFAAsE;AA6BpE,yFA7BO,4BAAQ,OA6BP;AA3BV,4DAAwD;AA4BtD,4FA5BO,0BAAW,OA4BP;AA3Bb,gDAA6C;AA4B3C,uFA5BO,eAAM,OA4BP;AA3BR,6EAAiE;AA4B/D,uFA5BO,wBAAM,OA4BP;AA1BR,2DAAuD;AA2BrD,4FA3BO,0BAAW,OA2BP;AA1Bb,6CAA0C;AA2BxC,sFA3BO,aAAK,OA2BP;AA1BP,4EAAgE;AA2B9D,uFA3BO,wBAAM,OA2BP;AAzBR,8DAA0D;AA0BxD,6FA1BO,4BAAY,OA0BP;AAzBd,gDAA6C;AA0B3C,uFA1BO,eAAM,OA0BP;AAzBR,+EAAmE;AA0BjE,wFA1BO,0BAAO,OA0BP;AAxBT,2DAAuD;AAyBrD,4FAzBO,0BAAW,OAyBP;AAxBb,6CAA0C;AAyBxC,sFAzBO,aAAK,OAyBP;AAxBP,4EAAgE;AAyB9D,uFAzBO,wBAAM,OAyBP;AAxBR,wEAI8C;AAuB5C,0FAxBA,yBAAS,OAwBA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { ICache } from './interfaces/cache.interface';
|
|
3
|
+
import { IRedisService } from 'src/external/redis/interfaces/redis.interface';
|
|
4
|
+
export declare class Cache implements ICache {
|
|
5
|
+
private readonly client;
|
|
6
|
+
constructor(client: IRedisService);
|
|
7
|
+
set(key: string, value: string | number | Date | Buffer, ttl?: number): Promise<void>;
|
|
8
|
+
get(key: string): Promise<string>;
|
|
9
|
+
delete(key: string): Promise<void>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Cache = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const redis_interface_1 = require("../../external/redis/interfaces/redis.interface");
|
|
18
|
+
let Cache = class Cache {
|
|
19
|
+
constructor(client) {
|
|
20
|
+
this.client = client;
|
|
21
|
+
}
|
|
22
|
+
async set(key, value, ttl) {
|
|
23
|
+
await this.client.setRedisKey(key, value, ttl);
|
|
24
|
+
}
|
|
25
|
+
async get(key) {
|
|
26
|
+
return await this.client.getRedisKey(key);
|
|
27
|
+
}
|
|
28
|
+
async delete(key) {
|
|
29
|
+
await this.client.deleteRedisKey(key);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
exports.Cache = Cache;
|
|
33
|
+
exports.Cache = Cache = __decorate([
|
|
34
|
+
(0, common_1.Injectable)(),
|
|
35
|
+
__param(0, (0, common_1.Inject)(redis_interface_1.IRedisService)),
|
|
36
|
+
__metadata("design:paramtypes", [Object])
|
|
37
|
+
], Cache);
|
|
38
|
+
//# sourceMappingURL=cache.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.js","sourceRoot":"","sources":["../../../src/lib/cache/cache.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AAEpD,qFAA8E;AAGvE,IAAM,KAAK,GAAX,MAAM,KAAK;IAChB,YAAoD,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAC7E,KAAK,CAAC,GAAG,CACP,GAAW,EACX,KAAsC,EACtC,GAAY;QAEZ,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,EAAE,KAAK,EAAE,GAAG,CAAC,CAAC;IACjD,CAAC;IACD,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAW;QACtB,MAAM,IAAI,CAAC,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACxC,CAAC;CACF,CAAA;AAhBY,sBAAK;gBAAL,KAAK;IADjB,IAAA,mBAAU,GAAE;IAEE,WAAA,IAAA,eAAM,EAAC,+BAAa,CAAC,CAAA;;GADvB,KAAK,CAgBjB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var CacheModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.CacheModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const redis_provider_1 = require("../../external/redis/redis.provider");
|
|
13
|
+
const redis_service_1 = require("../../external/redis/redis.service");
|
|
14
|
+
const redis_interface_1 = require("../../external/redis/interfaces/redis.interface");
|
|
15
|
+
const cache_interface_1 = require("./interfaces/cache.interface");
|
|
16
|
+
const cache_1 = require("./cache");
|
|
17
|
+
let CacheModule = CacheModule_1 = class CacheModule {
|
|
18
|
+
static forRoot(params) {
|
|
19
|
+
return {
|
|
20
|
+
module: CacheModule_1,
|
|
21
|
+
imports: [redis_provider_1.RedisModule.forRoot(params)],
|
|
22
|
+
providers: [
|
|
23
|
+
{ provide: cache_interface_1.ICache, useClass: cache_1.Cache },
|
|
24
|
+
{ provide: redis_interface_1.IRedisService, useClass: redis_service_1.RedisService },
|
|
25
|
+
],
|
|
26
|
+
exports: [
|
|
27
|
+
{ provide: cache_interface_1.ICache, useClass: cache_1.Cache },
|
|
28
|
+
{ provide: redis_interface_1.IRedisService, useClass: redis_service_1.RedisService },
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
exports.CacheModule = CacheModule;
|
|
34
|
+
exports.CacheModule = CacheModule = CacheModule_1 = __decorate([
|
|
35
|
+
(0, common_1.Module)({})
|
|
36
|
+
], CacheModule);
|
|
37
|
+
//# sourceMappingURL=cache.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.module.js","sourceRoot":"","sources":["../../../src/lib/cache/cache.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAAuD;AACvD,wEAAkE;AAClE,sEAAkE;AAKlE,qFAAgF;AAChF,kEAAsD;AACtD,mCAAgC;AAGzB,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACtB,MAAM,CAAC,OAAO,CAAC,MAA4C;QACzD,OAAO;YACL,MAAM,EAAE,aAAW;YACnB,OAAO,EAAE,CAAC,4BAAW,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACtC,SAAS,EAAE;gBACT,EAAE,OAAO,EAAE,wBAAM,EAAE,QAAQ,EAAE,aAAK,EAAE;gBACpC,EAAE,OAAO,EAAE,+BAAa,EAAE,QAAQ,EAAE,4BAAY,EAAE;aACnD;YACD,OAAO,EAAE;gBACP,EAAE,OAAO,EAAE,wBAAM,EAAE,QAAQ,EAAE,aAAK,EAAE;gBACpC,EAAE,OAAO,EAAE,+BAAa,EAAE,QAAQ,EAAE,4BAAY,EAAE;aACnD;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAfY,kCAAW;sBAAX,WAAW;IADvB,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,WAAW,CAevB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export interface ICache {
|
|
3
|
+
set(key: string, value: Date | number | Buffer | string, ttl?: number): Promise<void>;
|
|
4
|
+
get(key: string): Promise<string>;
|
|
5
|
+
delete(key: string): Promise<void>;
|
|
6
|
+
}
|
|
7
|
+
export declare const ICache: unique symbol;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cache.interface.js","sourceRoot":"","sources":["../../../../src/lib/cache/interfaces/cache.interface.ts"],"names":[],"mappings":";;;AAYa,QAAA,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC"}
|