@scayle/storefront-nuxt 7.46.0 → 7.47.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/CHANGELOG.md +13 -0
- package/dist/module.json +1 -1
- package/dist/module.mjs +4 -1
- package/dist/runtime/composables/core/useLog.mjs +1 -1
- package/dist/runtime/nitro/plugins/nitroLogger.d.ts +8 -0
- package/dist/runtime/nitro/plugins/nitroLogger.mjs +15 -0
- package/dist/runtime/plugin/log.server.mjs +2 -1
- package/dist/runtime/server/middleware/bootstrap.mjs +3 -9
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @scayle/storefront-nuxt
|
|
2
2
|
|
|
3
|
+
## 7.47.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Create a shared logger instance per-server instead of per-request
|
|
8
|
+
|
|
9
|
+
## 7.46.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @scayle/storefront-core@7.33.0
|
|
15
|
+
|
|
3
16
|
## 7.46.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -160,7 +160,7 @@ const module = defineNuxtModule({
|
|
|
160
160
|
filename: "types/storefront-bootstrap.d.ts",
|
|
161
161
|
getContents: () => `// Auto-generated
|
|
162
162
|
import type { RuntimeConfig } from '@nuxt/schema'
|
|
163
|
-
import type { RpcContext, Cache } from '@scayle/storefront-core'
|
|
163
|
+
import type { RpcContext, Cache, Log } from '@scayle/storefront-core'
|
|
164
164
|
import type { PublicShopConfig } from '@scayle/storefront-nuxt';
|
|
165
165
|
declare module 'h3' {
|
|
166
166
|
interface H3EventContext {
|
|
@@ -168,6 +168,7 @@ const module = defineNuxtModule({
|
|
|
168
168
|
$cache: Cache
|
|
169
169
|
$currentShop: PublicShopConfig,
|
|
170
170
|
$availableShops: PublicShopConfig[]
|
|
171
|
+
$log: Log
|
|
171
172
|
}
|
|
172
173
|
}
|
|
173
174
|
declare module '@scayle/storefront-core' {
|
|
@@ -178,6 +179,7 @@ const module = defineNuxtModule({
|
|
|
178
179
|
nuxt.hook("prepare:types", ({ references }) => {
|
|
179
180
|
references.push({ path: template.dst });
|
|
180
181
|
});
|
|
182
|
+
addServerPlugin(resolve("./runtime/nitro/plugins/nitroLogger"));
|
|
181
183
|
addServerPlugin(
|
|
182
184
|
resolve("./runtime/nitro/plugins/nitroRuntimeStorageConfig")
|
|
183
185
|
);
|
|
@@ -198,6 +200,7 @@ const module = defineNuxtModule({
|
|
|
198
200
|
"server/middleware/redirects",
|
|
199
201
|
"server/middleware/cache",
|
|
200
202
|
"server/utils/cacheStorage",
|
|
203
|
+
"nitro/plugins/nitroLogger",
|
|
201
204
|
"nitro/plugins/nitroRuntimeStorageConfig",
|
|
202
205
|
"nitro/plugins/nitroSetXPoweredByHeader"
|
|
203
206
|
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createConsola } from "consola";
|
|
2
|
+
import createLog from "../../createLog.mjs";
|
|
3
|
+
import { defineNitroPlugin, useRuntimeConfig } from "#imports";
|
|
4
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
5
|
+
const config = useRuntimeConfig();
|
|
6
|
+
const log = createLog(
|
|
7
|
+
createConsola,
|
|
8
|
+
config.storefront.log.name,
|
|
9
|
+
config.storefront.log.level
|
|
10
|
+
);
|
|
11
|
+
log.info(`Logger instance created. Level: ${config.storefront.log.level}`);
|
|
12
|
+
nitroApp.hooks.hook("request", (event) => {
|
|
13
|
+
event.context.$log = log;
|
|
14
|
+
});
|
|
15
|
+
});
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { defineNuxtPlugin } from "nuxt/app";
|
|
2
2
|
export default defineNuxtPlugin((nuxtApp) => {
|
|
3
3
|
if (!nuxtApp.ssrContext) {
|
|
4
|
+
console.log("ssrContext is missing. Could not create log");
|
|
4
5
|
return;
|
|
5
6
|
}
|
|
6
|
-
const log = nuxtApp.ssrContext.event.context.$
|
|
7
|
+
const log = nuxtApp.ssrContext.event.context.$log;
|
|
7
8
|
const coreLog = log.space("sfc");
|
|
8
9
|
coreLog.debug("Attached server-side logger");
|
|
9
10
|
return {
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { defineEventHandler, getRequestURL } from "h3";
|
|
2
|
-
import { createConsola } from "consola";
|
|
3
2
|
import { createRemoteJWKSet, decodeJwt } from "jose";
|
|
4
3
|
import { randomUUID } from "uncrypto";
|
|
5
4
|
import { useSession } from "@scayle/h3-session";
|
|
6
5
|
import { buildContext } from "../../context.mjs";
|
|
7
|
-
import createLog from "../../createLog.mjs";
|
|
8
6
|
import { useCacheStorage, useSessionStorage } from "../utils/cacheStorage.mjs";
|
|
9
7
|
import {
|
|
10
8
|
convertStoresToList,
|
|
@@ -42,7 +40,8 @@ async function handleOauth(event, storefrontConfig, log) {
|
|
|
42
40
|
});
|
|
43
41
|
await useOauth(event, JWKS);
|
|
44
42
|
}
|
|
45
|
-
async function bootstrap(event,
|
|
43
|
+
async function bootstrap(event, url, $shopConfig, $storefrontConfig, apiBasePath, config) {
|
|
44
|
+
const log = event.context.$log;
|
|
46
45
|
const bootstrapLog = log.space("bootstrap");
|
|
47
46
|
bootstrapLog.debug("Bootstrapping request: " + url.toString());
|
|
48
47
|
const $cache = useCacheStorage(
|
|
@@ -130,15 +129,10 @@ export default defineEventHandler(async (event) => {
|
|
|
130
129
|
}
|
|
131
130
|
const $shopConfig = getShopConfig(event, config);
|
|
132
131
|
const apiBasePath = ($storefrontConfig.shopSelector === "path" && $shopConfig.path ? `/${$shopConfig.path}` : "") + ($shopConfig.apiBasePath || $storefrontConfig.apiBasePath || "/api");
|
|
133
|
-
const log =
|
|
134
|
-
createConsola,
|
|
135
|
-
$storefrontConfig.log.name,
|
|
136
|
-
$storefrontConfig.log.level
|
|
137
|
-
);
|
|
132
|
+
const log = event.context.$log;
|
|
138
133
|
if (!event.context.$rpcContext) {
|
|
139
134
|
await bootstrap(
|
|
140
135
|
event,
|
|
141
|
-
log,
|
|
142
136
|
url,
|
|
143
137
|
$shopConfig,
|
|
144
138
|
$storefrontConfig,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scayle/storefront-nuxt",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "7.
|
|
4
|
+
"version": "7.47.0",
|
|
5
5
|
"description": "Nuxt integration for the SCAYLE Commerce Engine and Storefront API",
|
|
6
6
|
"author": "SCAYLE Commerce Engine",
|
|
7
7
|
"license": "MIT",
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"dependencies": {
|
|
63
63
|
"@nuxt/kit": "3.8.2",
|
|
64
64
|
"@scayle/h3-session": "0.3.4",
|
|
65
|
-
"@scayle/storefront-core": "7.
|
|
65
|
+
"@scayle/storefront-core": "7.33.0",
|
|
66
66
|
"@scayle/unstorage-compression-driver": "0.1.1",
|
|
67
67
|
"@vueuse/core": "10.7.0",
|
|
68
68
|
"consola": "3.2.3",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@nuxt/module-builder": "0.5.4",
|
|
84
84
|
"@nuxt/schema": "3.8.2",
|
|
85
|
-
"@nuxt/test-utils": "3.
|
|
85
|
+
"@nuxt/test-utils": "3.9.0",
|
|
86
86
|
"@scayle/eslint-config-storefront": "3.2.6",
|
|
87
87
|
"@scayle/prettier-config-storefront": "2.0.2",
|
|
88
88
|
"@types/node": "20.10.5",
|
|
@@ -92,8 +92,8 @@
|
|
|
92
92
|
"nuxt": "3.8.2",
|
|
93
93
|
"prettier": "3.0.0",
|
|
94
94
|
"publint": "0.2.6",
|
|
95
|
-
"vitest": "1.0
|
|
96
|
-
"vue-tsc": "1.8.
|
|
95
|
+
"vitest": "1.1.0",
|
|
96
|
+
"vue-tsc": "1.8.26"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
99
|
"nuxt": ">=3.8.1",
|