@scayle/storefront-nuxt 7.88.0 → 7.88.1
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 +12 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +1 -1
- package/dist/runtime/server/middleware/redirects.js +38 -16
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.88.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependency `@vueuse/core@11.1.0` to `@vueuse/core@11.2.0`
|
|
8
|
+
- Handle error when reading from or saving to the redirect cache
|
|
9
|
+
|
|
10
|
+
With this change, when the application fails to read from the redirect cache it will log the error and fallback to using the SAPI endpoint.
|
|
11
|
+
**Dependencies**
|
|
12
|
+
|
|
13
|
+
- Updated dependency to @scayle/storefront-core@7.66.1
|
|
14
|
+
|
|
3
15
|
## 7.88.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -5,13 +5,17 @@ import { useRuntimeConfig } from "#imports";
|
|
|
5
5
|
const REDIS_REDIRECT_PREFIX = ":REDIRECT";
|
|
6
6
|
const REDIRECT_NOT_SET = "REDIRECT_NOT_SET";
|
|
7
7
|
const REDIRECT_CACHE_TTL = 120;
|
|
8
|
-
async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCache, log) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
if (cachedResult
|
|
12
|
-
|
|
8
|
+
async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCache, log, waitUntil) {
|
|
9
|
+
try {
|
|
10
|
+
const cachedResult = await redirectCache.get(sourceUrl);
|
|
11
|
+
if (cachedResult) {
|
|
12
|
+
if (cachedResult === REDIRECT_NOT_SET) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return cachedResult;
|
|
13
16
|
}
|
|
14
|
-
|
|
17
|
+
} catch (e) {
|
|
18
|
+
log.error("Error fetching redirect from cache", e);
|
|
15
19
|
}
|
|
16
20
|
log.debug("No cached result for redirect; querying SAPI");
|
|
17
21
|
let sapiResult;
|
|
@@ -27,16 +31,22 @@ async function fetchRedirectWithCache(sourceUrl, storefrontAPIClient, redirectCa
|
|
|
27
31
|
return redirect && redirect?.source && redirect?.target && redirect.source !== redirect.target;
|
|
28
32
|
};
|
|
29
33
|
if (!sapiResult || !isValidRedirect(sapiResult)) {
|
|
30
|
-
|
|
34
|
+
waitUntil(
|
|
35
|
+
redirectCache.set(sourceUrl, REDIRECT_NOT_SET, REDIRECT_CACHE_TTL).catch(
|
|
36
|
+
(e) => log.error("Error saving redirect to cache", e)
|
|
37
|
+
)
|
|
38
|
+
);
|
|
31
39
|
return null;
|
|
32
40
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
waitUntil(
|
|
42
|
+
redirectCache.set(
|
|
43
|
+
sapiResult.source,
|
|
44
|
+
{
|
|
45
|
+
target: sapiResult.target,
|
|
46
|
+
statusCode: sapiResult.statusCode
|
|
47
|
+
},
|
|
48
|
+
REDIRECT_CACHE_TTL
|
|
49
|
+
).catch((e) => log.error("Error saving redirect to cache", e))
|
|
40
50
|
);
|
|
41
51
|
return sapiResult;
|
|
42
52
|
}
|
|
@@ -62,8 +72,20 @@ export async function useRedirects(event) {
|
|
|
62
72
|
queryParamWhitelist
|
|
63
73
|
);
|
|
64
74
|
const [relativeRedirect, absoluteRedirect] = await Promise.all([
|
|
65
|
-
fetchRedirectWithCache(
|
|
66
|
-
|
|
75
|
+
fetchRedirectWithCache(
|
|
76
|
+
relativeSourceUrl,
|
|
77
|
+
sapiClient,
|
|
78
|
+
redirectCache,
|
|
79
|
+
log,
|
|
80
|
+
event.waitUntil
|
|
81
|
+
),
|
|
82
|
+
fetchRedirectWithCache(
|
|
83
|
+
absoluteSourceUrl,
|
|
84
|
+
sapiClient,
|
|
85
|
+
redirectCache,
|
|
86
|
+
log,
|
|
87
|
+
event.waitUntil
|
|
88
|
+
)
|
|
67
89
|
]);
|
|
68
90
|
if (relativeRedirect && absoluteRedirect) {
|
|
69
91
|
log.info(`There are multiple valid redirects for: ${url.toString()}`);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.88.
|
|
4
|
+
"version": "7.88.1",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -65,9 +65,9 @@
|
|
|
65
65
|
"@nuxt/kit": "^3.12.2",
|
|
66
66
|
"@opentelemetry/api": "^1.9.0",
|
|
67
67
|
"@scayle/h3-session": "^0.4.1",
|
|
68
|
-
"@scayle/storefront-core": "7.66.
|
|
68
|
+
"@scayle/storefront-core": "7.66.1",
|
|
69
69
|
"@scayle/unstorage-compression-driver": "^0.1.4",
|
|
70
|
-
"@vueuse/core": "11.
|
|
70
|
+
"@vueuse/core": "11.2.0",
|
|
71
71
|
"consola": "^3.2.3",
|
|
72
72
|
"core-js": "^3.37.1",
|
|
73
73
|
"defu": "^6.1.4",
|
|
@@ -89,7 +89,7 @@
|
|
|
89
89
|
"@nuxt/test-utils": "3.14.4",
|
|
90
90
|
"@scayle/eslint-config-storefront": "4.3.2",
|
|
91
91
|
"@scayle/eslint-plugin-vue-composable": "0.2.1",
|
|
92
|
-
"@types/node": "22.8.
|
|
92
|
+
"@types/node": "22.8.5",
|
|
93
93
|
"dprint": "0.47.5",
|
|
94
94
|
"eslint": "9.13.0",
|
|
95
95
|
"eslint-formatter-gitlab": "5.1.0",
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
"nuxt": "3.13.2",
|
|
101
101
|
"publint": "0.2.12",
|
|
102
102
|
"vitest": "2.1.4",
|
|
103
|
-
"vue-tsc": "2.1.
|
|
103
|
+
"vue-tsc": "2.1.10"
|
|
104
104
|
},
|
|
105
105
|
"peerDependencies": {
|
|
106
106
|
"h3": "^1.10.0",
|