@shopbite-de/storefront 2.3.0 → 2.5.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/.env.example +13 -1
- package/.github/workflows/build.yaml +2 -2
- package/.github/workflows/ci.yaml +11 -11
- package/.nuxtrc +1 -1
- package/CLAUDE.md +8 -5
- package/app/app.vue +1 -1
- package/app/components/Address/Fields.vue +1 -2
- package/app/components/Header.vue +4 -0
- package/app/components/Home/Categories.vue +2 -2
- package/app/components/Menu/BonCard.vue +1 -2
- package/app/components/Navigation/MobileTop.vue +1 -1
- package/app/components/Order/Confirmation.vue +1 -2
- package/app/components/Product/QuickView.vue +1 -2
- package/app/composables/useAddressAutocomplete.ts +3 -11
- package/app/composables/useCheckoutMethodGuard.ts +1 -1
- package/app/composables/useShippingMethodChoice.ts +2 -2
- package/app/composables/useTrackEvent.ts +4 -3
- package/app/pages/account/recover/password/index.vue +10 -0
- package/app/pages/registrierung/bestaetigen.vue +4 -0
- package/app/utils/openingHours.ts +1 -1
- package/app/utils/schema.ts +2 -2
- package/app/utils/trackingUrl.ts +39 -0
- package/content/index.yml +16 -16
- package/content/zahlung-und-versand.md +3 -3
- package/docs/notes/2026-07-04-issue-239-hydration-mismatches.md +1 -1
- package/docs/notes/2026-09-08-issue-244-category-url-trailing-slash.md +2 -2
- package/docs/notes/2026-09-10-issue-251-shop-data-in-base-layer.md +4 -4
- package/docs/notes/2026-09-10-issue-272-restaurant-schema.md +3 -3
- package/docs/notes/2026-09-10-issue-273-performance-media.md +4 -4
- package/docs/notes/2026-09-10-issue-274-seo-basics.md +6 -6
- package/docs/notes/2026-09-10-issue-275-accessibility.md +3 -3
- package/docs/notes/2026-09-10-issue-290-footer-nap.md +5 -5
- package/docs/notes/2026-09-10-issue-294-matomo-without-config.md +1 -1
- package/docs/notes/2026-09-10-issue-296-track-direct-search.md +1 -1
- package/docs/notes/2026-09-10-issue-312-store-api-criteria-post.md +3 -3
- package/docs/notes/2026-09-10-issue-313-wishlist-scoped-tailwind.md +1 -1
- package/docs/notes/2026-09-10-issue-314-mobile-js-cost.md +1 -1
- package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +1 -1
- package/docs/notes/2026-09-12-issue-325-product-card.md +2 -2
- package/docs/notes/2026-09-12-issue-327-home-hero.md +2 -2
- package/docs/notes/2026-09-13-issue-332-home-info-cards.md +1 -1
- package/docs/notes/2026-09-13-quick-view-flicker.md +1 -1
- package/docs/notes/2026-09-14-demo-noindex.md +2 -2
- package/docs/notes/2026-09-17-quick-view-compact-options.md +1 -1
- package/docs/notes/2026-09-21-issue-273-cache-and-demo-video.md +1 -1
- package/docs/notes/2026-09-21-issue-363-non-fatal-404.md +2 -2
- package/docs/notes/2026-09-21-issue-366-wishlist-404.md +1 -1
- package/docs/notes/2026-09-21-issue-378-dev-modules.md +1 -1
- package/docs/notes/2026-10-05-issue-289-product-deep-links.md +1 -1
- package/docs/notes/2026-10-05-issue-400-menu-item-ingredients-diet.md +1 -1
- package/docs/notes/2026-10-05-issue-401-restaurant-schema-ordering.md +1 -1
- package/docs/notes/2026-10-05-issue-402-llms-txt.md +1 -1
- package/docs/notes/2026-10-05-issue-403-ai-crawlers.md +1 -1
- package/docs/notes/2026-10-05-issue-404-faq.md +1 -1
- package/docs/notes/2026-10-06-old-seo-url-redirect.md +5 -5
- package/docs/notes/2026-10-07-issue-434-property-group-projection.md +1 -1
- package/docs/notes/2026-11-18-dependency-update.md +118 -0
- package/node.dockerfile +7 -7
- package/nuxt.config.ts +65 -9
- package/package.json +41 -40
- package/pnpm-workspace.yaml +0 -2
- package/server/api/address/autocomplete.get.ts +79 -14
- package/server/api/listing/[categoryId].get.ts +5 -28
- package/server/api/search.get.ts +4 -18
- package/server/plugins/ai-crawlers.ts +1 -1
- package/server/plugins/bounded-cache.ts +28 -0
- package/server/plugins/security-headers.ts +54 -0
- package/server/plugins/site-url.ts +2 -2
- package/server/routes/llms.txt.ts +7 -3
- package/server/utils/addressAutocomplete.ts +181 -0
- package/server/utils/listingParams.ts +117 -0
- package/server/utils/securityHeaders.ts +165 -0
- package/server/utils/storeApi.ts +4 -2
- package/test/a11y/presets.test.ts +3 -1
- package/test/layer/nuxt.config.ts +2 -2
- package/test/nuxt/AccountPagesPreset.test.ts +10 -10
- package/test/nuxt/AuthPagesPreset.test.ts +3 -0
- package/test/nuxt/CheckoutFormsPreset.test.ts +5 -5
- package/test/nuxt/CheckoutOnePage.test.ts +2 -0
- package/test/nuxt/CheckoutSummary.test.ts +1 -1
- package/test/nuxt/HeaderFooterPreset.test.ts +23 -14
- package/test/nuxt/HomeFaq.test.ts +1 -1
- package/test/nuxt/NavigationMobileTop.test.ts +1 -1
- package/test/nuxt/OrderPagesPreset.test.ts +2 -2
- package/test/nuxt/RegisterConfirmPage.test.ts +12 -0
- package/test/nuxt/useAddressAutocomplete.test.ts +7 -22
- package/test/nuxt/useCheckoutMethodGuard.test.ts +1 -1
- package/test/nuxt/useShippingMethodChoice.test.ts +1 -1
- package/test/nuxt/useTrackEvent.test.ts +16 -0
- package/test/unit/addressAutocomplete.spec.ts +247 -0
- package/test/unit/boundedCache.spec.ts +231 -0
- package/test/unit/highlight.spec.ts +2 -2
- package/test/unit/llmsTxt.spec.ts +28 -28
- package/test/unit/openingHours.spec.ts +3 -3
- package/test/unit/schema.spec.ts +29 -32
- package/test/unit/securityHeaders.spec.ts +254 -0
- package/test/unit/seo.spec.ts +23 -29
- package/test/unit/sitemap.spec.ts +1 -1
- package/test/unit/trackingUrl.spec.ts +48 -0
- package/patches/@shopware__nuxt-module@1.5.2.patch +0 -13
package/node.dockerfile
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
FROM node:
|
|
2
|
+
FROM node:26-alpine AS build
|
|
3
3
|
|
|
4
|
-
ARG PNPM_VERSION=12.
|
|
4
|
+
ARG PNPM_VERSION=12.21.0
|
|
5
5
|
ARG NUXT_PUBLIC_SHOPWARE_ENDPOINT='https://my.shop/store-api'
|
|
6
6
|
ARG NUXT_PUBLIC_SHOPWARE_ACCESS_TOKEN='TOKEN'
|
|
7
7
|
|
|
@@ -12,20 +12,20 @@ ENV NODE_OPTIONS="--max-old-space-size=4096"
|
|
|
12
12
|
|
|
13
13
|
WORKDIR /app
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
# Node 25+ no longer bundles corepack
|
|
16
|
+
RUN npm install -g pnpm@${PNPM_VERSION}
|
|
16
17
|
|
|
17
18
|
# Copy manifests first so dependency layer is cached independently from source changes.
|
|
18
|
-
# pnpm-workspace.yaml (settings, allowBuilds
|
|
19
|
-
#
|
|
19
|
+
# pnpm-workspace.yaml (settings, allowBuilds) is part of the lockfile contract; without it
|
|
20
|
+
# `--frozen-lockfile` fails. Copy patches/ as well if a pnpm patch is added again.
|
|
20
21
|
COPY package.json pnpm-lock.yaml pnpm-workspace.yaml ./
|
|
21
|
-
COPY patches ./patches
|
|
22
22
|
RUN pnpm install --frozen-lockfile --prefer-offline
|
|
23
23
|
|
|
24
24
|
COPY . .
|
|
25
25
|
|
|
26
26
|
RUN pnpm build
|
|
27
27
|
|
|
28
|
-
FROM node:
|
|
28
|
+
FROM node:26-alpine AS production
|
|
29
29
|
|
|
30
30
|
WORKDIR /app
|
|
31
31
|
|
package/nuxt.config.ts
CHANGED
|
@@ -60,12 +60,63 @@ export default defineNuxtConfig({
|
|
|
60
60
|
// Store API caches after menu changes. Empty = route off.
|
|
61
61
|
cachePurgeSecret: "",
|
|
62
62
|
geoapifyApiKey: "",
|
|
63
|
+
// Per-IP token bucket of /api/address/autocomplete: `capacity` lookups at
|
|
64
|
+
// once, refilled by `refillPerMinute`; only lookups that reach Geoapify
|
|
65
|
+
// count. In memory per server process; capacity 0 turns it off (e.g. when
|
|
66
|
+
// the reverse proxy limits the route).
|
|
67
|
+
addressAutocomplete: {
|
|
68
|
+
rateLimit: {
|
|
69
|
+
capacity: 20,
|
|
70
|
+
refillPerMinute: 20,
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
// Bound of the Nitro cache (server/plugins/bounded-cache.ts): an LRU in
|
|
74
|
+
// memory with at most `maxEntries` entries and `maxSizeMb` of data;
|
|
75
|
+
// NUXT_CACHE_STORAGE_*, maxEntries 0 = unbounded. A cache storage the
|
|
76
|
+
// shop mounts itself (nitro.storage.cache) is kept.
|
|
77
|
+
cacheStorage: {
|
|
78
|
+
maxEntries: 5000,
|
|
79
|
+
maxSizeMb: 128,
|
|
80
|
+
},
|
|
81
|
+
// Sortings the listing and search routes accept (`order`), comma-
|
|
82
|
+
// separated; empty = Shopware's standard sortings. Add the keys of
|
|
83
|
+
// custom sortings created in the Shopware Administration.
|
|
84
|
+
listingSortings: "",
|
|
63
85
|
// AI crawlers named in robots.txt (#403, server/plugins/ai-crawlers.ts):
|
|
64
86
|
// search = AI search and assistant fetches, training = model training.
|
|
65
87
|
aiCrawlers: {
|
|
66
88
|
search: true,
|
|
67
89
|
training: true,
|
|
68
90
|
},
|
|
91
|
+
// Headers of every response (server/plugins/security-headers.ts),
|
|
92
|
+
// NUXT_SECURITY_HEADERS_*; an empty value leaves the header out.
|
|
93
|
+
securityHeaders: {
|
|
94
|
+
// Only sent when public.storeUrl is https.
|
|
95
|
+
strictTransportSecurity: "max-age=31536000; includeSubDomains",
|
|
96
|
+
contentTypeOptions: "nosniff",
|
|
97
|
+
// A shop embedded in another site sets frameOptions "" and lists the
|
|
98
|
+
// embedding origin in frameAncestors (CSP `frame-ancestors`).
|
|
99
|
+
frameOptions: "DENY",
|
|
100
|
+
frameAncestors: "'none'",
|
|
101
|
+
referrerPolicy: "strict-origin-when-cross-origin",
|
|
102
|
+
// No feature of the storefront uses these (address suggestions are
|
|
103
|
+
// typed, not located); Web Share and the clipboard stay allowed.
|
|
104
|
+
permissionsPolicy:
|
|
105
|
+
"camera=(), microphone=(), geolocation=(), usb=(), browsing-topics=()",
|
|
106
|
+
// Server-rendered HTML may contain the visitor's cart or login
|
|
107
|
+
// (useUserContextInSSR), so no shared or browser cache keeps it.
|
|
108
|
+
htmlCacheControl: "private, no-store",
|
|
109
|
+
// Report-only policy for pages: self, the Shopware endpoint, Matomo
|
|
110
|
+
// and inline scripts by hash. Extra hosts (e.g. a RUM collector) are
|
|
111
|
+
// space-separated lists.
|
|
112
|
+
contentSecurityPolicyReportOnly: {
|
|
113
|
+
enabled: true,
|
|
114
|
+
scriptSrc: "",
|
|
115
|
+
connectSrc: "",
|
|
116
|
+
imgSrc: "",
|
|
117
|
+
reportUri: "",
|
|
118
|
+
},
|
|
119
|
+
},
|
|
69
120
|
public: {
|
|
70
121
|
shopBite: {
|
|
71
122
|
cacheTtl: {
|
|
@@ -92,6 +143,7 @@ export default defineNuxtConfig({
|
|
|
92
143
|
searchFallbackCategoryId: "",
|
|
93
144
|
// Optional Geoapify bounding box "lon1,lat1,lon2,lat2" that narrows
|
|
94
145
|
// the address suggestions in the checkout (empty = no filter, #251).
|
|
146
|
+
// Applied by the server route, never taken from the request.
|
|
95
147
|
addressAutocomplete: {
|
|
96
148
|
boundingBox: "",
|
|
97
149
|
},
|
|
@@ -126,14 +178,14 @@ export default defineNuxtConfig({
|
|
|
126
178
|
telephone: "",
|
|
127
179
|
googleBusinessProfileUrl: "",
|
|
128
180
|
// Other names the shop is known by on maps and directories, comma-
|
|
129
|
-
// separated ("
|
|
181
|
+
// separated ("Esempio / Alter Hof, Alter Hof"), so search
|
|
130
182
|
// engines and AI assistants match them to this shop. Restaurant
|
|
131
183
|
// schema `alternateName` and /llms.txt.
|
|
132
184
|
alternateNames: "",
|
|
133
185
|
// Restaurant schema only, e.g. "€€" (#272).
|
|
134
186
|
priceRange: "",
|
|
135
187
|
// Restaurant schema only (#401): comma-separated delivery areas
|
|
136
|
-
// ("
|
|
188
|
+
// ("12345 Musterstadt, 12346 Beispieldorf"), coordinates and
|
|
137
189
|
// "true"/"false" or a text for table reservations.
|
|
138
190
|
deliveryAreas: "",
|
|
139
191
|
geo: {
|
|
@@ -288,16 +340,20 @@ export default defineNuxtConfig({
|
|
|
288
340
|
},
|
|
289
341
|
],
|
|
290
342
|
},
|
|
291
|
-
workbox
|
|
343
|
+
// `workbox` before @vite-pwa/nuxt 2.
|
|
344
|
+
generateSW: {
|
|
292
345
|
globPatterns: ["**/*.{js,css,html,png,svg,ico}"],
|
|
293
346
|
globIgnores: ["**/_payload.json"],
|
|
347
|
+
// The module adds a `**/_payload.json` pattern because Nuxt Content
|
|
348
|
+
// prerenders its database dumps; no page payload exists, and since
|
|
349
|
+
// 2.0 an empty pattern fails the build unless globStrict is off (the
|
|
350
|
+
// warning of 1.x).
|
|
351
|
+
globStrict: false,
|
|
352
|
+
// default of 1.x, off by default since 2.0
|
|
353
|
+
cleanupOutdatedCaches: true,
|
|
354
|
+
// No runtime caching of pages: server-rendered HTML may contain the
|
|
355
|
+
// visitor's cart or login and must not be kept in CacheStorage.
|
|
294
356
|
navigateFallback: null,
|
|
295
|
-
runtimeCaching: [
|
|
296
|
-
{
|
|
297
|
-
urlPattern: "/",
|
|
298
|
-
handler: "NetworkFirst",
|
|
299
|
-
},
|
|
300
|
-
],
|
|
301
357
|
},
|
|
302
358
|
devOptions: {
|
|
303
359
|
enabled: true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shopbite-de/storefront",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.5.0",
|
|
4
4
|
"main": "nuxt.config.ts",
|
|
5
5
|
"description": "Shopware storefront for food delivery shops",
|
|
6
6
|
"keywords": [
|
|
@@ -18,55 +18,56 @@
|
|
|
18
18
|
"license": "MIT",
|
|
19
19
|
"type": "module",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@nuxt/content": "3.
|
|
22
|
-
"@nuxt/fonts": "^
|
|
23
|
-
"@nuxt/image": "^2.1
|
|
21
|
+
"@nuxt/content": "3.17.0",
|
|
22
|
+
"@nuxt/fonts": "^1.2.0",
|
|
23
|
+
"@nuxt/image": "^2.2.1",
|
|
24
24
|
"@nuxt/scripts": "1.3.12",
|
|
25
|
-
"@nuxtjs/robots": "^
|
|
26
|
-
"@nuxtjs/sitemap": "^
|
|
27
|
-
"@shopware/api-client": "^1.
|
|
28
|
-
"@shopware/api-gen": "^1.
|
|
29
|
-
"@shopware/composables": "^1.
|
|
30
|
-
"@shopware/helpers": "^1.
|
|
31
|
-
"@shopware/nuxt-module": "^1.
|
|
32
|
-
"@tailwindcss/vite": "^4.3.
|
|
33
|
-
"@unhead/vue": "^3.4.
|
|
34
|
-
"@vite-pwa/nuxt": "^
|
|
25
|
+
"@nuxtjs/robots": "^7.0.2",
|
|
26
|
+
"@nuxtjs/sitemap": "^9.1.0",
|
|
27
|
+
"@shopware/api-client": "^1.8.0",
|
|
28
|
+
"@shopware/api-gen": "^1.6.0",
|
|
29
|
+
"@shopware/composables": "^1.15.0",
|
|
30
|
+
"@shopware/helpers": "^1.9.0",
|
|
31
|
+
"@shopware/nuxt-module": "^1.6.1",
|
|
32
|
+
"@tailwindcss/vite": "^4.3.5",
|
|
33
|
+
"@unhead/vue": "^3.4.3",
|
|
34
|
+
"@vite-pwa/nuxt": "^2.0.1",
|
|
35
35
|
"@vueuse/core": "^15.0.0",
|
|
36
|
-
"dotenv": "^18.0.
|
|
36
|
+
"dotenv": "^18.0.10",
|
|
37
37
|
"fflate": "^0.8.3",
|
|
38
|
-
"nuxt": "^4.
|
|
39
|
-
"nuxt-vitalizer": "
|
|
40
|
-
"reka-ui": "^2.
|
|
41
|
-
"
|
|
38
|
+
"nuxt": "^4.6.4",
|
|
39
|
+
"nuxt-vitalizer": "4.0.0",
|
|
40
|
+
"reka-ui": "^2.11.0",
|
|
41
|
+
"unstorage": "^1.17.6",
|
|
42
|
+
"uuid": "^14.0.3"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
44
|
-
"@axe-core/playwright": "^4.
|
|
45
|
-
"@nuxt/devtools-kit": "^3.4.
|
|
45
|
+
"@axe-core/playwright": "^4.14.0",
|
|
46
|
+
"@nuxt/devtools-kit": "^3.4.4",
|
|
46
47
|
"@nuxt/eslint": "^1.17.0",
|
|
47
48
|
"@nuxt/hints": "1.1.5",
|
|
48
|
-
"@nuxt/test-utils": "^4.
|
|
49
|
-
"@playwright/test": "^1.
|
|
49
|
+
"@nuxt/test-utils": "^4.4.0",
|
|
50
|
+
"@playwright/test": "^1.65.1",
|
|
50
51
|
"@types/js-cookie": "^3.0.6",
|
|
51
|
-
"@types/node": "^26.6.
|
|
52
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
53
|
-
"@typescript-eslint/parser": "^8.
|
|
54
|
-
"@vitejs/plugin-vue": "^6.0.
|
|
55
|
-
"@vitest/ui": "5.0
|
|
56
|
-
"@vue/compiler-dom": "^3.5.
|
|
57
|
-
"@vue/server-renderer": "^3.5.
|
|
58
|
-
"@vue/test-utils": "^2.
|
|
59
|
-
"@vue/typescript-plugin": "^3.3.
|
|
60
|
-
"eslint": "^10.
|
|
52
|
+
"@types/node": "^26.6.6",
|
|
53
|
+
"@typescript-eslint/eslint-plugin": "^8.73.0",
|
|
54
|
+
"@typescript-eslint/parser": "^8.73.0",
|
|
55
|
+
"@vitejs/plugin-vue": "^6.0.11",
|
|
56
|
+
"@vitest/ui": "5.1.0",
|
|
57
|
+
"@vue/compiler-dom": "^3.5.45",
|
|
58
|
+
"@vue/server-renderer": "^3.5.45",
|
|
59
|
+
"@vue/test-utils": "^2.6.0",
|
|
60
|
+
"@vue/typescript-plugin": "^3.3.14",
|
|
61
|
+
"eslint": "^10.15.0",
|
|
61
62
|
"eslint-config-prettier": "^10.1.8",
|
|
62
|
-
"happy-dom": "^
|
|
63
|
-
"jsdom": "^
|
|
64
|
-
"playwright-core": "^1.
|
|
65
|
-
"prettier": "^3.
|
|
66
|
-
"tailwindcss": "^4.3.
|
|
63
|
+
"happy-dom": "^21.0.4",
|
|
64
|
+
"jsdom": "^31.0.1",
|
|
65
|
+
"playwright-core": "^1.65.1",
|
|
66
|
+
"prettier": "^3.10.1",
|
|
67
|
+
"tailwindcss": "^4.3.5",
|
|
67
68
|
"typescript": "^6.0.3",
|
|
68
|
-
"vitest": "^5.0
|
|
69
|
-
"vue-tsc": "3.3.
|
|
69
|
+
"vitest": "^5.1.0",
|
|
70
|
+
"vue-tsc": "3.3.14"
|
|
70
71
|
},
|
|
71
72
|
"scripts": {
|
|
72
73
|
"build": "nuxt build",
|
package/pnpm-workspace.yaml
CHANGED
|
@@ -1,34 +1,99 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Geoapify address autocomplete proxy: keeps the API key on the server.
|
|
3
|
+
* Only `text` (3–200 characters), `lang` (two letters) and `limit` (1–10) are
|
|
4
|
+
* passed on; the area filter comes from the runtime config
|
|
5
|
+
* (`public.shopBite.addressAutocomplete.boundingBox`). Identical lookups are
|
|
6
|
+
* answered from a small in-memory cache for 5 minutes, and lookups that reach
|
|
7
|
+
* Geoapify are rate limited per client IP (`addressAutocomplete.rateLimit`,
|
|
8
|
+
* capacity 0 = off). Upstream errors are logged with the key redacted and
|
|
9
|
+
* answered with a generic 502.
|
|
10
|
+
*/
|
|
11
|
+
import type { AutocompleteParams } from "../../utils/addressAutocomplete";
|
|
12
|
+
|
|
13
|
+
const GEOAPIFY_URL = "https://api.geoapify.com/v1/geocode/autocomplete";
|
|
14
|
+
const CACHE_TTL_MS = 5 * 60 * 1000;
|
|
15
|
+
const CACHE_MAX_ENTRIES = 500;
|
|
16
|
+
|
|
17
|
+
type Suggestions = ReturnType<typeof pickAddressFields>;
|
|
18
|
+
|
|
19
|
+
const cache = createTtlCache<Suggestions>({
|
|
20
|
+
ttlMs: CACHE_TTL_MS,
|
|
21
|
+
maxEntries: CACHE_MAX_ENTRIES,
|
|
22
|
+
});
|
|
23
|
+
let limiter: ReturnType<typeof createTokenBucketLimiter> | null | undefined;
|
|
24
|
+
|
|
25
|
+
function rateLimiter() {
|
|
26
|
+
if (limiter !== undefined) return limiter;
|
|
27
|
+
const { capacity = 20, refillPerMinute = 20 } =
|
|
28
|
+
useRuntimeConfig().addressAutocomplete?.rateLimit ?? {};
|
|
29
|
+
limiter =
|
|
30
|
+
Number(capacity) > 0
|
|
31
|
+
? createTokenBucketLimiter({
|
|
32
|
+
capacity: Number(capacity),
|
|
33
|
+
refillPerMinute: Number(refillPerMinute),
|
|
34
|
+
})
|
|
35
|
+
: null;
|
|
36
|
+
return limiter;
|
|
37
|
+
}
|
|
38
|
+
|
|
1
39
|
export default defineEventHandler(async (event) => {
|
|
2
40
|
const config = useRuntimeConfig();
|
|
3
41
|
const apiKey = config.geoapifyApiKey;
|
|
4
|
-
const query = getQuery(event);
|
|
5
42
|
|
|
6
43
|
if (!apiKey) {
|
|
7
44
|
return { features: [] };
|
|
8
45
|
}
|
|
9
46
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
47
|
+
let params: AutocompleteParams | null;
|
|
48
|
+
try {
|
|
49
|
+
params = parseAutocompleteQuery(getQuery(event));
|
|
50
|
+
} catch {
|
|
51
|
+
throw createError({ statusCode: 400, statusMessage: "Bad Request" });
|
|
52
|
+
}
|
|
53
|
+
if (!params) {
|
|
13
54
|
return { features: [] };
|
|
14
55
|
}
|
|
15
56
|
|
|
16
|
-
const
|
|
17
|
-
|
|
57
|
+
const filter = boundingBoxFilter(
|
|
58
|
+
config.public.shopBite.addressAutocomplete?.boundingBox,
|
|
18
59
|
);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
60
|
+
const key = JSON.stringify([params.text, params.lang, params.limit, filter]);
|
|
61
|
+
const cached = cache.get(key);
|
|
62
|
+
if (cached) return cached;
|
|
63
|
+
|
|
64
|
+
const limit = rateLimiter();
|
|
65
|
+
if (
|
|
66
|
+
limit &&
|
|
67
|
+
!limit.take(getRequestIP(event, { xForwardedFor: true }) ?? "")
|
|
68
|
+
) {
|
|
69
|
+
setResponseHeader(event, "Retry-After", 10);
|
|
70
|
+
throw createError({
|
|
71
|
+
statusCode: 429,
|
|
72
|
+
statusMessage: "Too Many Requests",
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const url = new URL(GEOAPIFY_URL);
|
|
77
|
+
url.searchParams.set("apiKey", apiKey);
|
|
78
|
+
url.searchParams.set("text", params.text);
|
|
79
|
+
url.searchParams.set("lang", params.lang);
|
|
80
|
+
url.searchParams.set("limit", String(params.limit));
|
|
81
|
+
if (filter) url.searchParams.set("filter", filter);
|
|
24
82
|
|
|
25
83
|
try {
|
|
26
|
-
|
|
84
|
+
const suggestions = pickAddressFields(await $fetch(url.toString()));
|
|
85
|
+
cache.set(key, suggestions);
|
|
86
|
+
return suggestions;
|
|
27
87
|
} catch (error) {
|
|
28
88
|
const err = error as { response?: { status?: number }; message?: string };
|
|
89
|
+
console.error("Address autocomplete request failed", {
|
|
90
|
+
status: err.response?.status,
|
|
91
|
+
url: redactApiKey(url.toString()),
|
|
92
|
+
message: redactApiKey(String(err.message ?? "")),
|
|
93
|
+
});
|
|
29
94
|
throw createError({
|
|
30
|
-
statusCode:
|
|
31
|
-
statusMessage:
|
|
95
|
+
statusCode: 502,
|
|
96
|
+
statusMessage: "Address suggestions unavailable",
|
|
32
97
|
});
|
|
33
98
|
}
|
|
34
99
|
});
|
|
@@ -60,34 +60,11 @@ const BASE_CRITERIA = {
|
|
|
60
60
|
limit: 100,
|
|
61
61
|
};
|
|
62
62
|
|
|
63
|
-
/** Validates and returns a non-empty string up to maxLength, or undefined. */
|
|
64
|
-
function sanitizeString(value: unknown, maxLength: number): string | undefined {
|
|
65
|
-
if (typeof value !== "string" || value === "") return undefined;
|
|
66
|
-
const trimmed = value.trim();
|
|
67
|
-
return trimmed.length <= maxLength ? trimmed : undefined;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Validates page number: positive integer in [1, 1000]. */
|
|
71
|
-
function sanitizePage(value: unknown): number | undefined {
|
|
72
|
-
const n = Number(value);
|
|
73
|
-
return Number.isInteger(n) && n >= 1 && n <= 1000 ? n : undefined;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
function resolveAllowedParams(query: Record<string, unknown>) {
|
|
77
|
-
return {
|
|
78
|
-
order: sanitizeString(query.order, 64),
|
|
79
|
-
properties: sanitizeString(query.properties, 2048),
|
|
80
|
-
manufacturer: sanitizeString(query.manufacturer, 2048),
|
|
81
|
-
query: sanitizeString(query.query, 256),
|
|
82
|
-
p: sanitizePage(query.p),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
|
|
86
63
|
export default defineCachedEventHandler(
|
|
87
64
|
async (event) => {
|
|
88
|
-
const categoryId = getRouterParam(event, "categoryId")
|
|
65
|
+
const categoryId = categoryIdParam(getRouterParam(event, "categoryId"));
|
|
89
66
|
|
|
90
|
-
const { order, properties, manufacturer, query, p } =
|
|
67
|
+
const { order, properties, manufacturer, query, p } = listingParams(
|
|
91
68
|
getQuery(event) as Record<string, unknown>,
|
|
92
69
|
);
|
|
93
70
|
|
|
@@ -108,10 +85,10 @@ export default defineCachedEventHandler(
|
|
|
108
85
|
maxAge: useRuntimeConfig().public.shopBite.cacheTtl.listing,
|
|
109
86
|
name: "listing",
|
|
110
87
|
getKey: (event) => {
|
|
111
|
-
const categoryId = getRouterParam(event, "categoryId")
|
|
88
|
+
const categoryId = categoryIdParam(getRouterParam(event, "categoryId"));
|
|
112
89
|
const q = getQuery(event) as Record<string, unknown>;
|
|
113
|
-
|
|
114
|
-
|
|
90
|
+
// Validated before it becomes a key (400 otherwise).
|
|
91
|
+
const { order, properties, manufacturer, query, p } = listingParams(q);
|
|
115
92
|
return [
|
|
116
93
|
categoryId,
|
|
117
94
|
order ?? "",
|
package/server/api/search.get.ts
CHANGED
|
@@ -50,25 +50,12 @@ const BASE_CRITERIA = {
|
|
|
50
50
|
limit: 100,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
-
function sanitizeString(value: unknown, maxLength: number): string | undefined {
|
|
54
|
-
if (typeof value !== "string" || value === "") return undefined;
|
|
55
|
-
const trimmed = value.trim();
|
|
56
|
-
return trimmed.length <= maxLength ? trimmed : undefined;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function sanitizePage(value: unknown): number | undefined {
|
|
60
|
-
const n = Number(value);
|
|
61
|
-
return Number.isInteger(n) && n >= 1 && n <= 1000 ? n : undefined;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
53
|
export default defineCachedEventHandler(
|
|
65
54
|
async (event) => {
|
|
66
55
|
const { endpoint, accessToken } = useRuntimeConfig().public.shopware;
|
|
67
56
|
const q = getQuery(event) as Record<string, unknown>;
|
|
68
57
|
|
|
69
|
-
const search =
|
|
70
|
-
const order = sanitizeString(q.order, 64);
|
|
71
|
-
const p = sanitizePage(q.p);
|
|
58
|
+
const { search, order, p } = searchParams(q);
|
|
72
59
|
|
|
73
60
|
if (!search) {
|
|
74
61
|
return {
|
|
@@ -97,10 +84,9 @@ export default defineCachedEventHandler(
|
|
|
97
84
|
name: "search",
|
|
98
85
|
getKey: (event) => {
|
|
99
86
|
const q = getQuery(event) as Record<string, unknown>;
|
|
100
|
-
|
|
101
|
-
const order =
|
|
102
|
-
|
|
103
|
-
return [search, order, p].join("|");
|
|
87
|
+
// Validated before it becomes a key (400 otherwise).
|
|
88
|
+
const { search, order, p } = searchParams(q);
|
|
89
|
+
return [search ?? "", order ?? "", p ?? 1].join("|");
|
|
104
90
|
},
|
|
105
91
|
},
|
|
106
92
|
);
|
|
@@ -8,7 +8,7 @@ import { buildAiCrawlerGroups } from "../utils/aiCrawlers";
|
|
|
8
8
|
*/
|
|
9
9
|
export default defineNitroPlugin((nitroApp) => {
|
|
10
10
|
nitroApp.hooks.hook("robots:config", (ctx) => {
|
|
11
|
-
const { aiCrawlers } = useRuntimeConfig(
|
|
11
|
+
const { aiCrawlers } = useRuntimeConfig();
|
|
12
12
|
const wildcard = ctx.groups.find((group) =>
|
|
13
13
|
[group.userAgent ?? "*"].flat().includes("*"),
|
|
14
14
|
);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import lruCacheDriver from "unstorage/drivers/lru-cache";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Bounded storage for the Nitro cache (cached handlers and functions): an LRU
|
|
5
|
+
* with at most `cacheStorage.maxEntries` entries and `maxSizeMb` of
|
|
6
|
+
* serialised data (NUXT_CACHE_STORAGE_*). Without it the cache lives in the
|
|
7
|
+
* root memory storage without any bound. The least recently used entries
|
|
8
|
+
* are dropped first and are fetched again on their next request. A shop
|
|
9
|
+
* that mounts its own cache storage (`nitro.storage.cache`, e.g. Redis)
|
|
10
|
+
* keeps it; `maxEntries` 0 turns the LRU off.
|
|
11
|
+
*/
|
|
12
|
+
export default defineNitroPlugin(() => {
|
|
13
|
+
const { maxEntries = 5000, maxSizeMb = 128 } =
|
|
14
|
+
(
|
|
15
|
+
useRuntimeConfig() as {
|
|
16
|
+
cacheStorage?: { maxEntries?: number; maxSizeMb?: number };
|
|
17
|
+
}
|
|
18
|
+
).cacheStorage ?? {};
|
|
19
|
+
const max = Math.floor(Number(maxEntries));
|
|
20
|
+
const maxSize = Math.floor(Number(maxSizeMb) * 1024 * 1024);
|
|
21
|
+
if (!(max > 0) || !(maxSize > 0)) return;
|
|
22
|
+
|
|
23
|
+
const storage = useStorage();
|
|
24
|
+
// An unmounted `cache:` resolves to the root storage (base "").
|
|
25
|
+
if (storage.getMount("cache:").base !== "") return;
|
|
26
|
+
|
|
27
|
+
storage.mount("cache", lruCacheDriver({ max, maxSize }));
|
|
28
|
+
});
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security headers on every response (`runtimeConfig.securityHeaders`,
|
|
3
|
+
* `server/utils/securityHeaders.ts`). Server-rendered HTML additionally gets
|
|
4
|
+
* `Cache-Control: private, no-store` (it may contain the visitor's cart or
|
|
5
|
+
* login, `useUserContextInSSR`) unless a route rule sets one, an optional
|
|
6
|
+
* Content-Security-Policy-Report-Only with hashes of its inline scripts,
|
|
7
|
+
* and no `x-powered-by`.
|
|
8
|
+
*/
|
|
9
|
+
import type { SecurityHeadersConfig } from "../utils/securityHeaders";
|
|
10
|
+
|
|
11
|
+
interface RenderResponse {
|
|
12
|
+
body?: unknown;
|
|
13
|
+
headers?: Record<string, string | number | string[] | undefined>;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default defineNitroPlugin((nitroApp) => {
|
|
17
|
+
const runtimeConfig = useRuntimeConfig();
|
|
18
|
+
const config = (runtimeConfig.securityHeaders ?? {}) as SecurityHeadersConfig;
|
|
19
|
+
const headers = securityHeaders(config, runtimeConfig.public.storeUrl);
|
|
20
|
+
|
|
21
|
+
nitroApp.hooks.hook("request", (event) => {
|
|
22
|
+
setResponseHeaders(event, headers);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
nitroApp.hooks.hook(
|
|
26
|
+
"render:response",
|
|
27
|
+
(response: RenderResponse, { event }) => {
|
|
28
|
+
event.node.res.removeHeader("x-powered-by");
|
|
29
|
+
const responseHeaders = (response.headers ??= {});
|
|
30
|
+
delete responseHeaders["x-powered-by"];
|
|
31
|
+
|
|
32
|
+
const contentType = String(responseHeaders["content-type"] ?? "");
|
|
33
|
+
if (!contentType.includes("text/html")) return;
|
|
34
|
+
|
|
35
|
+
if (
|
|
36
|
+
config.htmlCacheControl?.trim() &&
|
|
37
|
+
!responseHeaders["cache-control"]
|
|
38
|
+
) {
|
|
39
|
+
responseHeaders["cache-control"] = config.htmlCacheControl.trim();
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const csp = config.contentSecurityPolicyReportOnly;
|
|
43
|
+
if (csp?.enabled && typeof response.body === "string") {
|
|
44
|
+
responseHeaders["content-security-policy-report-only"] =
|
|
45
|
+
contentSecurityPolicyReportOnly({
|
|
46
|
+
config: csp,
|
|
47
|
+
scriptHashes: inlineScriptHashes(response.body),
|
|
48
|
+
shopwareEndpoint: runtimeConfig.public.shopware?.endpoint,
|
|
49
|
+
matomoUrl: runtimeConfig.public.scripts?.matomoAnalytics?.matomoUrl,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
);
|
|
54
|
+
});
|
|
@@ -4,8 +4,8 @@
|
|
|
4
4
|
* the request origin (which is internal behind a reverse proxy).
|
|
5
5
|
*/
|
|
6
6
|
export default defineNitroPlugin((nitroApp) => {
|
|
7
|
-
nitroApp.hooks.hook("site-config:init", ({
|
|
8
|
-
const { storeUrl } = useRuntimeConfig(
|
|
7
|
+
nitroApp.hooks.hook("site-config:init", ({ siteConfig }) => {
|
|
8
|
+
const { storeUrl } = useRuntimeConfig().public;
|
|
9
9
|
if (storeUrl) {
|
|
10
10
|
siteConfig.push({ _context: "storeUrl", url: storeUrl });
|
|
11
11
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { queryCollection } from "@nuxt/content/server";
|
|
2
|
+
import { defineEventHandler } from "nuxt/server";
|
|
2
3
|
import type { components } from "~~/api-types/storeApiTypes";
|
|
3
4
|
import { getDiets, getMainIngredients } from "../../app/utils/product";
|
|
4
5
|
import { productDeepLink } from "../../app/utils/productUrl";
|
|
@@ -9,7 +10,7 @@ type Schemas = components["schemas"];
|
|
|
9
10
|
|
|
10
11
|
// Store API maximum per request.
|
|
11
12
|
const PRODUCT_PAGE_SIZE = 100;
|
|
12
|
-
// A menu has a few hundred products at most (
|
|
13
|
+
// A menu has a few hundred products at most (a real menu: 390 incl. extras).
|
|
13
14
|
const MAX_PRODUCT_PAGES = 10;
|
|
14
15
|
|
|
15
16
|
const NAVIGATION_CRITERIA = {
|
|
@@ -50,9 +51,12 @@ const PRODUCT_CRITERIA = {
|
|
|
50
51
|
* `/llms.txt` (#402): the shop, its hours, ordering and the menu as Markdown
|
|
51
52
|
* for language models. Every source is optional; a failing request leaves
|
|
52
53
|
* its section out instead of failing the file.
|
|
54
|
+
*
|
|
55
|
+
* A `nuxt/server` handler: its event has the web-standard shape that
|
|
56
|
+
* `getPathRobotConfig()` of @nuxtjs/robots 7 reads.
|
|
53
57
|
*/
|
|
54
58
|
export default defineEventHandler(async (event) => {
|
|
55
|
-
const { shopware, site } = useRuntimeConfig(
|
|
59
|
+
const { shopware, site } = useRuntimeConfig().public;
|
|
56
60
|
const siteUrl = getSiteConfig(event).url;
|
|
57
61
|
const headers = { "sw-access-key": shopware.accessToken };
|
|
58
62
|
const menuRoot = await menuRootId();
|
|
@@ -155,7 +159,7 @@ export default defineEventHandler(async (event) => {
|
|
|
155
159
|
now: new Date(),
|
|
156
160
|
});
|
|
157
161
|
|
|
158
|
-
|
|
162
|
+
event.res.headers.set("Content-Type", "text/markdown; charset=utf-8");
|
|
159
163
|
return body;
|
|
160
164
|
});
|
|
161
165
|
|