From cdb23adda46f08c31a5980dfb1ca907f95dd16ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20R=C3=B6ll?= <30629157+maxiroellplenty@users.noreply.github.com> Date: Tue, 7 Jan 2025 12:16:03 +0100 Subject: [PATCH] chore: upgrade alokai middleware to 5.3.2 (#933) --- apps/server/middleware.config.ts | 4 +- apps/server/package.json | 6 +- apps/server/src/index.ts | 39 ++--- apps/server/tsconfig.json | 4 +- apps/web/.env.example | 1 + apps/web/package.json | 2 +- yarn.lock | 277 +++++++++++++++---------------- 7 files changed, 159 insertions(+), 174 deletions(-) diff --git a/apps/server/middleware.config.ts b/apps/server/middleware.config.ts index 8673b2f0a..11575df27 100644 --- a/apps/server/middleware.config.ts +++ b/apps/server/middleware.config.ts @@ -1,11 +1,13 @@ import dotenv from 'dotenv'; import * as path from 'path'; - dotenv.config({ path: path.resolve(__dirname, '../web/.env'), }); const config = { + logger: { + verbosity: process.env.LOG_LEVEL ?? 'info', + }, integrations: { plentysystems: { location: '@plentymarkets/shop-api/server', diff --git a/apps/server/package.json b/apps/server/package.json index 10ff682fb..14f4ad9b0 100644 --- a/apps/server/package.json +++ b/apps/server/package.json @@ -12,14 +12,12 @@ }, "dependencies": { "@types/cors": "^2.8.17", - "@vue-storefront/middleware": "3.10.0", + "@vue-storefront/middleware": "5.3.2", "consola": "^3.2.3", "cors": "^2.8.5", - "dotenv": "^16.4.5", - "express": "^4.21.2" + "dotenv": "^16.4.5" }, "devDependencies": { - "@types/express": "^5.0.0", "eslint": "^8.57.0", "eslint-plugin-prettier": "5.1.3", "nodemon": "^3.1.4", diff --git a/apps/server/src/index.ts b/apps/server/src/index.ts index a6c0a4d20..42d3047ef 100755 --- a/apps/server/src/index.ts +++ b/apps/server/src/index.ts @@ -1,8 +1,6 @@ import { createServer } from '@vue-storefront/middleware'; import consola from 'consola'; -import cors from 'cors'; import config from '../middleware.config'; -import * as express from 'express'; const useIPV6 = process.env.USE_IPV6 === 'true'; @@ -19,29 +17,28 @@ const checkEnvironments = (integrations: any) => { } }; -const setCorsMiddleware = (app: any) => { - const CORS_MIDDLEWARE_NAME = 'corsMiddleware'; - const corsMiddleware = app._router.stack.find((middleware: any) => middleware.name === CORS_MIDDLEWARE_NAME); - corsMiddleware.handle = cors({ - origin: ['http://localhost:3000', ...(process.env.MIDDLEWARE_ALLOWED_ORIGINS?.split(',') ?? [])], - credentials: true, - }); -}; - -const setJsonMiddleware = (app: any) => { - const jsonMiddleware = app._router.stack.find((layer: any) => layer.name === 'jsonParser'); - if (jsonMiddleware) { - jsonMiddleware.handle = express.json({ limit: '13.5mb' }); // 13,3mb for 10mb upload file - } -}; - (async () => { - const app = await createServer({ integrations: config.integrations }); + const app = await createServer( + { integrations: config.integrations }, + { + cors: { + origin: 'http://localhost:3000', + credentials: true, + }, + bodyParser: { + limit: '50mb', + }, + fileUpload: { + enabled: true, + maxFileSize: 14_155_776, // 13,3mb for 10mb upload file + maxFiles: 5, + }, + }, + ); + const host = useIPV6 ? '::' : '0.0.0.0'; const port = Number(process.argv[3]) || 8181; - setCorsMiddleware(app); - setJsonMiddleware(app); checkEnvironments(config.integrations); app.listen(port, host, () => { diff --git a/apps/server/tsconfig.json b/apps/server/tsconfig.json index bcdbcb713..860723c2f 100644 --- a/apps/server/tsconfig.json +++ b/apps/server/tsconfig.json @@ -19,8 +19,8 @@ "strict": true, "target": "ES2019", "types": [ - "@types/express", - "jest" + "jest", + "@vue-storefront/middleware", ], "rootDir": ".", "outDir": "lib" diff --git a/apps/web/.env.example b/apps/web/.env.example index a970bf02d..192b05411 100644 --- a/apps/web/.env.example +++ b/apps/web/.env.example @@ -9,3 +9,4 @@ ENABLE_QUICK_CHECKOUT_TIMER=1 NEWSLETTERFORM=true NEWSLETTERFORMNAMES=false DEFAULT_FEEDBACK_ITEMS_PER_PAGE=10 +LOG_LEVEL=info diff --git a/apps/web/package.json b/apps/web/package.json index ec47b1760..dcc951090 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -49,7 +49,7 @@ "@types/node": "^20.14.9", "@vite-pwa/nuxt": "^0.10.6", "@vitest/coverage-v8": "^0.33.0", - "@vue-storefront/middleware": "^3.10.0", + "@vue-storefront/middleware": "5.3.2", "@vue-storefront/nuxt": "^3.1.1", "@vue-storefront/unified-data-model": "^0.18.1", "@vue/test-utils": "^2.4.6", diff --git a/yarn.lock b/yarn.lock index 36bc3e22d..dabe50c3e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2871,6 +2871,15 @@ __metadata: languageName: node linkType: hard +"@godaddy/terminus@npm:^4.12.1": + version: 4.12.1 + resolution: "@godaddy/terminus@npm:4.12.1" + dependencies: + stoppable: "npm:^1.1.0" + checksum: 10c0/89a3567418d261baed4942b9433696acafc78287efd9e25c258304cdddedb619cac571c02ebff84149bf1edba0995f438d7051a48c254414e6d7abc13d65c375 + languageName: node + linkType: hard + "@hapi/hoek@npm:^9.0.0, @hapi/hoek@npm:^9.3.0": version: 9.3.0 resolution: "@hapi/hoek@npm:9.3.0" @@ -4965,7 +4974,7 @@ __metadata: languageName: node linkType: hard -"@types/express@npm:^5.0.0": +"@types/express@npm:*": version: 5.0.0 resolution: "@types/express@npm:5.0.0" dependencies: @@ -5110,6 +5119,15 @@ __metadata: languageName: node linkType: hard +"@types/multer@npm:^1.4.7": + version: 1.4.12 + resolution: "@types/multer@npm:1.4.12" + dependencies: + "@types/express": "npm:*" + checksum: 10c0/1250a32a66b7c5929cc5b005dae4ad0768ded9b6b52ba6f90931ff39b4ed775b09a0fd9d880f0836bcac16a9a7febed6a479c6bf108a52a244c4c53badb82a7b + languageName: node + linkType: hard + "@types/node@npm:*, @types/node@npm:^20.14.9": version: 20.14.9 resolution: "@types/node@npm:20.14.9" @@ -6107,7 +6125,35 @@ __metadata: languageName: node linkType: hard -"@vue-storefront/middleware@npm:3.10.0, @vue-storefront/middleware@npm:^3.10.0, @vue-storefront/middleware@npm:^3.6.1": +"@vue-storefront/logger@npm:^1.0.0": + version: 1.0.0 + resolution: "@vue-storefront/logger@npm:1.0.0" + dependencies: + consola: "npm:^3" + dotenv: "npm:^16" + checksum: 10c0/3e608a892eda3be97600886e2449ecf6ce88d292a91a227add7b7b8877c9be0eee2a5d4a14144424323d3e7de46eabc32e15dfb2fb0c3993517f8518b64a80a7 + languageName: node + linkType: hard + +"@vue-storefront/middleware@npm:5.3.2": + version: 5.3.2 + resolution: "@vue-storefront/middleware@npm:5.3.2" + dependencies: + "@godaddy/terminus": "npm:^4.12.1" + "@types/multer": "npm:^1.4.7" + "@vue-storefront/logger": "npm:^1.0.0" + cookie-parser: "npm:^1.4.6" + cors: "npm:^2.8.5" + express: "npm:^4.18.1" + helmet: "npm:^5.1.1" + lodash.merge: "npm:^4.6.2" + multer: "npm:^1.4.5-lts.1" + xss: "npm:^1.0.15" + checksum: 10c0/5c944015df91d9e7322ae111b5703d3345935e3b7a81fec413b047af8e0c3f3db4505025de4a04654a4bb77dcded4719f2ff03df816965c1fcd5ad939b97c42a + languageName: node + linkType: hard + +"@vue-storefront/middleware@npm:^3.10.0, @vue-storefront/middleware@npm:^3.6.1": version: 3.10.0 resolution: "@vue-storefront/middleware@npm:3.10.0" dependencies: @@ -6876,6 +6922,13 @@ __metadata: languageName: node linkType: hard +"append-field@npm:^1.0.0": + version: 1.0.0 + resolution: "append-field@npm:1.0.0" + checksum: 10c0/1b5abcc227e5179936a9e4f7e2af4769fa1f00eda85bbaed907f7964b0fd1f7d61f0f332b35337f391389ff13dd5310c2546ba670f8e5a743b23ec85185c73ef + languageName: node + linkType: hard + "aproba@npm:^1.0.3 || ^2.0.0": version: 2.0.0 resolution: "aproba@npm:2.0.0" @@ -7448,26 +7501,6 @@ __metadata: languageName: node linkType: hard -"body-parser@npm:1.20.3": - version: 1.20.3 - resolution: "body-parser@npm:1.20.3" - dependencies: - bytes: "npm:3.1.2" - content-type: "npm:~1.0.5" - debug: "npm:2.6.9" - depd: "npm:2.0.0" - destroy: "npm:1.2.0" - http-errors: "npm:2.0.0" - iconv-lite: "npm:0.4.24" - on-finished: "npm:2.4.1" - qs: "npm:6.13.0" - raw-body: "npm:2.5.2" - type-is: "npm:~1.6.18" - unpipe: "npm:1.0.0" - checksum: 10c0/0a9a93b7518f222885498dcecaad528cf010dd109b071bf471c93def4bfe30958b83e03496eb9c1ad4896db543d999bb62be1a3087294162a88cfa1b42c16310 - languageName: node - linkType: hard - "boolbase@npm:^1.0.0": version: 1.0.0 resolution: "boolbase@npm:1.0.0" @@ -7592,6 +7625,15 @@ __metadata: languageName: node linkType: hard +"busboy@npm:^1.0.0": + version: 1.6.0 + resolution: "busboy@npm:1.6.0" + dependencies: + streamsearch: "npm:^1.1.0" + checksum: 10c0/fa7e836a2b82699b6e074393428b91ae579d4f9e21f5ac468e1b459a244341d722d2d22d10920cdd849743dbece6dca11d72de939fb75a7448825cf2babfba1f + languageName: node + linkType: hard + "bytes@npm:3.0.0": version: 3.0.0 resolution: "bytes@npm:3.0.0" @@ -8349,6 +8391,18 @@ __metadata: languageName: node linkType: hard +"concat-stream@npm:^1.5.2": + version: 1.6.2 + resolution: "concat-stream@npm:1.6.2" + dependencies: + buffer-from: "npm:^1.0.0" + inherits: "npm:^2.0.3" + readable-stream: "npm:^2.2.2" + typedarray: "npm:^0.0.6" + checksum: 10c0/2e9864e18282946dabbccb212c5c7cec0702745e3671679eb8291812ca7fd12023f7d8cb36493942a62f770ac96a7f90009dc5c82ad69893438371720fa92617 + languageName: node + linkType: hard + "concurrently@npm:^8.2.2": version: 8.2.2 resolution: "concurrently@npm:8.2.2" @@ -8407,6 +8461,13 @@ __metadata: languageName: node linkType: hard +"consola@npm:^3": + version: 3.3.0 + resolution: "consola@npm:3.3.0" + checksum: 10c0/78c847200d7f2cb2054a8451e31614da4b8cc8f4da2f2a764465f935509b24c2045b5f5951d788260961f33f7ca112ee1b78a7341fe8c2c617b7bddbdb92e4ec + languageName: node + linkType: hard + "consola@npm:^3.2.3": version: 3.2.3 resolution: "consola@npm:3.2.3" @@ -8521,13 +8582,6 @@ __metadata: languageName: node linkType: hard -"cookie@npm:0.7.1": - version: 0.7.1 - resolution: "cookie@npm:0.7.1" - checksum: 10c0/5de60c67a410e7c8dc8a46a4b72eb0fe925871d057c9a5d2c0e8145c4270a4f81076de83410c4d397179744b478e33cd80ccbcc457abf40a9409ad27dcd21dde - languageName: node - linkType: hard - "cookie@npm:^0.4.1": version: 0.4.2 resolution: "cookie@npm:0.4.2" @@ -9509,6 +9563,13 @@ __metadata: languageName: node linkType: hard +"dotenv@npm:^16": + version: 16.4.7 + resolution: "dotenv@npm:16.4.7" + checksum: 10c0/be9f597e36a8daf834452daa1f4cc30e5375a5968f98f46d89b16b983c567398a330580c88395069a77473943c06b877d1ca25b4afafcdd6d4adb549e8293462 + languageName: node + linkType: hard + "dotenv@npm:^16.4.5": version: 16.4.5 resolution: "dotenv@npm:16.4.5" @@ -9623,13 +9684,6 @@ __metadata: languageName: node linkType: hard -"encodeurl@npm:~2.0.0": - version: 2.0.0 - resolution: "encodeurl@npm:2.0.0" - checksum: 10c0/5d317306acb13e6590e28e27924c754163946a2480de11865c991a3a7eed4315cd3fba378b543ca145829569eefe9b899f3d84bb09870f675ae60bc924b01ceb - languageName: node - linkType: hard - "encoding@npm:^0.1.13": version: 0.1.13 resolution: "encoding@npm:0.1.13" @@ -10904,45 +10958,6 @@ __metadata: languageName: node linkType: hard -"express@npm:^4.21.2": - version: 4.21.2 - resolution: "express@npm:4.21.2" - dependencies: - accepts: "npm:~1.3.8" - array-flatten: "npm:1.1.1" - body-parser: "npm:1.20.3" - content-disposition: "npm:0.5.4" - content-type: "npm:~1.0.4" - cookie: "npm:0.7.1" - cookie-signature: "npm:1.0.6" - debug: "npm:2.6.9" - depd: "npm:2.0.0" - encodeurl: "npm:~2.0.0" - escape-html: "npm:~1.0.3" - etag: "npm:~1.8.1" - finalhandler: "npm:1.3.1" - fresh: "npm:0.5.2" - http-errors: "npm:2.0.0" - merge-descriptors: "npm:1.0.3" - methods: "npm:~1.1.2" - on-finished: "npm:2.4.1" - parseurl: "npm:~1.3.3" - path-to-regexp: "npm:0.1.12" - proxy-addr: "npm:~2.0.7" - qs: "npm:6.13.0" - range-parser: "npm:~1.2.1" - safe-buffer: "npm:5.2.1" - send: "npm:0.19.0" - serve-static: "npm:1.16.2" - setprototypeof: "npm:1.2.0" - statuses: "npm:2.0.1" - type-is: "npm:~1.6.18" - utils-merge: "npm:1.0.1" - vary: "npm:~1.1.2" - checksum: 10c0/38168fd0a32756600b56e6214afecf4fc79ec28eca7f7a91c2ab8d50df4f47562ca3f9dee412da7f5cea6b1a1544b33b40f9f8586dbacfbdada0fe90dbb10a1f - languageName: node - linkType: hard - "extend-shallow@npm:^2.0.1": version: 2.0.1 resolution: "extend-shallow@npm:2.0.1" @@ -11184,21 +11199,6 @@ __metadata: languageName: node linkType: hard -"finalhandler@npm:1.3.1": - version: 1.3.1 - resolution: "finalhandler@npm:1.3.1" - dependencies: - debug: "npm:2.6.9" - encodeurl: "npm:~2.0.0" - escape-html: "npm:~1.0.3" - on-finished: "npm:2.4.1" - parseurl: "npm:~1.3.3" - statuses: "npm:2.0.1" - unpipe: "npm:~1.0.0" - checksum: 10c0/d38035831865a49b5610206a3a9a9aae4e8523cbbcd01175d0480ffbf1278c47f11d89be3ca7f617ae6d94f29cf797546a4619cd84dd109009ef33f12f69019f - languageName: node - linkType: hard - "find-node-modules@npm:^2.1.2": version: 2.1.3 resolution: "find-node-modules@npm:2.1.3" @@ -14359,13 +14359,6 @@ __metadata: languageName: node linkType: hard -"merge-descriptors@npm:1.0.3": - version: 1.0.3 - resolution: "merge-descriptors@npm:1.0.3" - checksum: 10c0/866b7094afd9293b5ea5dcd82d71f80e51514bed33b4c4e9f516795dc366612a4cbb4dc94356e943a8a6914889a914530badff27f397191b9b75cda20b6bae93 - languageName: node - linkType: hard - "merge-stream@npm:^2.0.0": version: 2.0.0 resolution: "merge-stream@npm:2.0.0" @@ -14665,7 +14658,7 @@ __metadata: languageName: node linkType: hard -"mkdirp@npm:^0.5.3, mkdirp@npm:^0.5.6": +"mkdirp@npm:^0.5.3, mkdirp@npm:^0.5.4, mkdirp@npm:^0.5.6": version: 0.5.6 resolution: "mkdirp@npm:0.5.6" dependencies: @@ -14772,6 +14765,21 @@ __metadata: languageName: node linkType: hard +"multer@npm:^1.4.5-lts.1": + version: 1.4.5-lts.1 + resolution: "multer@npm:1.4.5-lts.1" + dependencies: + append-field: "npm:^1.0.0" + busboy: "npm:^1.0.0" + concat-stream: "npm:^1.5.2" + mkdirp: "npm:^0.5.4" + object-assign: "npm:^4.1.1" + type-is: "npm:^1.6.4" + xtend: "npm:^4.0.0" + checksum: 10c0/4c6c91e93e510c99e791b6520e3e2f4a227a57f4f509427ff7f3a6f4cc0b4b09ad77c475f629c12f7ae01dba11645b2bd6568877cab775de8bf853b0a67259b4 + languageName: node + linkType: hard + "mute-stream@npm:0.0.7": version: 0.0.7 resolution: "mute-stream@npm:0.0.7" @@ -15857,13 +15865,6 @@ __metadata: languageName: node linkType: hard -"path-to-regexp@npm:0.1.12": - version: 0.1.12 - resolution: "path-to-regexp@npm:0.1.12" - checksum: 10c0/1c6ff10ca169b773f3bba943bbc6a07182e332464704572962d277b900aeee81ac6aa5d060ff9e01149636c30b1f63af6e69dd7786ba6e0ddb39d4dee1f0645b - languageName: node - linkType: hard - "path-to-regexp@npm:0.1.7": version: 0.1.7 resolution: "path-to-regexp@npm:0.1.7" @@ -16873,7 +16874,7 @@ __metadata: languageName: node linkType: hard -"readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.5": +"readable-stream@npm:^2.0.1, readable-stream@npm:^2.0.5, readable-stream@npm:^2.2.2": version: 2.3.8 resolution: "readable-stream@npm:2.3.8" dependencies: @@ -17615,27 +17616,6 @@ __metadata: languageName: node linkType: hard -"send@npm:0.19.0": - version: 0.19.0 - resolution: "send@npm:0.19.0" - dependencies: - debug: "npm:2.6.9" - depd: "npm:2.0.0" - destroy: "npm:1.2.0" - encodeurl: "npm:~1.0.2" - escape-html: "npm:~1.0.3" - etag: "npm:~1.8.1" - fresh: "npm:0.5.2" - http-errors: "npm:2.0.0" - mime: "npm:1.6.0" - ms: "npm:2.1.3" - on-finished: "npm:2.4.1" - range-parser: "npm:~1.2.1" - statuses: "npm:2.0.1" - checksum: 10c0/ea3f8a67a8f0be3d6bf9080f0baed6d2c51d11d4f7b4470de96a5029c598a7011c497511ccc28968b70ef05508675cebff27da9151dd2ceadd60be4e6cf845e3 - languageName: node - linkType: hard - "serialize-javascript@npm:^6.0.1": version: 6.0.2 resolution: "serialize-javascript@npm:6.0.2" @@ -17666,31 +17646,17 @@ __metadata: languageName: node linkType: hard -"serve-static@npm:1.16.2": - version: 1.16.2 - resolution: "serve-static@npm:1.16.2" - dependencies: - encodeurl: "npm:~2.0.0" - escape-html: "npm:~1.0.3" - parseurl: "npm:~1.3.3" - send: "npm:0.19.0" - checksum: 10c0/528fff6f5e12d0c5a391229ad893910709bc51b5705962b09404a1d813857578149b8815f35d3ee5752f44cd378d0f31669d4b1d7e2d11f41e08283d5134bd1f - languageName: node - linkType: hard - "server@workspace:apps/server": version: 0.0.0-use.local resolution: "server@workspace:apps/server" dependencies: "@types/cors": "npm:^2.8.17" - "@types/express": "npm:^5.0.0" - "@vue-storefront/middleware": "npm:3.10.0" + "@vue-storefront/middleware": "npm:5.3.2" consola: "npm:^3.2.3" cors: "npm:^2.8.5" dotenv: "npm:^16.4.5" eslint: "npm:^8.57.0" eslint-plugin-prettier: "npm:5.1.3" - express: "npm:^4.21.2" nodemon: "npm:^3.1.4" ts-node-dev: "npm:^2.0.0" tsup: "npm:^7.2.0" @@ -18198,6 +18164,20 @@ __metadata: languageName: node linkType: hard +"stoppable@npm:^1.1.0": + version: 1.1.0 + resolution: "stoppable@npm:1.1.0" + checksum: 10c0/ba91b65e6442bf6f01ce837a727ece597a977ed92a05cb9aea6bf446c5e0dcbccc28f31b793afa8aedd8f34baaf3335398d35f903938d5493f7fbe386a1e090e + languageName: node + linkType: hard + +"streamsearch@npm:^1.1.0": + version: 1.1.0 + resolution: "streamsearch@npm:1.1.0" + checksum: 10c0/fbd9aecc2621364384d157f7e59426f4bfd385e8b424b5aaa79c83a6f5a1c8fd2e4e3289e95de1eb3511cb96bb333d6281a9919fafce760e4edb35b2cd2facab + languageName: node + linkType: hard + "streamx@npm:^2.15.0, streamx@npm:^2.18.0": version: 2.18.0 resolution: "streamx@npm:2.18.0" @@ -19459,7 +19439,7 @@ __metadata: languageName: node linkType: hard -"type-is@npm:^1.6.16, type-is@npm:~1.6.18": +"type-is@npm:^1.6.16, type-is@npm:^1.6.4, type-is@npm:~1.6.18": version: 1.6.18 resolution: "type-is@npm:1.6.18" dependencies: @@ -19530,6 +19510,13 @@ __metadata: languageName: node linkType: hard +"typedarray@npm:^0.0.6": + version: 0.0.6 + resolution: "typedarray@npm:0.0.6" + checksum: 10c0/6005cb31df50eef8b1f3c780eb71a17925f3038a100d82f9406ac2ad1de5eb59f8e6decbdc145b3a1f8e5836e17b0c0002fb698b9fe2516b8f9f9ff602d36412 + languageName: node + linkType: hard + "typedoc-plugin-markdown@npm:^4.1.0": version: 4.1.0 resolution: "typedoc-plugin-markdown@npm:4.1.0" @@ -20768,7 +20755,7 @@ __metadata: "@types/node": "npm:^20.14.9" "@vite-pwa/nuxt": "npm:^0.10.6" "@vitest/coverage-v8": "npm:^0.33.0" - "@vue-storefront/middleware": "npm:^3.10.0" + "@vue-storefront/middleware": "npm:5.3.2" "@vue-storefront/nuxt": "npm:^3.1.1" "@vue-storefront/sdk": "npm:^1.5.0" "@vue-storefront/unified-data-model": "npm:^0.18.1" @@ -21306,7 +21293,7 @@ __metadata: languageName: node linkType: hard -"xss@npm:^1.0.14": +"xss@npm:^1.0.14, xss@npm:^1.0.15": version: 1.0.15 resolution: "xss@npm:1.0.15" dependencies: