@common-stack/cache-api-server 0.2.1 → 0.2.14
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/CHANGELOG.md +16 -0
- package/lib/index.js +89 -150
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/webpack.config.js +53 -55
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.2.14](https://github.com/cdmbase/common-stack/compare/v0.2.13...v0.2.14) (2022-10-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @common-stack/cache-api-server
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.2.4](https://github.com/cdmbase/common-stack/compare/v0.2.3...v0.2.4) (2022-05-27)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package @common-stack/cache-api-server
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.2.1](https://github.com/cdmbase/common-stack/compare/v0.1.24...v0.2.1) (2022-03-19)
|
|
7
23
|
|
|
8
24
|
**Note:** Version bump only for package @common-stack/cache-api-server
|
package/lib/index.js
CHANGED
|
@@ -1,102 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
/******/
|
|
3
|
-
/******/
|
|
4
|
-
/******/ var installedModules = {};
|
|
5
|
-
/******/
|
|
6
|
-
/******/ // The require function
|
|
7
|
-
/******/ function __webpack_require__(moduleId) {
|
|
8
|
-
/******/
|
|
9
|
-
/******/ // Check if module is in cache
|
|
10
|
-
/******/ if(installedModules[moduleId]) {
|
|
11
|
-
/******/ return installedModules[moduleId].exports;
|
|
12
|
-
/******/ }
|
|
13
|
-
/******/ // Create a new module (and put it into the cache)
|
|
14
|
-
/******/ var module = installedModules[moduleId] = {
|
|
15
|
-
/******/ i: moduleId,
|
|
16
|
-
/******/ l: false,
|
|
17
|
-
/******/ exports: {}
|
|
18
|
-
/******/ };
|
|
19
|
-
/******/
|
|
20
|
-
/******/ // Execute the module function
|
|
21
|
-
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
22
|
-
/******/
|
|
23
|
-
/******/ // Flag the module as loaded
|
|
24
|
-
/******/ module.l = true;
|
|
25
|
-
/******/
|
|
26
|
-
/******/ // Return the exports of the module
|
|
27
|
-
/******/ return module.exports;
|
|
28
|
-
/******/ }
|
|
29
|
-
/******/
|
|
30
|
-
/******/
|
|
31
|
-
/******/ // expose the modules object (__webpack_modules__)
|
|
32
|
-
/******/ __webpack_require__.m = modules;
|
|
33
|
-
/******/
|
|
34
|
-
/******/ // expose the module cache
|
|
35
|
-
/******/ __webpack_require__.c = installedModules;
|
|
36
|
-
/******/
|
|
37
|
-
/******/ // define getter function for harmony exports
|
|
38
|
-
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
39
|
-
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
40
|
-
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
41
|
-
/******/ }
|
|
42
|
-
/******/ };
|
|
43
|
-
/******/
|
|
44
|
-
/******/ // define __esModule on exports
|
|
45
|
-
/******/ __webpack_require__.r = function(exports) {
|
|
46
|
-
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
47
|
-
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
48
|
-
/******/ }
|
|
49
|
-
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
50
|
-
/******/ };
|
|
51
|
-
/******/
|
|
52
|
-
/******/ // create a fake namespace object
|
|
53
|
-
/******/ // mode & 1: value is a module id, require it
|
|
54
|
-
/******/ // mode & 2: merge all properties of value into the ns
|
|
55
|
-
/******/ // mode & 4: return value when already ns object
|
|
56
|
-
/******/ // mode & 8|1: behave like require
|
|
57
|
-
/******/ __webpack_require__.t = function(value, mode) {
|
|
58
|
-
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
59
|
-
/******/ if(mode & 8) return value;
|
|
60
|
-
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
61
|
-
/******/ var ns = Object.create(null);
|
|
62
|
-
/******/ __webpack_require__.r(ns);
|
|
63
|
-
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
64
|
-
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
65
|
-
/******/ return ns;
|
|
66
|
-
/******/ };
|
|
67
|
-
/******/
|
|
68
|
-
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
69
|
-
/******/ __webpack_require__.n = function(module) {
|
|
70
|
-
/******/ var getter = module && module.__esModule ?
|
|
71
|
-
/******/ function getDefault() { return module['default']; } :
|
|
72
|
-
/******/ function getModuleExports() { return module; };
|
|
73
|
-
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
74
|
-
/******/ return getter;
|
|
75
|
-
/******/ };
|
|
76
|
-
/******/
|
|
77
|
-
/******/ // Object.prototype.hasOwnProperty.call
|
|
78
|
-
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
79
|
-
/******/
|
|
80
|
-
/******/ // __webpack_public_path__
|
|
81
|
-
/******/ __webpack_require__.p = "";
|
|
82
|
-
/******/
|
|
83
|
-
/******/
|
|
84
|
-
/******/ // Load entry module and return exports
|
|
85
|
-
/******/ return __webpack_require__(__webpack_require__.s = "./src/index.ts");
|
|
86
|
-
/******/ })
|
|
87
|
-
/************************************************************************/
|
|
88
|
-
/******/ ({
|
|
1
|
+
/******/ (() => { // webpackBootstrap
|
|
2
|
+
/******/ "use strict";
|
|
3
|
+
/******/ var __webpack_modules__ = ({
|
|
89
4
|
|
|
90
5
|
/***/ "./src/config/env-config.ts":
|
|
91
6
|
/*!**********************************!*\
|
|
92
7
|
!*** ./src/config/env-config.ts ***!
|
|
93
8
|
\**********************************/
|
|
94
|
-
|
|
95
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
9
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
96
10
|
|
|
97
|
-
"use strict";
|
|
98
11
|
|
|
99
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
100
13
|
exports.config = void 0;
|
|
101
14
|
const envalid = __webpack_require__(/*! envalid */ "envalid");
|
|
102
15
|
const { str, email, json, num, bool } = envalid;
|
|
@@ -117,14 +30,16 @@ exports.config = envalid.cleanEnv(process.env, {
|
|
|
117
30
|
/*!*****************************!*\
|
|
118
31
|
!*** ./src/config/index.ts ***!
|
|
119
32
|
\*****************************/
|
|
120
|
-
|
|
121
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
33
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
122
34
|
|
|
123
|
-
"use strict";
|
|
124
35
|
|
|
125
36
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
126
37
|
if (k2 === undefined) k2 = k;
|
|
127
|
-
Object.
|
|
38
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
39
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
40
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
41
|
+
}
|
|
42
|
+
Object.defineProperty(o, k2, desc);
|
|
128
43
|
}) : (function(o, m, k, k2) {
|
|
129
44
|
if (k2 === undefined) k2 = k;
|
|
130
45
|
o[k2] = m[k];
|
|
@@ -132,7 +47,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
132
47
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
133
48
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
134
49
|
};
|
|
135
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
136
51
|
__exportStar(__webpack_require__(/*! ./env-config */ "./src/config/env-config.ts"), exports);
|
|
137
52
|
|
|
138
53
|
|
|
@@ -142,12 +57,10 @@ __exportStar(__webpack_require__(/*! ./env-config */ "./src/config/env-config.ts
|
|
|
142
57
|
/*!**************************!*\
|
|
143
58
|
!*** ./src/constants.ts ***!
|
|
144
59
|
\**************************/
|
|
145
|
-
|
|
146
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
60
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
147
61
|
|
|
148
|
-
"use strict";
|
|
149
62
|
|
|
150
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
63
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
151
64
|
exports.Types = void 0;
|
|
152
65
|
var Types;
|
|
153
66
|
(function (Types) {
|
|
@@ -162,14 +75,16 @@ var Types;
|
|
|
162
75
|
/*!*********************************!*\
|
|
163
76
|
!*** ./src/containers/index.ts ***!
|
|
164
77
|
\*********************************/
|
|
165
|
-
|
|
166
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
78
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
167
79
|
|
|
168
|
-
"use strict";
|
|
169
80
|
|
|
170
81
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
171
82
|
if (k2 === undefined) k2 = k;
|
|
172
|
-
Object.
|
|
83
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
84
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
85
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
86
|
+
}
|
|
87
|
+
Object.defineProperty(o, k2, desc);
|
|
173
88
|
}) : (function(o, m, k, k2) {
|
|
174
89
|
if (k2 === undefined) k2 = k;
|
|
175
90
|
o[k2] = m[k];
|
|
@@ -177,7 +92,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
177
92
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
178
93
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
179
94
|
};
|
|
180
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
95
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
181
96
|
__exportStar(__webpack_require__(/*! ./module */ "./src/containers/module.ts"), exports);
|
|
182
97
|
|
|
183
98
|
|
|
@@ -187,12 +102,10 @@ __exportStar(__webpack_require__(/*! ./module */ "./src/containers/module.ts"),
|
|
|
187
102
|
/*!**********************************!*\
|
|
188
103
|
!*** ./src/containers/module.ts ***!
|
|
189
104
|
\**********************************/
|
|
190
|
-
|
|
191
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
105
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
192
106
|
|
|
193
|
-
"use strict";
|
|
194
107
|
|
|
195
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
108
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
196
109
|
exports.moduleFunc = void 0;
|
|
197
110
|
const inversify_1 = __webpack_require__(/*! inversify */ "inversify");
|
|
198
111
|
const services_1 = __webpack_require__(/*! ../services */ "./src/services/index.ts");
|
|
@@ -226,12 +139,10 @@ exports.moduleFunc = moduleFunc;
|
|
|
226
139
|
/*!***************************************!*\
|
|
227
140
|
!*** ./src/engines/ioredis-engine.ts ***!
|
|
228
141
|
\***************************************/
|
|
229
|
-
|
|
230
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
142
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
231
143
|
|
|
232
|
-
"use strict";
|
|
233
144
|
|
|
234
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
145
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
235
146
|
exports.Redis = void 0;
|
|
236
147
|
const IORedis = __webpack_require__(/*! ioredis */ "ioredis");
|
|
237
148
|
const { promisify } = __webpack_require__(/*! util */ "util");
|
|
@@ -275,14 +186,16 @@ exports.Redis = Redis;
|
|
|
275
186
|
/*!**********************!*\
|
|
276
187
|
!*** ./src/index.ts ***!
|
|
277
188
|
\**********************/
|
|
278
|
-
|
|
279
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
189
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
280
190
|
|
|
281
|
-
"use strict";
|
|
282
191
|
|
|
283
192
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
284
193
|
if (k2 === undefined) k2 = k;
|
|
285
|
-
Object.
|
|
194
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
195
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
196
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
197
|
+
}
|
|
198
|
+
Object.defineProperty(o, k2, desc);
|
|
286
199
|
}) : (function(o, m, k, k2) {
|
|
287
200
|
if (k2 === undefined) k2 = k;
|
|
288
201
|
o[k2] = m[k];
|
|
@@ -290,14 +203,14 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
290
203
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
291
204
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
292
205
|
};
|
|
293
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
206
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
294
207
|
exports.Cache = void 0;
|
|
295
208
|
const module_1 = __webpack_require__(/*! ./module */ "./src/module.ts");
|
|
296
209
|
const server_core_1 = __webpack_require__(/*! @common-stack/server-core */ "@common-stack/server-core");
|
|
297
210
|
__exportStar(__webpack_require__(/*! ./constants */ "./src/constants.ts"), exports);
|
|
298
211
|
var services_1 = __webpack_require__(/*! ./services */ "./src/services/index.ts");
|
|
299
|
-
Object.defineProperty(exports, "Cache", { enumerable: true, get: function () { return services_1.Cache; } });
|
|
300
|
-
exports
|
|
212
|
+
Object.defineProperty(exports, "Cache", ({ enumerable: true, get: function () { return services_1.Cache; } }));
|
|
213
|
+
exports["default"] = new server_core_1.Feature(module_1.default);
|
|
301
214
|
|
|
302
215
|
|
|
303
216
|
/***/ }),
|
|
@@ -306,19 +219,17 @@ exports.default = new server_core_1.Feature(module_1.default);
|
|
|
306
219
|
/*!***********************!*\
|
|
307
220
|
!*** ./src/module.ts ***!
|
|
308
221
|
\***********************/
|
|
309
|
-
|
|
310
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
222
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
311
223
|
|
|
312
|
-
"use strict";
|
|
313
224
|
|
|
314
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
225
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
315
226
|
const server_core_1 = __webpack_require__(/*! @common-stack/server-core */ "@common-stack/server-core");
|
|
316
227
|
const constants_1 = __webpack_require__(/*! ./constants */ "./src/constants.ts");
|
|
317
228
|
const containers_1 = __webpack_require__(/*! ./containers */ "./src/containers/index.ts");
|
|
318
229
|
const createServiceFunc = (container) => ({
|
|
319
230
|
cache: container.get(constants_1.Types.CacheService),
|
|
320
231
|
});
|
|
321
|
-
exports
|
|
232
|
+
exports["default"] = new server_core_1.Feature({
|
|
322
233
|
schema: [],
|
|
323
234
|
createServiceFunc,
|
|
324
235
|
createContainerFunc: [containers_1.moduleFunc],
|
|
@@ -331,12 +242,10 @@ exports.default = new server_core_1.Feature({
|
|
|
331
242
|
/*!***************************************!*\
|
|
332
243
|
!*** ./src/services/cache-service.ts ***!
|
|
333
244
|
\***************************************/
|
|
334
|
-
|
|
335
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
245
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
336
246
|
|
|
337
|
-
"use strict";
|
|
338
247
|
|
|
339
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
248
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
340
249
|
exports.Cache = void 0;
|
|
341
250
|
const ioredis_engine_1 = __webpack_require__(/*! ../engines/ioredis-engine */ "./src/engines/ioredis-engine.ts");
|
|
342
251
|
const server_1 = __webpack_require__(/*! @cdm-logger/server */ "@cdm-logger/server");
|
|
@@ -445,14 +354,16 @@ Cache.DEFAULT_SCOPE = 'cde_cache';
|
|
|
445
354
|
/*!*******************************!*\
|
|
446
355
|
!*** ./src/services/index.ts ***!
|
|
447
356
|
\*******************************/
|
|
448
|
-
|
|
449
|
-
/***/ (function(module, exports, __webpack_require__) {
|
|
357
|
+
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
450
358
|
|
|
451
|
-
"use strict";
|
|
452
359
|
|
|
453
360
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
454
361
|
if (k2 === undefined) k2 = k;
|
|
455
|
-
Object.
|
|
362
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
363
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
364
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
365
|
+
}
|
|
366
|
+
Object.defineProperty(o, k2, desc);
|
|
456
367
|
}) : (function(o, m, k, k2) {
|
|
457
368
|
if (k2 === undefined) k2 = k;
|
|
458
369
|
o[k2] = m[k];
|
|
@@ -460,7 +371,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
|
|
|
460
371
|
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
461
372
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
462
373
|
};
|
|
463
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
374
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
464
375
|
__exportStar(__webpack_require__(/*! ./cache-service */ "./src/services/cache-service.ts"), exports);
|
|
465
376
|
|
|
466
377
|
|
|
@@ -470,8 +381,7 @@ __exportStar(__webpack_require__(/*! ./cache-service */ "./src/services/cache-se
|
|
|
470
381
|
/*!*************************************!*\
|
|
471
382
|
!*** external "@cdm-logger/server" ***!
|
|
472
383
|
\*************************************/
|
|
473
|
-
|
|
474
|
-
/***/ (function(module, exports) {
|
|
384
|
+
/***/ ((module) => {
|
|
475
385
|
|
|
476
386
|
module.exports = require("@cdm-logger/server");
|
|
477
387
|
|
|
@@ -481,8 +391,7 @@ module.exports = require("@cdm-logger/server");
|
|
|
481
391
|
/*!********************************************!*\
|
|
482
392
|
!*** external "@common-stack/server-core" ***!
|
|
483
393
|
\********************************************/
|
|
484
|
-
|
|
485
|
-
/***/ (function(module, exports) {
|
|
394
|
+
/***/ ((module) => {
|
|
486
395
|
|
|
487
396
|
module.exports = require("@common-stack/server-core");
|
|
488
397
|
|
|
@@ -492,8 +401,7 @@ module.exports = require("@common-stack/server-core");
|
|
|
492
401
|
/*!**************************!*\
|
|
493
402
|
!*** external "envalid" ***!
|
|
494
403
|
\**************************/
|
|
495
|
-
|
|
496
|
-
/***/ (function(module, exports) {
|
|
404
|
+
/***/ ((module) => {
|
|
497
405
|
|
|
498
406
|
module.exports = require("envalid");
|
|
499
407
|
|
|
@@ -503,8 +411,7 @@ module.exports = require("envalid");
|
|
|
503
411
|
/*!****************************!*\
|
|
504
412
|
!*** external "inversify" ***!
|
|
505
413
|
\****************************/
|
|
506
|
-
|
|
507
|
-
/***/ (function(module, exports) {
|
|
414
|
+
/***/ ((module) => {
|
|
508
415
|
|
|
509
416
|
module.exports = require("inversify");
|
|
510
417
|
|
|
@@ -514,8 +421,7 @@ module.exports = require("inversify");
|
|
|
514
421
|
/*!**************************!*\
|
|
515
422
|
!*** external "ioredis" ***!
|
|
516
423
|
\**************************/
|
|
517
|
-
|
|
518
|
-
/***/ (function(module, exports) {
|
|
424
|
+
/***/ ((module) => {
|
|
519
425
|
|
|
520
426
|
module.exports = require("ioredis");
|
|
521
427
|
|
|
@@ -525,8 +431,7 @@ module.exports = require("ioredis");
|
|
|
525
431
|
/*!**********************!*\
|
|
526
432
|
!*** external "url" ***!
|
|
527
433
|
\**********************/
|
|
528
|
-
|
|
529
|
-
/***/ (function(module, exports) {
|
|
434
|
+
/***/ ((module) => {
|
|
530
435
|
|
|
531
436
|
module.exports = require("url");
|
|
532
437
|
|
|
@@ -536,12 +441,46 @@ module.exports = require("url");
|
|
|
536
441
|
/*!***********************!*\
|
|
537
442
|
!*** external "util" ***!
|
|
538
443
|
\***********************/
|
|
539
|
-
|
|
540
|
-
/***/ (function(module, exports) {
|
|
444
|
+
/***/ ((module) => {
|
|
541
445
|
|
|
542
446
|
module.exports = require("util");
|
|
543
447
|
|
|
544
448
|
/***/ })
|
|
545
449
|
|
|
546
|
-
/******/
|
|
450
|
+
/******/ });
|
|
451
|
+
/************************************************************************/
|
|
452
|
+
/******/ // The module cache
|
|
453
|
+
/******/ var __webpack_module_cache__ = {};
|
|
454
|
+
/******/
|
|
455
|
+
/******/ // The require function
|
|
456
|
+
/******/ function __webpack_require__(moduleId) {
|
|
457
|
+
/******/ // Check if module is in cache
|
|
458
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
459
|
+
/******/ if (cachedModule !== undefined) {
|
|
460
|
+
/******/ return cachedModule.exports;
|
|
461
|
+
/******/ }
|
|
462
|
+
/******/ // Create a new module (and put it into the cache)
|
|
463
|
+
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
464
|
+
/******/ // no module.id needed
|
|
465
|
+
/******/ // no module.loaded needed
|
|
466
|
+
/******/ exports: {}
|
|
467
|
+
/******/ };
|
|
468
|
+
/******/
|
|
469
|
+
/******/ // Execute the module function
|
|
470
|
+
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
471
|
+
/******/
|
|
472
|
+
/******/ // Return the exports of the module
|
|
473
|
+
/******/ return module.exports;
|
|
474
|
+
/******/ }
|
|
475
|
+
/******/
|
|
476
|
+
/************************************************************************/
|
|
477
|
+
/******/
|
|
478
|
+
/******/ // startup
|
|
479
|
+
/******/ // Load entry module and return exports
|
|
480
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
481
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/index.ts");
|
|
482
|
+
/******/ module.exports = __webpack_exports__;
|
|
483
|
+
/******/
|
|
484
|
+
/******/ })()
|
|
485
|
+
;
|
|
547
486
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/config/env-config.ts","webpack:///./src/config/index.ts","webpack:///./src/constants.ts","webpack:///./src/containers/index.ts","webpack:///./src/containers/module.ts","webpack:///./src/engines/ioredis-engine.ts","webpack:///./src/index.ts","webpack:///./src/module.ts","webpack:///./src/services/cache-service.ts","webpack:///./src/services/index.ts","webpack:///external \"@cdm-logger/server\"","webpack:///external \"@common-stack/server-core\"","webpack:///external \"envalid\"","webpack:///external \"inversify\"","webpack:///external \"ioredis\"","webpack:///external \"url\"","webpack:///external \"util\""],"names":[],"mappings":";;QAAA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;;QAEA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;;;QAGA;QACA;;QAEA;QACA;;QAEA;QACA;QACA;QACA,0CAA0C,gCAAgC;QAC1E;QACA;;QAEA;QACA;QACA;QACA,wDAAwD,kBAAkB;QAC1E;QACA,iDAAiD,cAAc;QAC/D;;QAEA;QACA;QACA;QACA;QACA;QACA;QACA;QACA;QACA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I,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,OAAuB;QACjD,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;YAClB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SACnC;aAAM;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAEzD,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACxC;IACL,CAAC;;AA9GL,sBA+GC;AA9GkB,mBAAa,GAAG,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;ACZ/C,qGAAgC;;;;;;;;;;;;ACAhC,+C;;;;;;;;;;;ACAA,sD;;;;;;;;;;;ACAA,oC;;;;;;;;;;;ACAA,sC;;;;;;;;;;;ACAA,oC;;;;;;;;;;;ACAA,gC;;;;;;;;;;;ACAA,iC","file":"index.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = \"./src/index.ts\");\n","import * as envalid from 'envalid';\nconst { str, email, json, num, bool } = envalid;\n\nexport interface IConfig {\n NODE_ENV: string;\n REDIS_URL: string;\n REDIS_CACHE_MAX_AGE_in_sec: number;\n REDIS_SENTINEL_ENABLED: boolean;\n REDIS_SENTINEL_NAME?: string;\n REDIS_CLUSTER_ENABLED?: boolean;\n REDIS_CLUSTER_URL?: any;\n}\n\nexport const config = envalid.cleanEnv<IConfig>(process.env, {\n REDIS_URL: str(),\n REDIS_SENTINEL_ENABLED: bool({ devDefault: false }),\n REDIS_SENTINEL_NAME: str({ default: 'mymaster' }),\n REDIS_CLUSTER_ENABLED: bool({ default: false }),\n REDIS_CLUSTER_URL: json({ desc: \"Send cluster nodes as array of host and port object. ex: [{ host: 'node1', port: 6678}]\" }),\n REDIS_CACHE_MAX_AGE_in_sec: num({ default: 2592000, desc: 'Max. age in seconds. Default is 30 days' }),\n NODE_ENV: str({ choices: ['production', 'test', 'staging', 'development'], default: 'production' }),\n});\n\n","export * from './env-config';\n","export enum Types {\n CacheEngine = 'CacheEngine',\n CacheService = 'CacheService',\n}\n","export * from './module';\n","import { ContainerModule, interfaces } from 'inversify';\n\nimport { Cache } from '../services';\nimport { Types } from '../constants';\nimport { Redis } from '../engines/ioredis-engine';\nimport { ICacheEngine, ICacheService } from '../interfaces';\nimport { CdmLogger } from '@cdm-logger/core';\n\nexport const moduleFunc: (settings: any, pubsub) => interfaces.ContainerModule =\n (settings: any) => new ContainerModule((bind: interfaces.Bind) => {\n\n /**\n *\n * @returns: () => cache;\n */\n bind<interfaces.Factory<Cache>>(Types.CacheService).toFactory<Cache>((context: interfaces.Context) => {\n return () => {\n // TODO: to make it singleton we need to check if Cache already exist then return same.\n const cacheEngine = context.container.get<ICacheEngine>(Types.CacheEngine);\n const logger = context.container.get<CdmLogger.ILogger>('Logger');\n const cache = new Cache(cacheEngine, logger);\n return cache;\n };\n }).whenTargetIsDefault();\n\n bind<ICacheEngine>(Types.CacheEngine)\n .toConstantValue(new Redis(settings.redisConnection))\n // .inSingletonScope()\n .whenTargetIsDefault();\n });\n\n","import * as IORedis from 'ioredis';\nimport { ICacheEngine } from '../interfaces';\nconst { promisify } = require('util');\n\nexport class Redis implements ICacheEngine {\n private client: IORedis.Redis | IORedis.Cluster;\n private getAsync;\n\n constructor(options: IORedis.RedisOptions | IORedis.ClusterOptions, isCluster?: boolean, clusterNodes?: IORedis.ClusterNode[]) {\n if (isCluster) {\n this.client = new IORedis.Cluster(clusterNodes, options);\n } else {\n this.client = new IORedis(options);\n }\n this.getAsync = promisify(this.client.get).bind(this.client);\n }\n\n public async set(key: string, data: any) {\n if (data.maxAge) {\n this.client.set(key, JSON.stringify(data), 'EX', data.maxAge);\n return data;\n }\n this.client.set(key, JSON.stringify(data));\n return data;\n }\n\n public async get(key: string) {\n const cacheString = await this.getAsync(key);\n return JSON.parse(cacheString);\n }\n\n public async drop(key: string) {\n this.client.del(key);\n return true;\n }\n\n public async invalidate(keys?: string[]) {\n (keys || []).forEach(key => this.client.del(key));\n return true;\n }\n}\n","import module from './module';\nimport { Feature } from '@common-stack/server-core';\n\nexport * from './constants';\nexport { Cache } from './services';\nexport default new Feature(module);\n\n","import * as _ from 'lodash';\nimport { interfaces } from 'inversify';\nimport { Feature } from '@common-stack/server-core';\n\nimport { Types } from './constants';\nimport { moduleFunc } from './containers';\n\nconst createServiceFunc = (container: interfaces.Container) => ({\n cache: container.get(Types.CacheService),\n});\n\nexport default new Feature({\n schema: [],\n createServiceFunc,\n createContainerFunc: [moduleFunc],\n});\n","import * as _ from 'lodash';\nimport { CdmLogger } from '@cdm-logger/core';\n\nimport { Types } from '../constants';\nimport { ICacheService, ICacheEngine, ICacheOptions, ICacheSetOptions } from '../interfaces';\nimport { create } from 'domain';\nimport { Redis } from '../engines/ioredis-engine';\nimport { logger as cdmLogger } from '@cdm-logger/server';\nimport { config } from '../config';\nimport * as url from 'url';\n\nexport class Cache implements ICacheService {\n private static DEFAULT_SCOPE = 'cde_cache';\n private static instance: Cache;\n\n private logger: CdmLogger.ILogger;\n private engine: ICacheEngine;\n\n constructor(\n engine: ICacheEngine,\n logger?: CdmLogger.ILogger,\n ) {\n this.engine = engine;\n if (logger) {\n this.logger = logger.child(this.constructor.name);\n } else {\n this.logger = cdmLogger.child(this.constructor.name);\n }\n }\n\n public static get Instance() {\n if (this.instance) {\n return this.instance;\n }\n const { port, hostname } = url.parse(config.REDIS_URL) as { port: any, hostname: string };\n let options;\n let client;\n if (config.REDIS_SENTINEL_ENABLED) {\n options = {\n sentinels: [{ host: hostname, port }],\n name: config.REDIS_SENTINEL_NAME,\n };\n client = new Redis(options);\n } else if (config.REDIS_CLUSTER_ENABLED) {\n options = {};\n client = new Redis(options, true, config.REDIS_CLUSTER_URL);\n } else {\n options = { host: hostname, port };\n client = new Redis(options);\n }\n this.instance = new this(client);\n return this.instance;\n }\n\n private key(key: string, scope?: string) {\n return `${scope || Cache.DEFAULT_SCOPE}.${key}`;\n }\n\n private isExpired(createdAt: number, maxAge: number) {\n const now = parseInt(`${Date.now() / 1000}`, null);\n return now - createdAt > maxAge;\n }\n\n private getOptions(opts: ICacheOptions) {\n return Object.assign(this.defaults, opts || {});\n }\n\n get defaults() {\n return {\n scope: Cache.DEFAULT_SCOPE,\n maxAge: config.REDIS_CACHE_MAX_AGE_in_sec,\n createdAt: parseInt(`${Date.now() / 1000}`, null),\n };\n }\n\n public async set(key: string, payload: any, options?: ICacheSetOptions) {\n const opts = this.getOptions(options);\n const cache = Object.assign({}, { payload }, opts);\n\n const path = this.key(key, opts.scope);\n const result = this.engine.set(path, cache);\n\n return payload;\n }\n\n public async get(key: string, options?: ICacheOptions) {\n const opts = this.getOptions(options);\n const path = this.key(key, opts.scope);\n const cache = await this.engine.get(path);\n\n if (cache == null) {\n return null;\n }\n\n if (this.isExpired(cache.createdAt, cache.maxAge)) {\n this.engine.drop(path);\n return null;\n } else {\n return opts.parse\n ? cache.payload\n : cache.payload; // not really doing anything here\n }\n }\n\n public async drop(key, options?: ICacheOptions) {\n const opts = this.getOptions(options);\n const path = this.key(key, opts.scope);\n\n const ok = this.engine.drop(path);\n return true;\n }\n\n public async invalidate(keys, options?: ICacheOptions) {\n if (keys.length <= 0) {\n return this.engine.invalidate();\n } else {\n const opts = this.getOptions(options);\n const paths = keys.map(key => this.key(key, opts.scope));\n\n return this.engine.invalidate(paths);\n }\n }\n}\n","export * from './cache-service';\n","module.exports = require(\"@cdm-logger/server\");","module.exports = require(\"@common-stack/server-core\");","module.exports = require(\"envalid\");","module.exports = require(\"inversify\");","module.exports = require(\"ioredis\");","module.exports = require(\"url\");","module.exports = require(\"util\");"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"file":"index.js","mappings":";;;;;;;;;;;;;AAAA,8DAAmC;AACnC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,OAAO,CAAC;AAYnC,cAAM,GAAG,OAAO,CAAC,QAAQ,CAAU,OAAO,CAAC,GAAG,EAAE;IACzD,SAAS,EAAE,GAAG,EAAE;IAChB,sBAAsB,EAAE,IAAI,CAAC,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC;IACnD,mBAAmB,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC;IACjD,qBAAqB,EAAE,IAAI,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC/C,iBAAiB,EAAE,IAAI,CAAC,EAAE,IAAI,EAAE,yFAAyF,EAAE,CAAC;IAC5H,0BAA0B,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,yCAAyC,EAAE,CAAC;IACtG,QAAQ,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,aAAa,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC;CACtG,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACrBH,6FAA6B;;;;;;;;;;;;;;ACA7B,IAAY,KAGX;AAHD,WAAY,KAAK;IACb,oCAA2B;IAC3B,sCAA6B;AACjC,CAAC,EA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AG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvC,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IAChB,CAAC;IAEM,KAAK,CAAC,UAAU,CAAC,IAAI,EAAE,OAAuB;QACjD,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE;YAClB,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,EAAE,CAAC;SACnC;aAAM;YACH,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACtC,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;YAEzD,OAAO,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC;SACxC;IACL,CAAC;;AA9GL,sBA+GC;AA9GkB,mBAAa,GAAG,WAAW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;ACZ/C,qGAAgC;;;;;;;;;;;ACAhC;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;;;;;ACAA;;;;;;UCAA;UACA;;UAEA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;UACA;;UAEA;UACA;;UAEA;UACA;UACA;;;;UEtBA;UACA;UACA;UACA","sources":["webpack://@common-stack/cache-api-server/./src/config/env-config.ts","webpack://@common-stack/cache-api-server/./src/config/index.ts","webpack://@common-stack/cache-api-server/./src/constants.ts","webpack://@common-stack/cache-api-server/./src/containers/index.ts","webpack://@common-stack/cache-api-server/./src/containers/module.ts","webpack://@common-stack/cache-api-server/./src/engines/ioredis-engine.ts","webpack://@common-stack/cache-api-server/./src/index.ts","webpack://@common-stack/cache-api-server/./src/module.ts","webpack://@common-stack/cache-api-server/./src/services/cache-service.ts","webpack://@common-stack/cache-api-server/./src/services/index.ts","webpack://@common-stack/cache-api-server/external commonjs \"@cdm-logger/server\"","webpack://@common-stack/cache-api-server/external commonjs \"@common-stack/server-core\"","webpack://@common-stack/cache-api-server/external commonjs \"envalid\"","webpack://@common-stack/cache-api-server/external commonjs \"inversify\"","webpack://@common-stack/cache-api-server/external commonjs \"ioredis\"","webpack://@common-stack/cache-api-server/external commonjs \"url\"","webpack://@common-stack/cache-api-server/external commonjs \"util\"","webpack://@common-stack/cache-api-server/webpack/bootstrap","webpack://@common-stack/cache-api-server/webpack/before-startup","webpack://@common-stack/cache-api-server/webpack/startup","webpack://@common-stack/cache-api-server/webpack/after-startup"],"sourcesContent":["import * as envalid from 'envalid';\nconst { str, email, json, num, bool } = envalid;\n\nexport interface IConfig {\n NODE_ENV: string;\n REDIS_URL: string;\n REDIS_CACHE_MAX_AGE_in_sec: number;\n REDIS_SENTINEL_ENABLED: boolean;\n REDIS_SENTINEL_NAME?: string;\n REDIS_CLUSTER_ENABLED?: boolean;\n REDIS_CLUSTER_URL?: any;\n}\n\nexport const config = envalid.cleanEnv<IConfig>(process.env, {\n REDIS_URL: str(),\n REDIS_SENTINEL_ENABLED: bool({ devDefault: false }),\n REDIS_SENTINEL_NAME: str({ default: 'mymaster' }),\n REDIS_CLUSTER_ENABLED: bool({ default: false }),\n REDIS_CLUSTER_URL: json({ desc: \"Send cluster nodes as array of host and port object. ex: [{ host: 'node1', port: 6678}]\" }),\n REDIS_CACHE_MAX_AGE_in_sec: num({ default: 2592000, desc: 'Max. age in seconds. Default is 30 days' }),\n NODE_ENV: str({ choices: ['production', 'test', 'staging', 'development'], default: 'production' }),\n});\n\n","export * from './env-config';\n","export enum Types {\n CacheEngine = 'CacheEngine',\n CacheService = 'CacheService',\n}\n","export * from './module';\n","import { ContainerModule, interfaces } from 'inversify';\n\nimport { Cache } from '../services';\nimport { Types } from '../constants';\nimport { Redis } from '../engines/ioredis-engine';\nimport { ICacheEngine, ICacheService } from '../interfaces';\nimport { CdmLogger } from '@cdm-logger/core';\n\nexport const moduleFunc: (settings: any, pubsub) => interfaces.ContainerModule =\n (settings: any) => new ContainerModule((bind: interfaces.Bind) => {\n\n /**\n *\n * @returns: () => cache;\n */\n bind<interfaces.Factory<Cache>>(Types.CacheService).toFactory<Cache>((context: interfaces.Context) => {\n return () => {\n // TODO: to make it singleton we need to check if Cache already exist then return same.\n const cacheEngine = context.container.get<ICacheEngine>(Types.CacheEngine);\n const logger = context.container.get<CdmLogger.ILogger>('Logger');\n const cache = new Cache(cacheEngine, logger);\n return cache;\n };\n }).whenTargetIsDefault();\n\n bind<ICacheEngine>(Types.CacheEngine)\n .toConstantValue(new Redis(settings.redisConnection))\n // .inSingletonScope()\n .whenTargetIsDefault();\n });\n\n","import * as IORedis from 'ioredis';\nimport { ICacheEngine } from '../interfaces';\nconst { promisify } = require('util');\n\nexport class Redis implements ICacheEngine {\n private client: IORedis.Redis | IORedis.Cluster;\n private getAsync;\n\n constructor(options: IORedis.RedisOptions | IORedis.ClusterOptions, isCluster?: boolean, clusterNodes?: IORedis.ClusterNode[]) {\n if (isCluster) {\n this.client = new IORedis.Cluster(clusterNodes, options);\n } else {\n this.client = new IORedis(options);\n }\n this.getAsync = promisify(this.client.get).bind(this.client);\n }\n\n public async set(key: string, data: any) {\n if (data.maxAge) {\n this.client.set(key, JSON.stringify(data), 'EX', data.maxAge);\n return data;\n }\n this.client.set(key, JSON.stringify(data));\n return data;\n }\n\n public async get(key: string) {\n const cacheString = await this.getAsync(key);\n return JSON.parse(cacheString);\n }\n\n public async drop(key: string) {\n this.client.del(key);\n return true;\n }\n\n public async invalidate(keys?: string[]) {\n (keys || []).forEach(key => this.client.del(key));\n return true;\n }\n}\n","import module from './module';\nimport { Feature } from '@common-stack/server-core';\n\nexport * from './constants';\nexport { Cache } from './services';\nexport default new Feature(module);\n\n","import * as _ from 'lodash';\nimport { interfaces } from 'inversify';\nimport { Feature } from '@common-stack/server-core';\n\nimport { Types } from './constants';\nimport { moduleFunc } from './containers';\n\nconst createServiceFunc = (container: interfaces.Container) => ({\n cache: container.get(Types.CacheService),\n});\n\nexport default new Feature({\n schema: [],\n createServiceFunc,\n createContainerFunc: [moduleFunc],\n});\n","import * as _ from 'lodash';\nimport { CdmLogger } from '@cdm-logger/core';\n\nimport { Types } from '../constants';\nimport { ICacheService, ICacheEngine, ICacheOptions, ICacheSetOptions } from '../interfaces';\nimport { create } from 'domain';\nimport { Redis } from '../engines/ioredis-engine';\nimport { logger as cdmLogger } from '@cdm-logger/server';\nimport { config } from '../config';\nimport * as url from 'url';\n\nexport class Cache implements ICacheService {\n private static DEFAULT_SCOPE = 'cde_cache';\n private static instance: Cache;\n\n private logger: CdmLogger.ILogger;\n private engine: ICacheEngine;\n\n constructor(\n engine: ICacheEngine,\n logger?: CdmLogger.ILogger,\n ) {\n this.engine = engine;\n if (logger) {\n this.logger = logger.child(this.constructor.name);\n } else {\n this.logger = cdmLogger.child(this.constructor.name);\n }\n }\n\n public static get Instance() {\n if (this.instance) {\n return this.instance;\n }\n const { port, hostname } = url.parse(config.REDIS_URL) as { port: any, hostname: string };\n let options;\n let client;\n if (config.REDIS_SENTINEL_ENABLED) {\n options = {\n sentinels: [{ host: hostname, port }],\n name: config.REDIS_SENTINEL_NAME,\n };\n client = new Redis(options);\n } else if (config.REDIS_CLUSTER_ENABLED) {\n options = {};\n client = new Redis(options, true, config.REDIS_CLUSTER_URL);\n } else {\n options = { host: hostname, port };\n client = new Redis(options);\n }\n this.instance = new this(client);\n return this.instance;\n }\n\n private key(key: string, scope?: string) {\n return `${scope || Cache.DEFAULT_SCOPE}.${key}`;\n }\n\n private isExpired(createdAt: number, maxAge: number) {\n const now = parseInt(`${Date.now() / 1000}`, null);\n return now - createdAt > maxAge;\n }\n\n private getOptions(opts: ICacheOptions) {\n return Object.assign(this.defaults, opts || {});\n }\n\n get defaults() {\n return {\n scope: Cache.DEFAULT_SCOPE,\n maxAge: config.REDIS_CACHE_MAX_AGE_in_sec,\n createdAt: parseInt(`${Date.now() / 1000}`, null),\n };\n }\n\n public async set(key: string, payload: any, options?: ICacheSetOptions) {\n const opts = this.getOptions(options);\n const cache = Object.assign({}, { payload }, opts);\n\n const path = this.key(key, opts.scope);\n const result = this.engine.set(path, cache);\n\n return payload;\n }\n\n public async get(key: string, options?: ICacheOptions) {\n const opts = this.getOptions(options);\n const path = this.key(key, opts.scope);\n const cache = await this.engine.get(path);\n\n if (cache == null) {\n return null;\n }\n\n if (this.isExpired(cache.createdAt, cache.maxAge)) {\n this.engine.drop(path);\n return null;\n } else {\n return opts.parse\n ? cache.payload\n : cache.payload; // not really doing anything here\n }\n }\n\n public async drop(key, options?: ICacheOptions) {\n const opts = this.getOptions(options);\n const path = this.key(key, opts.scope);\n\n const ok = this.engine.drop(path);\n return true;\n }\n\n public async invalidate(keys, options?: ICacheOptions) {\n if (keys.length <= 0) {\n return this.engine.invalidate();\n } else {\n const opts = this.getOptions(options);\n const paths = keys.map(key => this.key(key, opts.scope));\n\n return this.engine.invalidate(paths);\n }\n }\n}\n","export * from './cache-service';\n","module.exports = require(\"@cdm-logger/server\");","module.exports = require(\"@common-stack/server-core\");","module.exports = require(\"envalid\");","module.exports = require(\"inversify\");","module.exports = require(\"ioredis\");","module.exports = require(\"url\");","module.exports = require(\"util\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(\"./src/index.ts\");\n",""],"names":[],"sourceRoot":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@common-stack/cache-api-server",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.14",
|
|
4
4
|
"description": "Sample core for higher packages to depend on",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"author": "CDMBase LLC",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@common-stack/server-core": "^0.2.
|
|
43
|
+
"@common-stack/server-core": "^0.2.14",
|
|
44
44
|
"nodemailer": "^4.6.7",
|
|
45
45
|
"query-string": "^6.1.0",
|
|
46
46
|
"underscore": "^1.9.1"
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "fb916a34d61476fd21e00134852597adea395d71",
|
|
55
55
|
"typescript": {
|
|
56
56
|
"definition": "lib/index.d.ts"
|
|
57
57
|
}
|
package/webpack.config.js
CHANGED
|
@@ -1,58 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var fs = require('fs');
|
|
1
|
+
const nodeExternals = require('webpack-node-externals');
|
|
2
|
+
const webpack = require('webpack');
|
|
3
|
+
const path = require('path');
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
nodeExternals()
|
|
55
|
-
]
|
|
5
|
+
const webpackOpts = {
|
|
6
|
+
mode: 'development',
|
|
7
|
+
entry: {
|
|
8
|
+
index: './src/index.ts',
|
|
9
|
+
},
|
|
10
|
+
target: 'node',
|
|
11
|
+
output: {
|
|
12
|
+
path: path.join(__dirname, 'lib'),
|
|
13
|
+
filename: '[name].js',
|
|
14
|
+
libraryTarget: 'commonjs2',
|
|
15
|
+
},
|
|
16
|
+
resolve: {
|
|
17
|
+
extensions: ['.ts', '.tsx', '.graphql', '.graphqls', '.gql'],
|
|
18
|
+
},
|
|
19
|
+
plugins: [
|
|
20
|
+
new webpack.LoaderOptionsPlugin({
|
|
21
|
+
options: {
|
|
22
|
+
test: /\.tsx?$/,
|
|
23
|
+
ts: {
|
|
24
|
+
compiler: 'typescript',
|
|
25
|
+
configFile: 'tsconfig.json',
|
|
26
|
+
},
|
|
27
|
+
tslint: {
|
|
28
|
+
emitErrors: true,
|
|
29
|
+
failOnHint: true,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
devtool: 'source-map',
|
|
35
|
+
module: {
|
|
36
|
+
rules: [
|
|
37
|
+
{
|
|
38
|
+
test: /\.tsx?$/,
|
|
39
|
+
use: 'ts-loader',
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
test: /\.(gql)$/,
|
|
43
|
+
exclude: /node_modules/,
|
|
44
|
+
use: ['graphql-tag/loader'],
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
test: /\.graphql?/,
|
|
48
|
+
exclude: /node_modules/,
|
|
49
|
+
use: 'raw-loader',
|
|
50
|
+
},
|
|
51
|
+
],
|
|
52
|
+
},
|
|
53
|
+
externals: [nodeExternals({ modulesDir: '../../../node_modules' }), nodeExternals()],
|
|
56
54
|
};
|
|
57
55
|
|
|
58
|
-
module.exports =
|
|
56
|
+
module.exports = webpackOpts;
|