lambda-essentials-ts 7.0.3 → 7.0.4
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.
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export default function createRedisStorage(client: ReturnType<typeof createClient>): import("axios-cache-interceptor").AxiosStorage;
|
|
1
|
+
export default function createRedisStorage(redisEndpoint: string): import("axios-cache-interceptor").AxiosStorage;
|
|
@@ -4,15 +4,24 @@ exports.default = createRedisStorage;
|
|
|
4
4
|
const axios_cache_interceptor_1 = require("axios-cache-interceptor");
|
|
5
5
|
const KEY_PREFIX = 'axios-cache-';
|
|
6
6
|
const MIN_TTL = 60000;
|
|
7
|
-
function createRedisStorage(
|
|
7
|
+
function createRedisStorage(redisEndpoint) {
|
|
8
|
+
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
9
|
+
const redis = require('redis');
|
|
10
|
+
const client = redis.createClient({ url: redisEndpoint });
|
|
8
11
|
// source https://axios-cache-interceptor.js.org/guide/storages#node-redis-storage
|
|
9
12
|
return (0, axios_cache_interceptor_1.buildStorage)({
|
|
10
13
|
async find(key) {
|
|
14
|
+
if (!client.isReady) {
|
|
15
|
+
await client.connect();
|
|
16
|
+
}
|
|
11
17
|
const result = await client.get(`${KEY_PREFIX}${key}`);
|
|
12
18
|
return result ? JSON.parse(result) : undefined;
|
|
13
19
|
},
|
|
14
20
|
// eslint-disable-next-line complexity
|
|
15
21
|
async set(key, value, req) {
|
|
22
|
+
if (!client.isReady) {
|
|
23
|
+
await client.connect();
|
|
24
|
+
}
|
|
16
25
|
await client.set(`${KEY_PREFIX}${key}`, JSON.stringify(value), {
|
|
17
26
|
PXAT:
|
|
18
27
|
// We don't want to keep indefinitely values in the storage if
|
|
@@ -30,6 +39,9 @@ function createRedisStorage(client) {
|
|
|
30
39
|
});
|
|
31
40
|
},
|
|
32
41
|
async remove(key) {
|
|
42
|
+
if (!client.isReady) {
|
|
43
|
+
await client.connect();
|
|
44
|
+
}
|
|
33
45
|
await client.del(`${KEY_PREFIX}${key}`);
|
|
34
46
|
},
|
|
35
47
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambda-essentials-ts",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.4",
|
|
4
4
|
"description": "A selection of the finest modules supporting authorization, API routing, error handling, logging and sending HTTP requests.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"private": false,
|
|
@@ -28,12 +28,12 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@aws-sdk/client-kms": "^3.930.0",
|
|
30
30
|
"@aws-sdk/client-secrets-manager": "^3.930.0",
|
|
31
|
-
"@types/node": "^
|
|
31
|
+
"@types/node": "^25.0.3",
|
|
32
32
|
"axios": "1.13.2",
|
|
33
|
-
"axios-cache-interceptor": "
|
|
33
|
+
"axios-cache-interceptor": "1.11.2",
|
|
34
34
|
"fast-safe-stringify": "~2.1.1",
|
|
35
35
|
"is-error": "~2.2.2",
|
|
36
|
-
"jsonwebtoken": "9.0.
|
|
36
|
+
"jsonwebtoken": "9.0.3",
|
|
37
37
|
"md5": "~2.3.0",
|
|
38
38
|
"openapi-factory": "5.4.60",
|
|
39
39
|
"retry-axios": "~3.2.1",
|
|
@@ -42,17 +42,17 @@
|
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"@types/jest": "^29.5.14",
|
|
44
44
|
"@types/newrelic": "^9.14.8",
|
|
45
|
-
"redis": "^5.9.0",
|
|
46
45
|
"axios-mock-adapter": "^2.1.0",
|
|
47
46
|
"eslint": "^8.57.1",
|
|
48
|
-
"eslint-config-cimpress-atsquad": "^2.2.
|
|
47
|
+
"eslint-config-cimpress-atsquad": "^2.2.3",
|
|
49
48
|
"husky": "^9.1.7",
|
|
50
49
|
"jest": "^29.7.0",
|
|
51
50
|
"lint-staged": "^15.5.2",
|
|
52
51
|
"prettier": "^2.8.8",
|
|
53
|
-
"ts-jest": "^29.4.
|
|
52
|
+
"ts-jest": "^29.4.6",
|
|
54
53
|
"ts-node": "^10.9.2",
|
|
55
|
-
"typescript": "^5.9.3"
|
|
54
|
+
"typescript": "^5.9.3",
|
|
55
|
+
"redis": "^5.10.0"
|
|
56
56
|
},
|
|
57
57
|
"eslintConfig": {
|
|
58
58
|
"extends": "cimpress-atsquad"
|