From 23553c60443ffb6f15e3741f4bb4026cc1e3a612 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:05:18 -0300 Subject: [PATCH 01/41] Update deploy --- .forgejo/workflows/deploy.yml | 21 +++++++-------------- vite.config.js | 3 +++ 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 3c18941..4476c44 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -13,24 +13,17 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Use Node.js 19 - uses: actions/setup-node@v4 - with: - node-version: 19 + - name: Install PM2 + run: npm i -g pm2 - env: - SSH_PRIVATE_KEY: ${{secrets.SSH_KEY}} - SSH_KNOWN_HOSTS: ${{secrets.SSH_KNOWN_HOSTS}} + - name: Set up SSH + run: | + mkdir -p ~/.ssh/ + echo "${{ secrets.SSH_KEY }}" > ./deploy.key + sudo chmod 600 ./deploy.key - name: Install PM2 run: npm i -g pm2 - - name: Add Deploy Key to SSH - run: | - mkdir -p ~/.ssh - echo "${{ secrets.SSH_KEY }}" >> ./deploy.key - sudo chmod 600 ./deploy.key - echo "${{ secrets.SSH_KNOWN_HOSTS}}" > ~/.ssh/known_hosts - - name: Deploy run: pm2 deploy ecosystem.config.cjs production diff --git a/vite.config.js b/vite.config.js index 786b475..460ac90 100644 --- a/vite.config.js +++ b/vite.config.js @@ -6,4 +6,7 @@ export default defineConfig({ define: { APP_VERSION: JSON.stringify(process.env.npm_package_version), }, + build: { + minify: true, + }, }); From ca816567297171dcabdb0dd977101fb147f18034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:06:33 -0300 Subject: [PATCH 02/41] Update action --- .forgejo/workflows/deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 4476c44..079b6e4 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -20,7 +20,7 @@ jobs: run: | mkdir -p ~/.ssh/ echo "${{ secrets.SSH_KEY }}" > ./deploy.key - sudo chmod 600 ./deploy.key + chmod 600 ./deploy.key - name: Install PM2 run: npm i -g pm2 From b2015aa2f508919454c38a702cf8ca46111ec753 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:09:47 -0300 Subject: [PATCH 03/41] Update prod action --- .forgejo/workflows/deploy.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.forgejo/workflows/deploy.yml b/.forgejo/workflows/deploy.yml index 079b6e4..c43c056 100644 --- a/.forgejo/workflows/deploy.yml +++ b/.forgejo/workflows/deploy.yml @@ -13,14 +13,12 @@ jobs: - name: Checkout code uses: actions/checkout@v2 - - name: Install PM2 - run: npm i -g pm2 - - name: Set up SSH run: | mkdir -p ~/.ssh/ echo "${{ secrets.SSH_KEY }}" > ./deploy.key chmod 600 ./deploy.key + echo "${{ secrets.SSH_KNOWN_HOSTS }}" > ~/.ssh/known_hosts - name: Install PM2 run: npm i -g pm2 From 5e3f1a071cb79a826b90062fac33e96ca4ac056b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:10:40 -0300 Subject: [PATCH 04/41] Trigger action --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b5b2950..9789014 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app +npx sv create my-app. ``` ## Developing From 94383cb5fc4196b2598f8278f662b807ac0e9c6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:16:11 -0300 Subject: [PATCH 05/41] Update pm2 action --- ecosystem.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 38a4b89..723625e 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -24,7 +24,7 @@ module.exports = { path: '/home/deployer/embroidery-viewer', 'pre-deploy': 'rm package-lock.json && npm i', 'post-deploy': - 'npm run build && pm2 reload ecosystem.config.cjs --only acelera-alagoas-prod --env production && pm2 save', + 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { PORT: 7017, NODE_ENV: 'production', From 7f2362b2d60db967cce4e431a59279ec352ac320 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:19:44 -0300 Subject: [PATCH 06/41] Trigger deploy --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9789014..a6f00ca 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app. +npx sv create my-app.. ``` ## Developing From 9dc862397f63abb3ea13f86d0697f5d7fe17f091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:23:39 -0300 Subject: [PATCH 07/41] Update init locale --- src/lib/translations/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js index c7f0e62..5c2f412 100644 --- a/src/lib/translations/index.js +++ b/src/lib/translations/index.js @@ -16,7 +16,7 @@ export const SUPPORTED_LOCALES = Object.freeze({ /** @type {import('sveltekit-i18n').Config} */ const config = { - initLocale: navigator.language, + initLocale: SUPPORTED_LOCALES.EN_US, fallbackLocale: SUPPORTED_LOCALES.EN_US, loaders: [ { From 3fc4265087f289e33bb19446128c807963b13526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:29:55 -0300 Subject: [PATCH 08/41] Update ecosystem --- ecosystem.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 723625e..bf122a9 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -2,7 +2,7 @@ module.exports = { apps: [ { name: 'embroidery-viewer', - script: './build/index.js', + script: '.svelte-kit/output/server/index.js', time: true, instances: 1, autorestart: true, From 2a0fe13d53fbb4d14de51585ea36ac5be6fb326c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:37:25 -0300 Subject: [PATCH 09/41] Trigger aciton --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a6f00ca..29e5e87 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app.. +npx sv create my-app... ``` ## Developing From 9999f12491a7601206b27222b342635b5852d85d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:40:29 -0300 Subject: [PATCH 10/41] Trigger again --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 29e5e87..60773e8 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app... +npx sv create my-app.... ``` ## Developing From d7e5c89474db7044e3bc9d721e0969aec01d43ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:41:54 -0300 Subject: [PATCH 11/41] Trigger to work --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60773e8..08f9abb 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app.... +npx sv create my-app..... ``` ## Developing From 9e30aab3540e9124b9aa53916ef980e6b9b9035e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 19:49:58 -0300 Subject: [PATCH 12/41] Update again --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 08f9abb..b5b2950 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you're seeing this, you've probably already done this step. Congrats! npx sv create # create a new project in my-app -npx sv create my-app..... +npx sv create my-app ``` ## Developing From 083cef3abd8ad0e8e036f23ad6e4bb099670a754 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 20:33:27 -0300 Subject: [PATCH 13/41] Update port --- ecosystem.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index bf122a9..42e87e3 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -26,7 +26,7 @@ module.exports = { 'post-deploy': 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { - PORT: 7017, + PORT: 8001, NODE_ENV: 'production', }, }, From b5b110355ba0693fe4d0f275d7978c4362b000ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 20:39:16 -0300 Subject: [PATCH 14/41] Update ecosystem --- ecosystem.config.cjs | 1 + 1 file changed, 1 insertion(+) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 42e87e3..4a2f3e2 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -10,6 +10,7 @@ module.exports = { watch: false, max_memory_restart: '1G', env: { + PORT: 8001, NODE_ENV: 'production', }, }, From 6a0e331abcdb87bce20d7c82f3fbb3fcc0db21a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 20:54:13 -0300 Subject: [PATCH 15/41] Update adapter --- package-lock.json | 232 ++++++++++++++++++++++++++++++++++++++++++++-- package.json | 2 +- svelte.config.js | 13 ++- 3 files changed, 238 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index ed889ec..9105138 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,7 @@ "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", - "@sveltejs/adapter-auto": "^6.0.0", + "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "eslint": "^9.28.0", @@ -760,6 +760,112 @@ "dev": true, "license": "MIT" }, + "node_modules/@rollup/plugin-commonjs": { + "version": "28.0.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.3.tgz", + "integrity": "sha512-pyltgilam1QPdn+Zd9gaCfOLcnjMEJ9gV+bTw6/r73INdvzf1ah9zLIJBm+kW7R6IUFIQ1YO+VqZtYxZNWFPEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "fdir": "^6.2.0", + "is-reference": "1.2.1", + "magic-string": "^0.30.3", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=16.0.0 || 14 >= 14.17" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@rollup/plugin-json": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", + "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.1.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.1.tgz", + "integrity": "sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", + "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^4.0.2" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, "node_modules/@rollup/rollup-android-arm-eabi": { "version": "4.41.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.41.1.tgz", @@ -1049,14 +1155,20 @@ "acorn": "^8.9.0" } }, - "node_modules/@sveltejs/adapter-auto": { - "version": "6.0.1", - "resolved": "https://registry.npmjs.org/@sveltejs/adapter-auto/-/adapter-auto-6.0.1.tgz", - "integrity": "sha512-mcWud3pYGPWM2Pphdj8G9Qiq24nZ8L4LB7coCUckUEy5Y7wOWGJ/enaZ4AtJTcSm5dNK1rIkBRoqt+ae4zlxcQ==", + "node_modules/@sveltejs/adapter-node": { + "version": "5.2.12", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-5.2.12.tgz", + "integrity": "sha512-0bp4Yb3jKIEcZWVcJC/L1xXp9zzJS4hDwfb4VITAkfT4OVdkspSHsx7YhqJDbb2hgLl6R9Vs7VQR+fqIVOxPUQ==", "dev": true, "license": "MIT", + "dependencies": { + "@rollup/plugin-commonjs": "^28.0.1", + "@rollup/plugin-json": "^6.1.0", + "@rollup/plugin-node-resolve": "^16.0.0", + "rollup": "^4.9.5" + }, "peerDependencies": { - "@sveltejs/kit": "^2.0.0" + "@sveltejs/kit": "^2.4.0" } }, "node_modules/@sveltejs/kit": { @@ -1166,6 +1278,13 @@ "dev": true, "license": "MIT" }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true, + "license": "MIT" + }, "node_modules/accept-language-parser": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/accept-language-parser/-/accept-language-parser-1.5.0.tgz", @@ -1342,6 +1461,13 @@ "dev": true, "license": "MIT" }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true, + "license": "MIT" + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -1693,6 +1819,13 @@ "node": ">=4.0" } }, + "node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true, + "license": "MIT" + }, "node_modules/esutils": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.3.tgz", @@ -1805,6 +1938,16 @@ "node": "^8.16.0 || ^10.6.0 || >=11.0.0" } }, + "node_modules/function-bind": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", + "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/glob-parent": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-6.0.2.tgz", @@ -1841,6 +1984,19 @@ "node": ">=8" } }, + "node_modules/hasown": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", + "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "function-bind": "^1.1.2" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/ignore": { "version": "5.3.2", "resolved": "https://registry.npmjs.org/ignore/-/ignore-5.3.2.tgz", @@ -1878,6 +2034,22 @@ "node": ">=0.8.19" } }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1901,6 +2073,13 @@ "node": ">=0.10.0" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true, + "license": "MIT" + }, "node_modules/is-reference": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz", @@ -2189,6 +2368,13 @@ "node": ">=8" } }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", @@ -2407,6 +2593,27 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/resolve-from": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", @@ -2564,6 +2771,19 @@ "node": ">=8" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/svelte": { "version": "5.33.13", "resolved": "https://registry.npmjs.org/svelte/-/svelte-5.33.13.tgz", diff --git a/package.json b/package.json index 7e54a73..ebcf8cf 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,7 @@ "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", - "@sveltejs/adapter-auto": "^6.0.0", + "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "eslint": "^9.28.0", diff --git a/svelte.config.js b/svelte.config.js index 1cb4d5e..d338538 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,5 +1,14 @@ -import adapter from '@sveltejs/adapter-auto'; +import adapter from '@sveltejs/adapter-node'; -const config = { kit: { adapter: adapter() } }; +/** @type {import('@sveltejs/kit').Config} */ +const config = { + extensions: ['.svelte'], + kit: { + // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. + // If your environment is not supported or you settled on a specific environment, switch out the adapter. + // See https://kit.svelte.dev/docs/adapters for more information about adapters. + adapter: adapter(), + }, +}; export default config; From c1a9daaf80d5409a85435d7ae30f46d88f64f9d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 20:56:36 -0300 Subject: [PATCH 16/41] Update ecosystem --- ecosystem.config.cjs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 4a2f3e2..79083e0 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -2,7 +2,7 @@ module.exports = { apps: [ { name: 'embroidery-viewer', - script: '.svelte-kit/output/server/index.js', + script: './build/index.js', time: true, instances: 1, autorestart: true, @@ -10,7 +10,6 @@ module.exports = { watch: false, max_memory_restart: '1G', env: { - PORT: 8001, NODE_ENV: 'production', }, }, From c6e414f31bdff8df64167d140a05a03cb2eef8ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 21:09:09 -0300 Subject: [PATCH 17/41] Update ecossytem --- ecosystem.config.cjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 79083e0..41f963a 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -11,6 +11,7 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', + PORT: 8001, }, }, ], @@ -24,7 +25,7 @@ module.exports = { path: '/home/deployer/embroidery-viewer', 'pre-deploy': 'rm package-lock.json && npm i', 'post-deploy': - 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', + 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production --port 8001 && pm2 save', env: { PORT: 8001, NODE_ENV: 'production', From 8515afc0b9b32d9b0d9d7efc835e172ba1f6ad6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 21:09:53 -0300 Subject: [PATCH 18/41] Fix ecossytem --- ecosystem.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 41f963a..cff18e7 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -25,7 +25,7 @@ module.exports = { path: '/home/deployer/embroidery-viewer', 'pre-deploy': 'rm package-lock.json && npm i', 'post-deploy': - 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production --port 8001 && pm2 save', + 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { PORT: 8001, NODE_ENV: 'production', From 8a4e8e639f072b6d8f67bc0a98583cc0806cbf38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 21:32:07 -0300 Subject: [PATCH 19/41] Update ecosystem --- ecosystem.config.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index cff18e7..5a6b181 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -11,7 +11,7 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - PORT: 8001, + PORT: 7280, }, }, ], @@ -27,7 +27,7 @@ module.exports = { 'post-deploy': 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { - PORT: 8001, + PORT: 7280, NODE_ENV: 'production', }, }, From a1ea1d0b1f072db7f850b4a2e032b6fa803cf211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 21:47:27 -0300 Subject: [PATCH 20/41] Update port --- ecosystem.config.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 5a6b181..8441461 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -11,7 +11,7 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - PORT: 7280, + PORT: '7280', }, }, ], @@ -27,7 +27,7 @@ module.exports = { 'post-deploy': 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { - PORT: 7280, + PORT: '7280', NODE_ENV: 'production', }, }, From 54981dcd091d2a50bf9855f21a18617335de8adc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 21:50:30 -0300 Subject: [PATCH 21/41] Update svelte config --- svelte.config.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/svelte.config.js b/svelte.config.js index d338538..769b401 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -9,6 +9,11 @@ const config = { // See https://kit.svelte.dev/docs/adapters for more information about adapters. adapter: adapter(), }, + vite: { + server: { + port: 7280, + }, + }, }; export default config; From 4e374fcfd139c6fbfa136aa5f1385459ad1e645c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 22:10:38 -0300 Subject: [PATCH 22/41] Update port --- ecosystem.config.cjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 8441461..5a6b181 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -11,7 +11,7 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - PORT: '7280', + PORT: 7280, }, }, ], @@ -27,7 +27,7 @@ module.exports = { 'post-deploy': 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', env: { - PORT: '7280', + PORT: 7280, NODE_ENV: 'production', }, }, From 6de66c4d42cfa7bc342cd4cfbd1a2a5249b05587 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Wed, 4 Jun 2025 22:49:49 -0300 Subject: [PATCH 23/41] Update package.json --- package-lock.json | 93 +---------------------------------------------- package.json | 2 +- 2 files changed, 2 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9105138..b9ca271 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,13 +8,13 @@ "name": "embroidery-viewer", "version": "0.0.1", "dependencies": { + "@sveltejs/adapter-node": "^5.2.12", "accept-language-parser": "^1.5.0", "sveltekit-i18n": "^2.4.2" }, "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", - "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "eslint": "^9.28.0", @@ -49,7 +49,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -66,7 +65,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -83,7 +81,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -100,7 +97,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -117,7 +113,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -134,7 +129,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -151,7 +145,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -168,7 +161,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -185,7 +177,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -202,7 +193,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -219,7 +209,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -236,7 +225,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -253,7 +241,6 @@ "cpu": [ "mips64el" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -270,7 +257,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -287,7 +273,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -304,7 +289,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -321,7 +305,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -338,7 +321,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -355,7 +337,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -372,7 +353,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -389,7 +369,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -406,7 +385,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -423,7 +401,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -440,7 +417,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -457,7 +433,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -757,14 +732,12 @@ "version": "1.0.0-next.29", "resolved": "https://registry.npmjs.org/@polka/url/-/url-1.0.0-next.29.tgz", "integrity": "sha512-wwQAWhWSuHaag8c4q/KN/vCoeOJYshAIvMQwD4GpSb3OiZklFfvAgmj0VCBBImRpuF/aFgIRzllXlVX93Jevww==", - "dev": true, "license": "MIT" }, "node_modules/@rollup/plugin-commonjs": { "version": "28.0.3", "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-28.0.3.tgz", "integrity": "sha512-pyltgilam1QPdn+Zd9gaCfOLcnjMEJ9gV+bTw6/r73INdvzf1ah9zLIJBm+kW7R6IUFIQ1YO+VqZtYxZNWFPEQ==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.0.1", @@ -791,7 +764,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "*" @@ -801,7 +773,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.1.0.tgz", "integrity": "sha512-EGI2te5ENk1coGeADSIwZ7G2Q8CJS2sF120T7jLw4xFw9n7wIOXHo+kIYRAoVpJAN+kmqZSoO3Fp4JtoNF4ReA==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.1.0" @@ -822,7 +793,6 @@ "version": "16.0.1", "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-16.0.1.tgz", "integrity": "sha512-tk5YCxJWIG81umIvNkSod2qK5KyQW19qcBF/B78n1bjtOON6gzKoVeSzAE8yHCZEDmqkHKkxplExA8KzdJLJpA==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/pluginutils": "^5.0.1", @@ -847,7 +817,6 @@ "version": "5.1.4", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.1.4.tgz", "integrity": "sha512-USm05zrsFxYLPdWWq+K3STlWiT/3ELn3RcV5hJMghpeAIhxfsUIg6mt12CBJBInWMV4VneoV7SfGv8xIwo2qNQ==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "^1.0.0", @@ -873,7 +842,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -887,7 +855,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -901,7 +868,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -915,7 +881,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -929,7 +894,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -943,7 +907,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -957,7 +920,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -971,7 +933,6 @@ "cpu": [ "arm" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -985,7 +946,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -999,7 +959,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1013,7 +972,6 @@ "cpu": [ "loong64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1027,7 +985,6 @@ "cpu": [ "ppc64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1041,7 +998,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1055,7 +1011,6 @@ "cpu": [ "riscv64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1069,7 +1024,6 @@ "cpu": [ "s390x" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1083,7 +1037,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1097,7 +1050,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1111,7 +1063,6 @@ "cpu": [ "arm64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1125,7 +1076,6 @@ "cpu": [ "ia32" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1139,7 +1089,6 @@ "cpu": [ "x64" ], - "dev": true, "license": "MIT", "optional": true, "os": [ @@ -1159,7 +1108,6 @@ "version": "5.2.12", "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-5.2.12.tgz", "integrity": "sha512-0bp4Yb3jKIEcZWVcJC/L1xXp9zzJS4hDwfb4VITAkfT4OVdkspSHsx7YhqJDbb2hgLl6R9Vs7VQR+fqIVOxPUQ==", - "dev": true, "license": "MIT", "dependencies": { "@rollup/plugin-commonjs": "^28.0.1", @@ -1175,7 +1123,6 @@ "version": "2.21.1", "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-2.21.1.tgz", "integrity": "sha512-vLbtVwtDcK8LhJKnFkFYwM0uCdFmzioQnif0bjEYH1I24Arz22JPr/hLUiXGVYAwhu8INKx5qrdvr4tHgPwX6w==", - "dev": true, "license": "MIT", "dependencies": { "@sveltejs/acorn-typescript": "^1.0.5", @@ -1207,7 +1154,6 @@ "version": "5.0.3", "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte/-/vite-plugin-svelte-5.0.3.tgz", "integrity": "sha512-MCFS6CrQDu1yGwspm4qtli0e63vaPCehf6V7pIMP15AsWgMKrqDGCPFF/0kn4SP0ii4aySu4Pa62+fIRGFMjgw==", - "dev": true, "license": "MIT", "dependencies": { "@sveltejs/vite-plugin-svelte-inspector": "^4.0.1", @@ -1229,7 +1175,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/@sveltejs/vite-plugin-svelte-inspector/-/vite-plugin-svelte-inspector-4.0.1.tgz", "integrity": "sha512-J/Nmb2Q2y7mck2hyCX4ckVHcR5tu2J+MtBEQqpDrrgELZ2uvraQcK/ioCV61AqkdXFgriksOKIceDcQmqnGhVw==", - "dev": true, "license": "MIT", "dependencies": { "debug": "^4.3.7" @@ -1262,7 +1207,6 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.6.0.tgz", "integrity": "sha512-4Kh9a6B2bQciAhf7FSuMRRkUWecJgJu9nPnx3yzpsfXX/c50REIqpHY4C82bXP90qrLtXtkDxTZosYO3UpOwlA==", - "dev": true, "license": "MIT" }, "node_modules/@types/estree": { @@ -1282,7 +1226,6 @@ "version": "1.20.2", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", - "dev": true, "license": "MIT" }, "node_modules/accept-language-parser": { @@ -1465,7 +1408,6 @@ "version": "1.0.1", "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", - "dev": true, "license": "MIT" }, "node_modules/concat-map": { @@ -1479,7 +1421,6 @@ "version": "0.6.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.6" @@ -1517,7 +1458,6 @@ "version": "4.4.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", "integrity": "sha512-KcKCqiftBJcZr++7ykoDIEwSa3XWowTfNPo92BYxjXiyYEVrUQh2aLyhxBCwww+heortUFxEJYcRzosstTEBYQ==", - "dev": true, "license": "MIT", "dependencies": { "ms": "^2.1.3" @@ -1542,7 +1482,6 @@ "version": "4.3.1", "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.3.1.tgz", "integrity": "sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==", - "dev": true, "license": "MIT", "engines": { "node": ">=0.10.0" @@ -1552,14 +1491,12 @@ "version": "5.1.1", "resolved": "https://registry.npmjs.org/devalue/-/devalue-5.1.1.tgz", "integrity": "sha512-maua5KUiapvEwiEAe+XnlZ3Rh0GD+qI1J/nb9vrJc3muPXvcF/8gXYTWF76+5DAqHyDUtOIImEuo0YKE9mshVw==", - "dev": true, "license": "MIT" }, "node_modules/esbuild": { "version": "0.25.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.5.tgz", "integrity": "sha512-P8OtKZRv/5J5hhz0cUAdu/cLuPIKXpQl1R9pZtvmHWQvrAUVd0UNIPT4IB4W3rNOqVO0rlqHmCIbSwxh/c9yUQ==", - "dev": true, "hasInstallScript": true, "license": "MIT", "bin": { @@ -1823,7 +1760,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", - "dev": true, "license": "MIT" }, "node_modules/esutils": { @@ -1861,7 +1797,6 @@ "version": "6.4.5", "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.4.5.tgz", "integrity": "sha512-4BG7puHpVsIYxZUbiUE3RqGloLaSSwzYie5jvasC4LWuBWzZawynvYouhjbQKw2JuIGYdm0DzIxl8iVidKlUEw==", - "dev": true, "license": "MIT", "peerDependencies": { "picomatch": "^3 || ^4" @@ -1927,7 +1862,6 @@ "version": "2.3.3", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", - "dev": true, "hasInstallScript": true, "license": "MIT", "optional": true, @@ -1942,7 +1876,6 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz", "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dev": true, "license": "MIT", "funding": { "url": "https://github.com/sponsors/ljharb" @@ -1988,7 +1921,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz", "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dev": true, "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -2038,7 +1970,6 @@ "version": "2.16.1", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", - "dev": true, "license": "MIT", "dependencies": { "hasown": "^2.0.2" @@ -2077,7 +2008,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", - "dev": true, "license": "MIT" }, "node_modules/is-reference": { @@ -2144,7 +2074,6 @@ "version": "4.1.5", "resolved": "https://registry.npmjs.org/kleur/-/kleur-4.1.5.tgz", "integrity": "sha512-o+NO+8WrRiQEE4/7nwRJhN1HWpVmJm511pBHUxPLtp0BUISzlBplORYSmTclCnJvQq2tKu/sgl3xVpkc7ZWuQQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -2236,7 +2165,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/mri/-/mri-1.2.0.tgz", "integrity": "sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==", - "dev": true, "license": "MIT", "engines": { "node": ">=4" @@ -2246,7 +2174,6 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/mrmime/-/mrmime-2.0.1.tgz", "integrity": "sha512-Y3wQdFg2Va6etvQ5I82yUhGdsKrcYox6p7FfL1LbK2J4V01F9TGlepTIhnK24t7koZibmg82KGglhA1XK5IsLQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=10" @@ -2256,14 +2183,12 @@ "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dev": true, "license": "MIT" }, "node_modules/nanoid": { "version": "3.3.11", "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "dev": true, "funding": [ { "type": "github", @@ -2372,21 +2297,18 @@ "version": "1.0.7", "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", - "dev": true, "license": "MIT" }, "node_modules/picocolors": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", - "dev": true, "license": "ISC" }, "node_modules/picomatch": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.2.tgz", "integrity": "sha512-M7BAV6Rlcy5u+m6oPhAPFgJTzAioX/6B0DxyvDlo9l8+T3nLKbrczg2WLUyzd45L8RqfUMyGPzekbMvX2Ldkwg==", - "dev": true, "license": "MIT", "engines": { "node": ">=12" @@ -2399,7 +2321,6 @@ "version": "8.5.4", "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.4.tgz", "integrity": "sha512-QSa9EBe+uwlGTFmHsPKokv3B/oEMQZxfqW0QqNCyhpa6mB1afzulwn8hihglqAb2pOw+BJgNlmXQ8la2VeHB7w==", - "dev": true, "funding": [ { "type": "opencollective", @@ -2597,7 +2518,6 @@ "version": "1.22.10", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", - "dev": true, "license": "MIT", "dependencies": { "is-core-module": "^2.16.0", @@ -2628,7 +2548,6 @@ "version": "4.41.1", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.41.1.tgz", "integrity": "sha512-cPmwD3FnFv8rKMBc1MxWCwVQFxwf1JEmSX3iQXrRVVG15zerAIXRjMFVWnd5Q5QvgKF7Aj+5ykXFhUl+QGnyOw==", - "dev": true, "license": "MIT", "dependencies": { "@types/estree": "1.0.7" @@ -2668,7 +2587,6 @@ "version": "1.8.1", "resolved": "https://registry.npmjs.org/sade/-/sade-1.8.1.tgz", "integrity": "sha512-xal3CZX1Xlo/k4ApwCFrHVACi9fBqJ7V+mwhBsuf/1IOKbBy098Fex+Wa/5QMubw09pSZ/u8EY8PWgevJsXp1A==", - "dev": true, "license": "MIT", "dependencies": { "mri": "^1.1.0" @@ -2694,7 +2612,6 @@ "version": "2.7.1", "resolved": "https://registry.npmjs.org/set-cookie-parser/-/set-cookie-parser-2.7.1.tgz", "integrity": "sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==", - "dev": true, "license": "MIT" }, "node_modules/shebang-command": { @@ -2724,7 +2641,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/sirv/-/sirv-3.0.1.tgz", "integrity": "sha512-FoqMu0NCGBLCcAkS1qA+XJIQTR6/JHfQXl+uGteNCQ76T91DMUjPa9xfmeqMY3z80nLSg9yQmNjK0Px6RWsH/A==", - "dev": true, "license": "MIT", "dependencies": { "@polka/url": "^1.0.0-next.24", @@ -2739,7 +2655,6 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", - "dev": true, "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" @@ -2775,7 +2690,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", - "dev": true, "license": "MIT", "engines": { "node": ">= 0.4" @@ -2882,7 +2796,6 @@ "version": "0.2.14", "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.14.tgz", "integrity": "sha512-tX5e7OM1HnYr2+a2C/4V0htOcSQcoSTH9KgJnVvNm5zm/cyEWKJ7j7YutsH9CxMdtOkkLFy2AHrMci9IM8IPZQ==", - "dev": true, "license": "MIT", "dependencies": { "fdir": "^6.4.4", @@ -2899,7 +2812,6 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/totalist/-/totalist-3.0.1.tgz", "integrity": "sha512-sf4i37nQ2LBx4m3wB74y+ubopq6W/dIzXg0FDGjsYnZHVa1Da8FH853wlL2gtUhg+xJXjfk3kUZS3BRoQeoQBQ==", - "dev": true, "license": "MIT", "engines": { "node": ">=6" @@ -2953,7 +2865,6 @@ "version": "6.3.5", "resolved": "https://registry.npmjs.org/vite/-/vite-6.3.5.tgz", "integrity": "sha512-cZn6NDFE7wdTpINgs++ZJ4N49W2vRp8LCKrn3Ob1kYNtOo21vfDoaV5GzBfLU4MovSAB8uNRm4jgzVQZ+mBzPQ==", - "dev": true, "license": "MIT", "dependencies": { "esbuild": "^0.25.0", @@ -3028,7 +2939,6 @@ "version": "1.0.6", "resolved": "https://registry.npmjs.org/vitefu/-/vitefu-1.0.6.tgz", "integrity": "sha512-+Rex1GlappUyNN6UfwbVZne/9cYC4+R2XDk9xkNXBKMw6HQagdX9PgZ8V2v1WUSK1wfBLp7qbI1+XSNIlB1xmA==", - "dev": true, "license": "MIT", "workspaces": [ "tests/deps/*", @@ -3073,7 +2983,6 @@ "version": "2.8.0", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.8.0.tgz", "integrity": "sha512-4lLa/EcQCB0cJkyts+FpIRx5G/llPxfP6VQU5KByHEhLxY3IJCH0f0Hy1MHI8sClTvsIb8qwRJ6R/ZdlDJ/leQ==", - "dev": true, "license": "ISC", "optional": true, "peer": true, diff --git a/package.json b/package.json index ebcf8cf..d1156bc 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,6 @@ "devDependencies": { "@eslint/compat": "^1.2.5", "@eslint/js": "^9.18.0", - "@sveltejs/adapter-node": "^5.2.12", "@sveltejs/kit": "^2.16.0", "@sveltejs/vite-plugin-svelte": "^5.0.0", "eslint": "^9.28.0", @@ -31,6 +30,7 @@ "vite": "^6.2.6" }, "dependencies": { + "@sveltejs/adapter-node": "^5.2.12", "accept-language-parser": "^1.5.0", "sveltekit-i18n": "^2.4.2" } From ab67a4150cc4fda94227181d1c27e7592d659e84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 00:06:53 -0300 Subject: [PATCH 24/41] Update gitignore --- .gitignore | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/.gitignore b/.gitignore index 6635cf5..f88f4de 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,68 @@ node_modules !.env.example vite.config.js.timestamp-* vite.config.ts.timestamp-* +deploy.key + + vite: { + server: { + port: 7280, + }, + }, + + server { + if ($host = www.embroideryviewer.xyz) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + if ($host = embroideryviewer.xyz) { + return 301 https://$host$request_uri; + } # managed by Certbot + + + listen 80; + listen [::]:80; + server_name embroideryviewer.xyz www.embroideryviewer.xyz; + + location / { + proxy_pass http://embroidery; # Replace with actual port + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + + + +} + +server { + listen 443 ssl; + server_name embroideryviewer.xyz www.embroideryviewer.xyz; + + + location / { + proxy_pass http://embroidery; # Replace with actual port + proxy_http_version 1.1; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + } + + ssl_certificate /etc/letsencrypt/live/embroideryviewer.xyz/fullchain.pem; # managed by Certbot + ssl_certificate_key /etc/letsencrypt/live/embroideryviewer.xyz/privkey.pem; # managed by Certbot + +} + +server { + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + + return 444; # Or return 404; +} From 883dee35bf52183641c309c0c7fbf224dd408b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 00:07:08 -0300 Subject: [PATCH 25/41] Updaet name --- ecosystem.config.cjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 5a6b181..0ed2807 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -11,7 +11,7 @@ module.exports = { max_memory_restart: '1G', env: { NODE_ENV: 'production', - PORT: 7280, + PORT: 7281, }, }, ], @@ -25,9 +25,9 @@ module.exports = { path: '/home/deployer/embroidery-viewer', 'pre-deploy': 'rm package-lock.json && npm i', 'post-deploy': - 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer --env production && pm2 save', + 'npm run build && pm2 reload ecosystem.config.cjs --only embroidery-viewer-prod --env production && pm2 save', env: { - PORT: 7280, + PORT: 7281, NODE_ENV: 'production', }, }, From 3e252d34c37d26f104a212f1418dab4be772c181 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 00:09:54 -0300 Subject: [PATCH 26/41] Update prod --- ecosystem.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ecosystem.config.cjs b/ecosystem.config.cjs index 0ed2807..8d05d01 100644 --- a/ecosystem.config.cjs +++ b/ecosystem.config.cjs @@ -1,7 +1,7 @@ module.exports = { apps: [ { - name: 'embroidery-viewer', + name: 'embroidery-viewer-prod', script: './build/index.js', time: true, instances: 1, From 563af3d90fa94d7b4e5b3b2e9dcf1977b71f6bdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 00:34:56 -0300 Subject: [PATCH 27/41] Update cookie policy --- src/lib/translations/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js index 5c2f412..825ac45 100644 --- a/src/lib/translations/index.js +++ b/src/lib/translations/index.js @@ -128,6 +128,6 @@ export const { locale.subscribe(($locale) => { if (typeof document !== 'undefined') { - document.cookie = `locale=${$locale}; path=/; SameSite=Strict;`; + document.cookie = `locale=${$locale}; path=/; SameSite=None; Secure`; } }); From 0f599d206913a68c554e92ed998da3b274324184 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 00:37:48 -0300 Subject: [PATCH 28/41] Just testing an hypotesis --- src/lib/translations/index.js | 6 +++--- src/routes/+layout.server.js | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js index 825ac45..e354002 100644 --- a/src/lib/translations/index.js +++ b/src/lib/translations/index.js @@ -127,7 +127,7 @@ export const { } = new i18n(config); locale.subscribe(($locale) => { - if (typeof document !== 'undefined') { - document.cookie = `locale=${$locale}; path=/; SameSite=None; Secure`; - } + // if (typeof document !== 'undefined') { + // document.cookie = `locale=${$locale}; path=/; SameSite=None; Secure`; + // } }); diff --git a/src/routes/+layout.server.js b/src/routes/+layout.server.js index 195496e..17c341b 100644 --- a/src/routes/+layout.server.js +++ b/src/routes/+layout.server.js @@ -41,9 +41,10 @@ function localeFromHeader(header) { /** @type {import('@sveltejs/kit').ServerLoad}*/ export async function load({ url, request, cookies }) { - const cookieLocale = localeFromCookies(cookies); - const headerLocale = localeFromHeader(request.headers.get('accept-language')); - const language = cookieLocale || headerLocale || SUPPORTED_LOCALES.EN_US; + // const cookieLocale = localeFromCookies(cookies); + // const headerLocale = localeFromHeader(request.headers.get('accept-language')); + // const language = cookieLocale || headerLocale || SUPPORTED_LOCALES.EN_US; + const language = SUPPORTED_LOCALES.EN_US; const route = url.pathname; await loadTranslations(language, route); From 835aa9aea23659e9e2fe40d5287a814318c3145e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 07:25:19 -0300 Subject: [PATCH 29/41] Update svelte config --- svelte.config.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/svelte.config.js b/svelte.config.js index 769b401..02ba2c8 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -14,6 +14,9 @@ const config = { port: 7280, }, }, + prerender: { + origin: 'https://embroideryviewer.xyz', + }, }; export default config; From cf231feb8e5a7fc372df44ea7cc3e2ed5643d70a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 07:30:21 -0300 Subject: [PATCH 30/41] Update hooks --- hooks.server.ts | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 hooks.server.ts diff --git a/hooks.server.ts b/hooks.server.ts new file mode 100644 index 0000000..6dc3214 --- /dev/null +++ b/hooks.server.ts @@ -0,0 +1,21 @@ +import type { Handle } from '@sveltejs/kit'; + +export const handle: Handle = async ({ event, resolve }) => { + // Correct origin behind Nginx + const host = event.request.headers.get('x-forwarded-host') ?? event.request.headers.get('host'); + const proto = event.request.headers.get('x-forwarded-proto') ?? 'https'; + const origin = `${proto}://${host}`; + + // Example: force HTTPS (optional, Nginx should already do this) + if (proto === 'http') { + return new Response(null, { + status: 308, + headers: { + Location: origin + event.url.pathname + event.url.search + } + }); + } + + // Proceed with default behavior + return resolve(event); +}; From f6578c5bf75abc0009395b9cc1d4bfae7ef19ebd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Leonardo=20Mur=C3=A7a?= Date: Thu, 5 Jun 2025 19:13:50 -0300 Subject: [PATCH 31/41] Remove translation handling with cookies --- hooks.server.ts | 21 ------------- src/lib/translations/index.js | 9 ++++-- src/routes/+layout.js | 54 +++++++++++++++++++++++++++------- src/routes/+layout.server.js | 55 ++++++++++++++--------------------- src/routes/+layout.svelte | 23 +++++++++++---- 5 files changed, 90 insertions(+), 72 deletions(-) delete mode 100644 hooks.server.ts diff --git a/hooks.server.ts b/hooks.server.ts deleted file mode 100644 index 6dc3214..0000000 --- a/hooks.server.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Handle } from '@sveltejs/kit'; - -export const handle: Handle = async ({ event, resolve }) => { - // Correct origin behind Nginx - const host = event.request.headers.get('x-forwarded-host') ?? event.request.headers.get('host'); - const proto = event.request.headers.get('x-forwarded-proto') ?? 'https'; - const origin = `${proto}://${host}`; - - // Example: force HTTPS (optional, Nginx should already do this) - if (proto === 'http') { - return new Response(null, { - status: 308, - headers: { - Location: origin + event.url.pathname + event.url.search - } - }); - } - - // Proceed with default behavior - return resolve(event); -}; diff --git a/src/lib/translations/index.js b/src/lib/translations/index.js index e354002..6fc26cb 100644 --- a/src/lib/translations/index.js +++ b/src/lib/translations/index.js @@ -127,7 +127,10 @@ export const { } = new i18n(config); locale.subscribe(($locale) => { - // if (typeof document !== 'undefined') { - // document.cookie = `locale=${$locale}; path=/; SameSite=None; Secure`; - // } + if (typeof localStorage !== 'undefined' && $locale) { + const existing = localStorage.getItem('locale'); + if (existing !== $locale) { + localStorage.setItem('locale', $locale); + } + } }); diff --git a/src/routes/+layout.js b/src/routes/+layout.js index 89b2c80..bf7ed0a 100644 --- a/src/routes/+layout.js +++ b/src/routes/+layout.js @@ -1,17 +1,51 @@ -import { setLocale, setRoute } from '$lib/translations'; +import { browser } from '$app/environment'; +import { loadTranslations, setLocale, setRoute } from '$lib/translations'; +import { SUPPORTED_LOCALES } from '$lib/translations'; /** - * @typedef {Object} LayoutData - * @property {string} route - * @property {string} language + * Type guard that checks if a string is a supported locale. + * @param {string | null} locale + * @returns {locale is "en-US" | "pt-BR"} */ +function isSupportedLocale(locale) { + // @ts-ignore + return locale !== null && Object.values(SUPPORTED_LOCALES).includes(locale); +} -/** @type {import('@sveltejs/kit').Load} */ -export const load = async ({ data }) => { - const { route, language } = data ?? {}; +/** + * Client-side load function to initialize translations based on localStorage or server fallback. + * + * This function runs in the browser and: + * - Prioritizes locale from localStorage (if valid) + * - Falls back to the server-provided fallbackLanguage (from Accept-Language) + * - Initializes translations and routing + * + * @type {import('@sveltejs/kit').Load} + */ +export const load = async ({ data, url }) => { + /** @type {string} */ + const route = url.pathname; - if (route) await setRoute(route); - if (language) await setLocale(language); + /** @type {"en-US" | "pt-BR"} */ + let language; - return data ?? {}; + if (browser) { + /** + * Locale stored in the browser, if any. + * @type {string | null} + */ + const stored = localStorage.getItem('locale'); + + if (isSupportedLocale(stored)) { + language = stored; // Type narrowed here + } else { + language = data?.fallbackLanguage ?? SUPPORTED_LOCALES.EN_US; + } + + await loadTranslations(language, route); + await setLocale(language); + await setRoute(route); + } + + return {}; }; diff --git a/src/routes/+layout.server.js b/src/routes/+layout.server.js index 17c341b..f6ee3e9 100644 --- a/src/routes/+layout.server.js +++ b/src/routes/+layout.server.js @@ -1,55 +1,44 @@ import { parse } from 'accept-language-parser'; -import { loadTranslations, setLocale, setRoute } from '$lib/translations'; import { SUPPORTED_LOCALES } from '$lib/translations'; /** - * A set of all supported locale codes, used to validate and match against - * user preferences from cookies or Accept-Language headers. We're using a - * Set for better performance in lookup. - * + * A Set of all supported locale codes for quick validation. * Example values: "en-US", "pt-BR" * @type {Set} */ const SUPPORTED_LOCALE_SET = new Set(Object.values(SUPPORTED_LOCALES)); /** - * Returns a valid locale from cookies, or null if not valid/found. - * @param {{ get: (cookies: string) => any; }} cookies - */ -function localeFromCookies(cookies) { - const locale = cookies.get('locale'); - return locale && SUPPORTED_LOCALE_SET.has(locale) ? locale : null; -} - -/** - * Parses the Accept-Language header and returns the best matching locale. - * @param {string | null | undefined} header + * Extracts the best matching locale from an Accept-Language HTTP header. + * + * @param {string | null} header - The Accept-Language header value. + * @returns {string | null} - A supported locale string like "en-US", or null if none matched. */ function localeFromHeader(header) { if (!header) return null; - - const parsedLanguages = parse(header); - for (const { code, region } of parsedLanguages) { + const parsed = parse(header); + for (const { code, region } of parsed) { const locale = region ? `${code}-${region}` : code; - if (SUPPORTED_LOCALE_SET.has(locale)) { - return locale; - } + if (SUPPORTED_LOCALE_SET.has(locale)) return locale; } - return null; } -/** @type {import('@sveltejs/kit').ServerLoad}*/ -export async function load({ url, request, cookies }) { - // const cookieLocale = localeFromCookies(cookies); - // const headerLocale = localeFromHeader(request.headers.get('accept-language')); - // const language = cookieLocale || headerLocale || SUPPORTED_LOCALES.EN_US; - const language = SUPPORTED_LOCALES.EN_US; +/** + * Server-side load function that returns the initial route and fallback language. + * The language is inferred from the Accept-Language header. + * `localStorage` will take precedence on the client. + * + * @type {import('@sveltejs/kit').ServerLoad} + */ +export async function load({ url, request }) { + /** @type {string} */ const route = url.pathname; - await loadTranslations(language, route); - setLocale(language); - setRoute(route); + /** @type {string} */ + const fallbackLanguage = + localeFromHeader(request.headers.get('accept-language')) || + SUPPORTED_LOCALES.EN_US; - return { language, route }; + return { fallbackLanguage, route }; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 324a7d4..244c409 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -1,13 +1,26 @@ -
-
- -
-