From 695c13c21666a06135b0e2a169b95964856ab4eb Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Wed, 21 Aug 2024 16:44:47 +0300 Subject: [PATCH 01/18] forcing max 1 connection on pgboss --- app/utils/scheduler.server.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/utils/scheduler.server.ts b/app/utils/scheduler.server.ts index 3224868ef..cb5617513 100644 --- a/app/utils/scheduler.server.ts +++ b/app/utils/scheduler.server.ts @@ -10,7 +10,10 @@ declare global { export const init = async () => { if (!scheduler) { if (NODE_ENV === "production") { - scheduler = new PgBoss(DATABASE_URL); + scheduler = new PgBoss({ + connectionString: DATABASE_URL, + max: 1, + }); } else { if (!global.scheduler) { global.scheduler = new PgBoss({ From fa27a3cb854e5b4271e696728e9d764ed6b7f86f Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 10:35:50 +0300 Subject: [PATCH 02/18] fixing mistake in fly.toml --- fly.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fly.toml b/fly.toml index 1cb4e13dd..665d80292 100644 --- a/fly.toml +++ b/fly.toml @@ -26,7 +26,7 @@ port = 443 [http_service] internal_port = 8080 force_https = true -auto_stop_machines = false +auto_stop_machines = "off" auto_start_machines = false min_machines_running = 1 processes = ["app"] From dcc2e51e22f264c867b2c0906c7ec3063555d720 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 12:13:27 +0300 Subject: [PATCH 03/18] adding react-router-hono-server package --- app/database/db.server.ts | 4 + app/entry.server.tsx | 2 + package-lock.json | 271 ++++++++++++++++++++------------- package.json | 1 + server/index.ts | 311 ++++++++++++++++++-------------------- vite.config.ts | 14 +- 6 files changed, 330 insertions(+), 273 deletions(-) diff --git a/app/database/db.server.ts b/app/database/db.server.ts index 320604b94..b54c26e41 100644 --- a/app/database/db.server.ts +++ b/app/database/db.server.ts @@ -11,8 +11,10 @@ declare global { var __db__: ExtendedPrismaClient; } +console.log("IN DB file at start"); /** Extending prisma client for dynamic findMany */ function getNewPrismaClient() { + console.log("Inside function getNewPrismaClient"); return new PrismaClient().$extends({ model: { $allModels: { @@ -39,4 +41,6 @@ if (NODE_ENV === "production") { void db.$connect(); } +console.log("In DB file before exporting db"); + export { db }; diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 20ef79d66..191032497 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -175,3 +175,5 @@ function handleBrowserRequest( setTimeout(abort, ABORT_DELAY); }); } + +export * from "../server"; diff --git a/package-lock.json b/package-lock.json index fbf138b0a..33a8696a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,6 +68,7 @@ "react-map-gl": "^7.1.7", "react-media-devices": "^1.1.5", "react-microsoft-clarity": "^1.2.0", + "react-router-hono-server": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", "react-tag-autocomplete": "^7.1.0", "react-to-print": "^2.15.1", "react-zorm": "^0.9.0", @@ -919,13 +920,13 @@ "dev": true }, "node_modules/@cloudflare/workerd-darwin-64": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240610.1.tgz", - "integrity": "sha512-YanZ1iXgMGaUWlleB5cswSE6qbzyjQ8O7ENWZcPAcZZ6BfuL7q3CWi0t9iM1cv2qx92rRztsRTyjcfq099++XQ==", + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240806.0.tgz", + "integrity": "sha512-FqcVBBCO//I39K5F+HqE/v+UkqY1UrRnS653Jv+XsNNH9TpX5fTs7VCKG4kDSnmxlAaKttyIN5sMEt7lpuNExQ==", "cpu": [ "x64" ], - "dev": true, + "license": "Apache-2.0", "optional": true, "os": [ "darwin" @@ -935,13 +936,13 @@ } }, "node_modules/@cloudflare/workerd-darwin-arm64": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240610.1.tgz", - "integrity": "sha512-bRe/y/LKjIgp3L2EHjc+CvoCzfHhf4aFTtOBkv2zW+VToNJ4KlXridndf7LvR9urfsFRRo9r4TXCssuKaU+ypQ==", + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240806.0.tgz", + "integrity": "sha512-8c3KvmzYp/wg+82KHSOzDetJK+pThH4MTrU1OsjmsR2cUfedm5dk5Lah9/0Ld68+6A0umFACi4W2xJHs/RoBpA==", "cpu": [ "arm64" ], - "dev": true, + "license": "Apache-2.0", "optional": true, "os": [ "darwin" @@ -951,13 +952,13 @@ } }, "node_modules/@cloudflare/workerd-linux-64": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240610.1.tgz", - "integrity": "sha512-2zDcadR7+Gs9SjcMXmwsMji2Xs+yASGNA2cEHDuFc4NMUup+eL1mkzxc/QzvFjyBck98e92rBjMZt2dVscpGKg==", + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240806.0.tgz", + "integrity": "sha512-/149Bpxw4e2p5QqnBc06g0mx+4sZYh9j0doilnt0wk/uqYkLp0DdXGMQVRB74sBLg2UD3wW8amn1w3KyFhK2tQ==", "cpu": [ "x64" ], - "dev": true, + "license": "Apache-2.0", "optional": true, "os": [ "linux" @@ -967,13 +968,13 @@ } }, "node_modules/@cloudflare/workerd-linux-arm64": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240610.1.tgz", - "integrity": "sha512-7y41rPi5xmIYJN8CY+t3RHnjLL0xx/WYmaTd/j552k1qSr02eTE2o/TGyWZmGUC+lWnwdPQJla0mXbvdqgRdQg==", + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240806.0.tgz", + "integrity": "sha512-lacDWY3S1rKL/xT6iMtTQJEKmTTKrBavPczInEuBFXElmrS6IwVjZwv8hhVm32piyNt/AuFu9BYoJALi9D85/g==", "cpu": [ "arm64" ], - "dev": true, + "license": "Apache-2.0", "optional": true, "os": [ "linux" @@ -983,13 +984,13 @@ } }, "node_modules/@cloudflare/workerd-windows-64": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240610.1.tgz", - "integrity": "sha512-B0LyT3DB6rXHWNptnntYHPaoJIy0rXnGfeDBM3nEVV8JIsQrx8MEFn2F2jYioH1FkUVavsaqKO/zUosY3tZXVA==", + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240806.0.tgz", + "integrity": "sha512-hC6JEfTSQK6//Lg+D54TLVn1ceTPY+fv4MXqDZIYlPP53iN+dL8Xd0utn2SG57UYdlL5FRAhm/EWHcATZg1RgA==", "cpu": [ "x64" ], - "dev": true, + "license": "Apache-2.0", "optional": true, "os": [ "win32" @@ -1002,7 +1003,6 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", - "dev": true, "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -1014,7 +1014,6 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", - "dev": true, "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -1042,7 +1041,6 @@ "cpu": [ "ppc64" ], - "dev": true, "optional": true, "os": [ "aix" @@ -1540,7 +1538,6 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", - "dev": true, "engines": { "node": ">=14" } @@ -6386,7 +6383,6 @@ "cpu": [ "arm" ], - "dev": true, "optional": true, "os": [ "android" @@ -6399,7 +6395,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "android" @@ -6412,7 +6407,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -6425,7 +6419,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -6438,7 +6431,6 @@ "cpu": [ "arm" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6451,7 +6443,6 @@ "cpu": [ "arm" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6464,7 +6455,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6477,7 +6467,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6490,7 +6479,6 @@ "cpu": [ "ppc64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6503,7 +6491,6 @@ "cpu": [ "riscv64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6516,7 +6503,6 @@ "cpu": [ "s390x" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6529,7 +6515,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6542,7 +6527,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -6555,7 +6539,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "win32" @@ -6568,7 +6551,6 @@ "cpu": [ "ia32" ], - "dev": true, "optional": true, "os": [ "win32" @@ -6581,7 +6563,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "win32" @@ -7511,8 +7492,7 @@ "node_modules/@types/estree": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.5.tgz", - "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==", - "dev": true + "integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==" }, "node_modules/@types/estree-jsx": { "version": "1.0.5", @@ -8470,7 +8450,6 @@ "version": "8.3.3", "resolved": "https://registry.npmjs.org/acorn-walk/-/acorn-walk-8.3.3.tgz", "integrity": "sha512-MxXdReSRhGO7VlFe1bRG/oI7/mdLV9B9JJT0N8vZOhF7gFRR5l3M8W9G8JxmKV+JC5mGqJ0QvqfSOLsCPa4nUw==", - "dev": true, "dependencies": { "acorn": "^8.11.0" }, @@ -8801,7 +8780,6 @@ "version": "1.0.55", "resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz", "integrity": "sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==", - "dev": true, "dependencies": { "printable-characters": "^1.0.42" } @@ -9372,7 +9350,6 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/capnp-ts/-/capnp-ts-0.7.0.tgz", "integrity": "sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==", - "dev": true, "dependencies": { "debug": "^4.3.1", "tslib": "^2.2.0" @@ -12023,7 +12000,6 @@ "version": "2.2.1", "resolved": "https://registry.npmjs.org/exit-hook/-/exit-hook-2.2.1.tgz", "integrity": "sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==", - "dev": true, "engines": { "node": ">=6" }, @@ -12721,7 +12697,6 @@ "version": "2.0.12", "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz", "integrity": "sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==", - "dev": true, "dependencies": { "data-uri-to-buffer": "^2.0.0", "source-map": "^0.6.1" @@ -12730,14 +12705,12 @@ "node_modules/get-source/node_modules/data-uri-to-buffer": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz", - "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==", - "dev": true + "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==" }, "node_modules/get-source/node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true, "engines": { "node": ">=0.10.0" } @@ -12866,8 +12839,7 @@ "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", - "dev": true + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" }, "node_modules/global-prefix": { "version": "3.0.0", @@ -13144,9 +13116,10 @@ } }, "node_modules/hono": { - "version": "4.4.8", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.4.8.tgz", - "integrity": "sha512-eewnSgTzdWgFVn97kPV24h+9UVNUQ+9mj6IRxr7dBseTaTBSHtFo/T/vRNcqJkQFysVoXyecflr3Xe/fdvzEpQ==", + "version": "4.5.8", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.5.8.tgz", + "integrity": "sha512-pqpSlcdqGkpTTRpLYU1PnCz52gVr0zVR9H5GzMyJWuKQLLEBQxh96q45QizJ2PPX8NATtz2mu31/PKW/Jt+90Q==", + "license": "MIT", "engines": { "node": ">=16.0.0" } @@ -15801,10 +15774,10 @@ } }, "node_modules/miniflare": { - "version": "3.20240610.1", - "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240610.1.tgz", - "integrity": "sha512-ZkfSpBmX3nJW00yYhvF2kGvjb6f77TOimRR6+2GQvsArbwo6e0iYqLGM9aB/cnJzgFjLMvOv1qj4756iynSxJQ==", - "dev": true, + "version": "3.20240806.1", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240806.1.tgz", + "integrity": "sha512-wJq3YQYx9k83L2CNYtxvwWvXSi+uHrC6aFoXYSbzhxIDlUWvMEqippj+3HeKLgsggC31nHJab3b1Pifg9IxIFQ==", + "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "0.8.1", "acorn": "^8.8.0", @@ -15814,8 +15787,8 @@ "glob-to-regexp": "^0.4.1", "stoppable": "^1.1.0", "undici": "^5.28.4", - "workerd": "1.20240610.1", - "ws": "^8.14.2", + "workerd": "1.20240806.0", + "ws": "^8.17.1", "youch": "^3.2.2", "zod": "^3.22.3" }, @@ -15830,7 +15803,6 @@ "version": "8.17.1", "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", - "dev": true, "engines": { "node": ">=10.0.0" }, @@ -16175,7 +16147,6 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", - "dev": true, "bin": { "mustache": "bin/mustache" } @@ -18127,8 +18098,7 @@ "node_modules/printable-characters": { "version": "1.0.42", "resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", - "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==", - "dev": true + "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==" }, "node_modules/prisma": { "version": "5.15.1", @@ -18725,6 +18695,129 @@ "react-dom": ">=16.8" } }, + "node_modules/react-router-hono-server": { + "version": "0.0.5", + "resolved": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", + "integrity": "sha512-bwiWhHe0Vbi4W3dXtd4eNJmOgzyvdoUvUibWeCECWovNfA//F3bs6YX83FAOkfoIhl3XhAVWgU1uwcC5VeS/rw==", + "license": "ISC", + "workspaces": [ + ".", + "examples/*" + ], + "dependencies": { + "@hono/node-server": "^1.12.0", + "@hono/vite-dev-server": "^0.13.1", + "hono": "^4.5.3", + "remix-hono": "^0.0.16" + }, + "optionalDependencies": { + "@rollup/rollup-darwin-x64-gnu": "4.18.1", + "@rollup/rollup-darwin-x64-musl": "4.18.1", + "@rollup/rollup-linux-arm64-gnu": "4.18.1", + "@rollup/rollup-linux-x64-gnu": "^4.18.1", + "@rollup/rollup-linux-x64-musl": "^4.18.1", + "@rollup/rollup-win32-arm64-msvc": "4.18.1", + "@rollup/rollup-win32-x64-msvc": "4.18.1", + "@rollup/rollup-win32-x64-musl": "4.18.1" + }, + "peerDependencies": { + "@remix-run/node": "^2.0.0", + "hono": "^4.5.3", + "remix-hono": "^0.0.16", + "vite": "^5.0.0" + } + }, + "node_modules/react-router-hono-server/node_modules/@hono/node-server": { + "version": "1.12.1", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.12.1.tgz", + "integrity": "sha512-C9l+08O8xtXB7Ppmy8DjBFH1hYji7JKzsU32Yt1poIIbdPp6S7aOI8IldDHD9YFJ55lv2c21ovNrmxatlHfhAg==", + "license": "MIT", + "engines": { + "node": ">=18.14.1" + } + }, + "node_modules/react-router-hono-server/node_modules/@hono/vite-dev-server": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/@hono/vite-dev-server/-/vite-dev-server-0.13.1.tgz", + "integrity": "sha512-AK0yQkGwoQvcbf0MeBDDslVnVvzlKjAT00Z2A4Oqyh0RYhLQyCT1aSJzz3eZj7tYytG0B6EGt92DjrkB0tsy1A==", + "license": "MIT", + "dependencies": { + "@hono/node-server": "^1.12.0", + "miniflare": "^3.20240701.0", + "minimatch": "^9.0.3" + }, + "engines": { + "node": ">=18.14.1" + }, + "peerDependencies": { + "hono": "*" + } + }, + "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.1.tgz", + "integrity": "sha512-8mwmGD668m8WaGbthrEYZ9CBmPug2QPGWxhJxh/vCgBjro5o96gL04WLlg5BA233OCWLqERy4YUzX3bJGXaJgQ==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.0.tgz", + "integrity": "sha512-e2hrvElFIh6kW/UNBQK/kzqMNY5mO+67YtEh9OA65RM5IJXYTWiXjX6fjIiPaqOkBthYF1EqgiZ6OXKcQsM0hg==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.0.tgz", + "integrity": "sha512-1vvmgDdUSebVGXWX2lIcgRebqfQSff0hMEkLJyakQ9JQUbLDkEaMsPTLOmyccyC6IJ/l3FZuJbmrBw/u0A0uCQ==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/react-router-hono-server/node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.18.1.tgz", + "integrity": "sha512-W2ZNI323O/8pJdBGil1oCauuCzmVd9lDmWBBqxYZcOqWD6aWqJtVBQ1dFrF4dYpZPks6F+xCZHfzG5hYlSHZ6g==", + "cpu": [ + "arm64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/react-router-hono-server/node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.18.1", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.18.1.tgz", + "integrity": "sha512-yjk2MAkQmoaPYCSu35RLJ62+dz358nE83VfTePJRp8CG7aMg25mEJYpXFiD+NcevhX8LxD5OP5tktPXnXN7GDw==", + "cpu": [ + "x64" + ], + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/react-smooth": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/react-smooth/-/react-smooth-4.0.1.tgz", @@ -19451,7 +19544,6 @@ "version": "4.18.0", "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.18.0.tgz", "integrity": "sha512-QmJz14PX3rzbJCN1SG4Xe/bAAX2a6NpCP8ab2vfu2GiUr8AQcr2nCV/oEO3yneFarB67zk8ShlIyWb2LGTb3Sg==", - "dev": true, "dependencies": { "@types/estree": "1.0.5" }, @@ -20140,7 +20232,6 @@ "version": "2.1.8", "resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-2.1.8.tgz", "integrity": "sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==", - "dev": true, "dependencies": { "as-table": "^1.0.36", "get-source": "^2.0.12" @@ -20200,7 +20291,6 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", - "dev": true, "engines": { "node": ">=4", "npm": ">=6" @@ -21763,7 +21853,6 @@ "version": "5.28.4", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", - "dev": true, "dependencies": { "@fastify/busboy": "^2.0.0" }, @@ -22192,7 +22281,6 @@ "version": "5.3.1", "resolved": "https://registry.npmjs.org/vite/-/vite-5.3.1.tgz", "integrity": "sha512-XBmSKRLXLxiaPYamLv3/hnP/KXDai1NDexN0FpkTaZXTfycHvkRHoenpgl/fvuK/kPbB6xAgoyiryAhQNxYmAQ==", - "dev": true, "dependencies": { "esbuild": "^0.21.3", "postcss": "^8.4.38", @@ -22304,7 +22392,6 @@ "cpu": [ "arm" ], - "dev": true, "optional": true, "os": [ "android" @@ -22320,7 +22407,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "android" @@ -22336,7 +22422,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "android" @@ -22352,7 +22437,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -22368,7 +22452,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "darwin" @@ -22384,7 +22467,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "freebsd" @@ -22400,7 +22482,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "freebsd" @@ -22416,7 +22497,6 @@ "cpu": [ "arm" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22432,7 +22512,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22448,7 +22527,6 @@ "cpu": [ "ia32" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22464,7 +22542,6 @@ "cpu": [ "loong64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22480,7 +22557,6 @@ "cpu": [ "mips64el" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22496,7 +22572,6 @@ "cpu": [ "ppc64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22512,7 +22587,6 @@ "cpu": [ "riscv64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22528,7 +22602,6 @@ "cpu": [ "s390x" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22544,7 +22617,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "linux" @@ -22560,7 +22632,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "netbsd" @@ -22576,7 +22647,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "openbsd" @@ -22592,7 +22662,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "sunos" @@ -22608,7 +22677,6 @@ "cpu": [ "arm64" ], - "dev": true, "optional": true, "os": [ "win32" @@ -22624,7 +22692,6 @@ "cpu": [ "ia32" ], - "dev": true, "optional": true, "os": [ "win32" @@ -22640,7 +22707,6 @@ "cpu": [ "x64" ], - "dev": true, "optional": true, "os": [ "win32" @@ -22653,7 +22719,6 @@ "version": "0.21.5", "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.21.5.tgz", "integrity": "sha512-mg3OPMV4hXywwpoDxu3Qda5xCKQi+vCTZq8S9J/EpkhB2HzKXq4SNFZE3+NK93JYxc8VMSep+lOUSC/RVKaBqw==", - "dev": true, "hasInstallScript": true, "bin": { "esbuild": "bin/esbuild" @@ -23094,11 +23159,11 @@ } }, "node_modules/workerd": { - "version": "1.20240610.1", - "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20240610.1.tgz", - "integrity": "sha512-Rtut5GrsODQMh6YU43b9WZ980Wd05Ov1/ds88pT/SoetmXFBvkBzdRfiHiATv+azmGX8KveE0i/Eqzk/yI01ug==", - "dev": true, + "version": "1.20240806.0", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20240806.0.tgz", + "integrity": "sha512-yyNtyzTMgVY0sgYijHBONqZFVXsOFGj2jDjS8MF/RbO2ZdGROvs4Hkc/9QnmqFWahE0STxXeJ1yW1yVotdF0UQ==", "hasInstallScript": true, + "license": "Apache-2.0", "bin": { "workerd": "bin/workerd" }, @@ -23106,11 +23171,11 @@ "node": ">=16" }, "optionalDependencies": { - "@cloudflare/workerd-darwin-64": "1.20240610.1", - "@cloudflare/workerd-darwin-arm64": "1.20240610.1", - "@cloudflare/workerd-linux-64": "1.20240610.1", - "@cloudflare/workerd-linux-arm64": "1.20240610.1", - "@cloudflare/workerd-windows-64": "1.20240610.1" + "@cloudflare/workerd-darwin-64": "1.20240806.0", + "@cloudflare/workerd-darwin-arm64": "1.20240806.0", + "@cloudflare/workerd-linux-64": "1.20240806.0", + "@cloudflare/workerd-linux-arm64": "1.20240806.0", + "@cloudflare/workerd-windows-64": "1.20240806.0" } }, "node_modules/wrap-ansi": { @@ -23327,7 +23392,6 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/youch/-/youch-3.3.3.tgz", "integrity": "sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==", - "dev": true, "dependencies": { "cookie": "^0.5.0", "mustache": "^4.2.0", @@ -23338,7 +23402,6 @@ "version": "0.5.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", - "dev": true, "engines": { "node": ">= 0.6" } diff --git a/package.json b/package.json index 0526377bf..beaaf3c75 100644 --- a/package.json +++ b/package.json @@ -100,6 +100,7 @@ "react-map-gl": "^7.1.7", "react-media-devices": "^1.1.5", "react-microsoft-clarity": "^1.2.0", + "react-router-hono-server": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", "react-tag-autocomplete": "^7.1.0", "react-to-print": "^2.15.1", "react-zorm": "^0.9.0", diff --git a/server/index.ts b/server/index.ts index e2633521b..88b85ea20 100644 --- a/server/index.ts +++ b/server/index.ts @@ -2,13 +2,11 @@ // It is important to import it as .js for this to work, even if the file is .ts import "./instrument.server.js"; -import { serve } from "@hono/node-server"; import { serveStatic } from "@hono/node-server/serve-static"; import type { AppLoadContext, ServerBuild } from "@remix-run/node"; -import { Hono } from "hono"; +import { createHonoServer } from "react-router-hono-server/node"; import { remix } from "remix-hono/handler"; import { getSession, session } from "remix-hono/session"; - import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; @@ -36,161 +34,164 @@ const mode = env.NODE_ENV === "test" ? "development" : env.NODE_ENV; const isProductionMode = mode === "production"; -const app = new Hono({ - getPath: (req) => { - const url = new URL(req.url); - const host = req.headers.get("host"); +const server = await createHonoServer({ + honoOptions: { + getPath: (req) => { + const url = new URL(req.url); + const host = req.headers.get("host"); - if (process.env.URL_SHORTENER && host === process.env.URL_SHORTENER) { - return "/" + host + url.pathname; - } + if (process.env.URL_SHORTENER && host === process.env.URL_SHORTENER) { + return "/" + host + url.pathname; + } - return url.pathname; + return url.pathname; + }, }, -}); + configure: (server) => { + // Apply the middleware to all routes + server.use( + `/${process.env.URL_SHORTENER}/:path*`, + urlShortener({ + excludePaths: ["/file-assets", "/healthcheck", "/static"], + }) + ); -// Apply the middleware to all routes -app.use( - `/${process.env.URL_SHORTENER}/:path*`, - urlShortener({ - excludePaths: ["/file-assets", "/healthcheck", "/static"], - }) -); - -/** - * Serve assets files from build/client/assets - */ -app.use( - "/file-assets/*", - cache(60 * 60 * 24 * 365), // 1 year - serveStatic({ root: "./build/client" }) -); + /** + * Serve assets files from build/client/assets + */ + server.use( + "/file-assets/*", + cache(60 * 60 * 24 * 365), // 1 year + serveStatic({ root: "./build/client" }) + ); -/** - * Serve public files - */ -app.use( - "*", - cache(60 * 60), - serveStatic({ root: isProductionMode ? "./build/client" : "./public" }) -); // 1 hour + /** + * Serve public files + */ + server.use( + "*", + cache(60 * 60), + serveStatic({ root: isProductionMode ? "./build/client" : "./public" }) + ); // 1 hour -/** - * Add logger middleware - */ -app.use("*", logger()); + /** + * Add logger middleware + */ + server.use("*", logger()); -/** - * Add session middleware - */ -app.use( - session({ - autoCommit: true, - createSessionStorage() { - const sessionStorage = createSessionStorage(); - - return { - ...sessionStorage, - // If a user doesn't come back to the app within 30 days, their session will be deleted. - async commitSession(session) { - return sessionStorage.commitSession(session, { - maxAge: 60 * 60 * 24 * 30, // 30 days - }); + /** + * Add session middleware + */ + server.use( + session({ + autoCommit: true, + createSessionStorage() { + const sessionStorage = createSessionStorage(); + + return { + ...sessionStorage, + // If a user doesn't come back to the app within 30 days, their session will be deleted. + async commitSession(session) { + return sessionStorage.commitSession(session, { + maxAge: 60 * 60 * 24 * 30, // 30 days + }); + }, + }; }, - }; - }, - }) -); + }) + ); -/** - * Add refresh session middleware - * - */ -app.use("*", refreshSession()); + /** + * Add refresh session middleware + * + */ + server.use("*", refreshSession()); -/** - * Add protected routes middleware - * - */ -app.use( - "*", - protect({ - onFailRedirectTo: "/login", - publicPaths: [ - "/", - "/accept-invite/:path*", // :path* is a wildcard that will match any path after /accept-invite - "/forgot-password", - "/join", - "/login", - "/sso-login", - "/oauth/callback", - "/logout", - "/otp", - "/resend-otp", - "/reset-password", - "/send-otp", - "/healthcheck", - "/api/public-stats", - "/api/oss-friends", - "/api/stripe-webhook", - "/qr", - "/qr/:path*", - "/qr/:path*/contact-owner", - "/qr/:path*/not-logged-in", - ], - }) -); + /** + * Add protected routes middleware + * + */ + server.use( + "*", + protect({ + onFailRedirectTo: "/login", + publicPaths: [ + "/", + "/accept-invite/:path*", // :path* is a wildcard that will match any path after /accept-invite + "/forgot-password", + "/join", + "/login", + "/sso-login", + "/oauth/callback", + "/logout", + "/otp", + "/resend-otp", + "/reset-password", + "/send-otp", + "/healthcheck", + "/api/public-stats", + "/api/oss-friends", + "/api/stripe-webhook", + "/qr", + "/qr/:path*", + "/qr/:path*/contact-owner", + "/qr/:path*/not-logged-in", + ], + }) + ); -/** - * Add remix middleware to Hono server - */ -app.use(async (c, next) => { - const build = (isProductionMode - ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - // eslint-disable-next-line import/no-unresolved -- this expected until you build the app - await import("../build/server/remix.js") - : await importDevBuild()) as unknown as ServerBuild; - - return remix({ - build, - mode, - getLoadContext(context) { - const session = getSession(context); - - return { - // Nice to have if you want to display the app version or do something in the app when deploying a new version - // Exemple: on navigate, check if the app version is the same as the one in the build assets and if not, display a toast to the user to refresh the page - // Prevent the user to use an old version of the client side code (it is only downloaded on document request) - appVersion: isProductionMode ? build.assets.version : "dev", - isAuthenticated: session.has(authSessionKey), - // we could ensure that session.get() match a specific shape - // let's trust our system for now - getSession: () => { - const auth = session.get(authSessionKey); - - if (!auth) { - throw new ShelfError({ - cause: null, - message: - "There is no session here. This should not happen because if you require it, this route should be mark as protected and catch by the protect middleware.", - status: 403, - label: "Dev error", - }); - } - - return auth; - }, - setSession: (auth: any) => { - session.set(authSessionKey, auth); - }, - destroySession: () => { - session.unset(authSessionKey); + /** + * Add remix middleware to Hono server + */ + server.use(async (c, next) => { + const build = (isProductionMode + ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-ignore + // eslint-disable-next-line import/no-unresolved -- this expected until you build the app + await import("../build/server/remix.js") + : await importDevBuild()) as unknown as ServerBuild; + + return remix({ + build, + mode, + getLoadContext(context) { + const session = getSession(context); + + return { + // Nice to have if you want to display the app version or do something in the app when deploying a new version + // Exemple: on navigate, check if the app version is the same as the one in the build assets and if not, display a toast to the user to refresh the page + // Prevent the user to use an old version of the client side code (it is only downloaded on document request) + appVersion: isProductionMode ? build.assets.version : "dev", + isAuthenticated: session.has(authSessionKey), + // we could ensure that session.get() match a specific shape + // let's trust our system for now + getSession: () => { + const auth = session.get(authSessionKey); + + if (!auth) { + throw new ShelfError({ + cause: null, + message: + "There is no session here. This should not happen because if you require it, this route should be mark as protected and catch by the protect middleware.", + status: 403, + label: "Dev error", + }); + } + + return auth; + }, + setSession: (auth: any) => { + session.set(authSessionKey, auth); + }, + destroySession: () => { + session.unset(authSessionKey); + }, + errorMessage: session.get("errorMessage") || null, + } satisfies AppLoadContext; }, - errorMessage: session.get("errorMessage") || null, - } satisfies AppLoadContext; - }, - })(c, next); + })(c, next); + }); + }, }); /** @@ -235,20 +236,4 @@ declare module "@remix-run/node" { } } -/** - * Start the server - */ -if (isProductionMode) { - serve( - { - ...app, - port: Number(process.env.PORT) || 3000, - }, - (info) => { - // eslint-disable-next-line no-console - console.log(`🚀 Server started on port ${info.port}`); - } - ); -} - -export default app; +export default server; diff --git a/vite.config.ts b/vite.config.ts index 234ac7a3b..9acf6aa8b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,8 @@ import { vitePlugin as remix } from "@remix-run/dev"; import { defineConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; -import devServer, { defaultOptions } from "@hono/vite-dev-server"; +// import devServer, { defaultOptions } from "@hono/vite-dev-server"; +import { devServer } from "react-router-hono-server/dev"; import esbuild from "esbuild"; import { flatRoutes } from "remix-flat-routes"; import { cjsInterop } from "vite-plugin-cjs-interop"; @@ -63,11 +64,12 @@ export default defineConfig({ "react-to-print", ], }), - devServer({ - injectClientScript: false, - entry: "server/index.ts", // The file path of your server. - exclude: [/^\/(app)\/.+/, /^\/@.+$/, /^\/node_modules\/.*/], - }), + devServer(), + // { + // injectClientScript: false, + // entry: "server/index.ts", // The file path of your server. + // exclude: [/^\/(app)\/.+/, /^\/@.+$/, /^\/node_modules\/.*/], + // } remix({ serverBuildFile: "remix.js", ignoredRouteFiles: ["**/.*"], From 7c9decd3d77e7e2e4d93d8be4964c35a3888e450 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 12:27:28 +0300 Subject: [PATCH 04/18] getLoadContext --- server/index.ts | 97 +++++++++++++++++++++---------------------------- 1 file changed, 42 insertions(+), 55 deletions(-) diff --git a/server/index.ts b/server/index.ts index 88b85ea20..acb382ea0 100644 --- a/server/index.ts +++ b/server/index.ts @@ -3,14 +3,13 @@ import "./instrument.server.js"; import { serveStatic } from "@hono/node-server/serve-static"; -import type { AppLoadContext, ServerBuild } from "@remix-run/node"; +import type { AppLoadContext } from "@remix-run/node"; +import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; -import { remix } from "remix-hono/handler"; import { getSession, session } from "remix-hono/session"; import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; -import { importDevBuild } from "./dev/server"; import { logger } from "./logger"; import { cache, protect, refreshSession, urlShortener } from "./middleware"; import { authSessionKey, createSessionStorage } from "./session"; @@ -34,6 +33,45 @@ const mode = env.NODE_ENV === "test" ? "development" : env.NODE_ENV; const isProductionMode = mode === "production"; +export const getLoadContext: HonoServerOptions["getLoadContext"] = ( + c, + { build } +) => { + const session = getSession(c); + + return { + // Nice to have if you want to display the app version or do something in the app when deploying a new version + // Exemple: on navigate, check if the app version is the same as the one in the build assets and if not, display a toast to the user to refresh the page + // Prevent the user to use an old version of the client side code (it is only downloaded on document request) + appVersion: isProductionMode ? build.assets.version : "dev", + isAuthenticated: session.has(authSessionKey), + // we could ensure that session.get() match a specific shape + // let's trust our system for now + getSession: () => { + const auth = session.get(authSessionKey); + + if (!auth) { + throw new ShelfError({ + cause: null, + message: + "There is no session here. This should not happen because if you require it, this route should be mark as protected and catch by the protect middleware.", + status: 403, + label: "Dev error", + }); + } + + return auth; + }, + setSession: (auth: any) => { + session.set(authSessionKey, auth); + }, + destroySession: () => { + session.unset(authSessionKey); + }, + errorMessage: session.get("errorMessage") || null, + } satisfies AppLoadContext; +}; + const server = await createHonoServer({ honoOptions: { getPath: (req) => { @@ -47,6 +85,7 @@ const server = await createHonoServer({ return url.pathname; }, }, + getLoadContext, configure: (server) => { // Apply the middleware to all routes server.use( @@ -139,58 +178,6 @@ const server = await createHonoServer({ ], }) ); - - /** - * Add remix middleware to Hono server - */ - server.use(async (c, next) => { - const build = (isProductionMode - ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment - // @ts-ignore - // eslint-disable-next-line import/no-unresolved -- this expected until you build the app - await import("../build/server/remix.js") - : await importDevBuild()) as unknown as ServerBuild; - - return remix({ - build, - mode, - getLoadContext(context) { - const session = getSession(context); - - return { - // Nice to have if you want to display the app version or do something in the app when deploying a new version - // Exemple: on navigate, check if the app version is the same as the one in the build assets and if not, display a toast to the user to refresh the page - // Prevent the user to use an old version of the client side code (it is only downloaded on document request) - appVersion: isProductionMode ? build.assets.version : "dev", - isAuthenticated: session.has(authSessionKey), - // we could ensure that session.get() match a specific shape - // let's trust our system for now - getSession: () => { - const auth = session.get(authSessionKey); - - if (!auth) { - throw new ShelfError({ - cause: null, - message: - "There is no session here. This should not happen because if you require it, this route should be mark as protected and catch by the protect middleware.", - status: 403, - label: "Dev error", - }); - } - - return auth; - }, - setSession: (auth: any) => { - session.set(authSessionKey, auth); - }, - destroySession: () => { - session.unset(authSessionKey); - }, - errorMessage: session.get("errorMessage") || null, - } satisfies AppLoadContext; - }, - })(c, next); - }); }, }); From 380be94753f713a4cab91dc01dd91a0571f3b106 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 12:28:35 +0300 Subject: [PATCH 05/18] mend --- server/index.ts | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/server/index.ts b/server/index.ts index acb382ea0..dc204dcc0 100644 --- a/server/index.ts +++ b/server/index.ts @@ -85,6 +85,7 @@ const server = await createHonoServer({ return url.pathname; }, }, + assetsDir: "file-assets", getLoadContext, configure: (server) => { // Apply the middleware to all routes @@ -95,23 +96,23 @@ const server = await createHonoServer({ }) ); - /** - * Serve assets files from build/client/assets - */ - server.use( - "/file-assets/*", - cache(60 * 60 * 24 * 365), // 1 year - serveStatic({ root: "./build/client" }) - ); - - /** - * Serve public files - */ - server.use( - "*", - cache(60 * 60), - serveStatic({ root: isProductionMode ? "./build/client" : "./public" }) - ); // 1 hour + // /** + // * Serve assets files from build/client/assets + // */ + // server.use( + // "/file-assets/*", + // cache(60 * 60 * 24 * 365), // 1 year + // serveStatic({ root: "./build/client" }) + // ); + + // /** + // * Serve public files + // */ + // server.use( + // "*", + // cache(60 * 60), + // serveStatic({ root: isProductionMode ? "./build/client" : "./public" }) + // ); // 1 hour /** * Add logger middleware From 6300842c79e2c8ca76040fc029721454b8921ab9 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 12:30:57 +0300 Subject: [PATCH 06/18] mend --- server/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/index.ts b/server/index.ts index dc204dcc0..1ff6a061b 100644 --- a/server/index.ts +++ b/server/index.ts @@ -2,7 +2,6 @@ // It is important to import it as .js for this to work, even if the file is .ts import "./instrument.server.js"; -import { serveStatic } from "@hono/node-server/serve-static"; import type { AppLoadContext } from "@remix-run/node"; import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; @@ -11,7 +10,7 @@ import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; import { logger } from "./logger"; -import { cache, protect, refreshSession, urlShortener } from "./middleware"; +import { protect, refreshSession, urlShortener } from "./middleware"; import { authSessionKey, createSessionStorage } from "./session"; import type { FlashData, SessionData } from "./session"; @@ -86,6 +85,8 @@ const server = await createHonoServer({ }, }, assetsDir: "file-assets", + /** Disable default logger as we have our own */ + defaultLogger: false, getLoadContext, configure: (server) => { // Apply the middleware to all routes From f6282eaa1bd4561a8045ec8cf167c698d1ce6b01 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 12:45:06 +0300 Subject: [PATCH 07/18] more updates + removing package --- package.json | 4 ---- server/index.ts | 30 +++--------------------------- vite.config.ts | 4 ++-- 3 files changed, 5 insertions(+), 33 deletions(-) diff --git a/package.json b/package.json index beaaf3c75..3cde22357 100644 --- a/package.json +++ b/package.json @@ -42,7 +42,6 @@ "@fullcalendar/daygrid": "^6.1.11", "@fullcalendar/list": "^6.1.11", "@fullcalendar/react": "^6.1.11", - "@hono/node-server": "1.10.1", "@markdoc/markdoc": "^0.4.0", "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^5.9.1", @@ -75,7 +74,6 @@ "detectrtc": "^1.4.1", "dom-to-image": "^2.6.0", "framer-motion": "^11.0.5", - "hono": "^4.2.7", "iconv-lite": "^0.6.3", "intl-parse-accept-language": "^1.0.0", "isbot": "^4.4.0", @@ -105,7 +103,6 @@ "react-to-print": "^2.15.1", "react-zorm": "^0.9.0", "react-zxing": "^2.0.0", - "remix-hono": "^0.0.16", "remix-utils": "^7.5.0", "sharp": "^0.33.2", "stripe": "^14.16.0", @@ -118,7 +115,6 @@ }, "devDependencies": { "@faker-js/faker": "^8.4.1", - "@hono/vite-dev-server": "^0.10.0", "@playwright/test": "^1.41.2", "@remix-run/dev": "2.10.3", "@remix-run/eslint-config": "2.10.3", diff --git a/server/index.ts b/server/index.ts index 1ff6a061b..47f99a179 100644 --- a/server/index.ts +++ b/server/index.ts @@ -28,13 +28,9 @@ if (env.NODE_ENV !== "production") { }); } -const mode = env.NODE_ENV === "test" ? "development" : env.NODE_ENV; - -const isProductionMode = mode === "production"; - export const getLoadContext: HonoServerOptions["getLoadContext"] = ( c, - { build } + { build, mode } ) => { const session = getSession(c); @@ -42,7 +38,7 @@ export const getLoadContext: HonoServerOptions["getLoadContext"] = ( // Nice to have if you want to display the app version or do something in the app when deploying a new version // Exemple: on navigate, check if the app version is the same as the one in the build assets and if not, display a toast to the user to refresh the page // Prevent the user to use an old version of the client side code (it is only downloaded on document request) - appVersion: isProductionMode ? build.assets.version : "dev", + appVersion: mode === "production" ? build.assets.version : "dev", isAuthenticated: session.has(authSessionKey), // we could ensure that session.get() match a specific shape // let's trust our system for now @@ -71,7 +67,7 @@ export const getLoadContext: HonoServerOptions["getLoadContext"] = ( } satisfies AppLoadContext; }; -const server = await createHonoServer({ +export const server = await createHonoServer({ honoOptions: { getPath: (req) => { const url = new URL(req.url); @@ -97,24 +93,6 @@ const server = await createHonoServer({ }) ); - // /** - // * Serve assets files from build/client/assets - // */ - // server.use( - // "/file-assets/*", - // cache(60 * 60 * 24 * 365), // 1 year - // serveStatic({ root: "./build/client" }) - // ); - - // /** - // * Serve public files - // */ - // server.use( - // "*", - // cache(60 * 60), - // serveStatic({ root: isProductionMode ? "./build/client" : "./public" }) - // ); // 1 hour - /** * Add logger middleware */ @@ -224,5 +202,3 @@ declare module "@remix-run/node" { errorMessage: string | null; } } - -export default server; diff --git a/vite.config.ts b/vite.config.ts index 9acf6aa8b..2b6dd98f6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -89,10 +89,10 @@ export default defineConfig({ // The final file name outdir: "build/server", // Our server entry point - entryPoints: ["server/index.ts", "server/instrument.server.ts"], + entryPoints: ["server/instrument.server.ts"], // Dependencies that should not be bundled // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again - external: ["./build/server/*", "./instrument.server.js"], + external: ["./instrument.server.js"], platform: "node", format: "esm", // Don't include node_modules in the bundle From c9cc6d117f9c28112dc7728a5079bcb983f90550 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 13:00:05 +0300 Subject: [PATCH 08/18] adjustments to config to make build work --- package-lock.json | 29 ----------------------------- package.json | 5 ++--- vite.config.ts | 1 - 3 files changed, 2 insertions(+), 33 deletions(-) diff --git a/package-lock.json b/package-lock.json index 33a8696a2..c2e02877a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,6 @@ "@fullcalendar/daygrid": "^6.1.11", "@fullcalendar/list": "^6.1.11", "@fullcalendar/react": "^6.1.11", - "@hono/node-server": "1.10.1", "@markdoc/markdoc": "^0.4.0", "@paralleldrive/cuid2": "^2.2.2", "@prisma/client": "^5.9.1", @@ -43,7 +42,6 @@ "detectrtc": "^1.4.1", "dom-to-image": "^2.6.0", "framer-motion": "^11.0.5", - "hono": "^4.2.7", "iconv-lite": "^0.6.3", "intl-parse-accept-language": "^1.0.0", "isbot": "^4.4.0", @@ -73,7 +71,6 @@ "react-to-print": "^2.15.1", "react-zorm": "^0.9.0", "react-zxing": "^2.0.0", - "remix-hono": "^0.0.16", "remix-utils": "^7.5.0", "sharp": "^0.33.2", "stripe": "^14.16.0", @@ -86,7 +83,6 @@ }, "devDependencies": { "@faker-js/faker": "^8.4.1", - "@hono/vite-dev-server": "^0.10.0", "@playwright/test": "^1.41.2", "@remix-run/dev": "2.10.3", "@remix-run/eslint-config": "2.10.3", @@ -1678,31 +1674,6 @@ "tailwindcss": "^3.0" } }, - "node_modules/@hono/node-server": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.10.1.tgz", - "integrity": "sha512-5BKW25JH5PQKPDkTcIgv3yNUPtOAbnnjFFgWvIxxAY/B/ZNeYjjWoAeDmqhIiCgOAJ3Tauuw+0G+VainhuZRYQ==", - "engines": { - "node": ">=18.14.1" - } - }, - "node_modules/@hono/vite-dev-server": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/@hono/vite-dev-server/-/vite-dev-server-0.10.0.tgz", - "integrity": "sha512-JWqdgH59x/PKDrwVCS5EW4eOL4fV+JOuzlKgaHk5eQUgE9vkPwyWwmf8f8rXjsXt5zxOKS3XMlf8sZeglFg3hw==", - "dev": true, - "dependencies": { - "@hono/node-server": "^1.8.2", - "miniflare": "^3.20231218.2", - "minimatch": "^9.0.3" - }, - "engines": { - "node": ">=18.14.1" - }, - "peerDependencies": { - "hono": "*" - } - }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", diff --git a/package.json b/package.json index 3cde22357..754a5e1d3 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "sideEffects": false, "type": "module", "scripts": { - "build": "remix vite:build", + "build": "NODE_ENV=production remix vite:build", "db:diff": "prisma migrate diff --from-url=${DATABASE_URL} --to-migrations=./app/database/migrations --shadow-database-url=${SHADOW_DATABASE_URL} --script > rollback.sql", "db:prepare-migration": "prisma generate && prisma migrate dev --create-only --skip-seed", "db:generate-type": "prisma generate", @@ -12,8 +12,7 @@ "db:deploy-migration": "prisma migrate deploy && prisma generate", "db:deploy-migration:staging": "dotenv -e .env.staging -- prisma migrate deploy && prisma generate", "db:deploy-migration:production": "dotenv -e .env.production -- prisma migrate deploy && prisma generate", - "dev": "dotenv -e .env -- run-p dev:*", - "dev:remix": "vite --host | pino-pretty", + "dev": "vite --host", "production:dev": "dotenv -e .env.production -- run-p dev:*", "staging:dev": "dotenv -e .env.staging -- run-p dev:*", "format": "prettier --write .", diff --git a/vite.config.ts b/vite.config.ts index 2b6dd98f6..44a87eb24 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -71,7 +71,6 @@ export default defineConfig({ // exclude: [/^\/(app)\/.+/, /^\/@.+$/, /^\/node_modules\/.*/], // } remix({ - serverBuildFile: "remix.js", ignoredRouteFiles: ["**/.*"], future: { // unstable_fogOfWar: true, From a9c903d3cd5b2070ad72d34014418a7533942ea0 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 13:15:57 +0300 Subject: [PATCH 09/18] testing instrument.js setup --- app/entry.server.tsx | 5 +++++ {server => app}/instrument.server.ts | 0 server/index.ts | 4 ---- vite.config.ts | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) rename {server => app}/instrument.server.ts (100%) diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 191032497..7538f528e 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -1,3 +1,8 @@ +// import the Sentry instrumentation file before anything else. +// It is important to import it as .js for this to work, even if the file is .ts +// eslint-disable-next-line import/no-unresolved +import "./instrument.server.js"; + /* eslint-disable no-console */ import { PassThrough } from "stream"; diff --git a/server/instrument.server.ts b/app/instrument.server.ts similarity index 100% rename from server/instrument.server.ts rename to app/instrument.server.ts diff --git a/server/index.ts b/server/index.ts index 47f99a179..c5ede90e8 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,7 +1,3 @@ -// import the Sentry instrumentation file before anything else. -// It is important to import it as .js for this to work, even if the file is .ts -import "./instrument.server.js"; - import type { AppLoadContext } from "@remix-run/node"; import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; diff --git a/vite.config.ts b/vite.config.ts index 44a87eb24..9733f30c8 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -88,7 +88,7 @@ export default defineConfig({ // The final file name outdir: "build/server", // Our server entry point - entryPoints: ["server/instrument.server.ts"], + entryPoints: ["./app/instrument.server.ts"], // Dependencies that should not be bundled // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again external: ["./instrument.server.js"], From 9a6072ec8146a644ee2604a3f0374c2c58dcd5e8 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 16:23:39 +0300 Subject: [PATCH 10/18] testing mcguiver fix --- app/instrument.server.ts | 3 +++ server/index.ts | 2 ++ 2 files changed, 5 insertions(+) diff --git a/app/instrument.server.ts b/app/instrument.server.ts index 9e073319d..1db6c1d25 100644 --- a/app/instrument.server.ts +++ b/app/instrument.server.ts @@ -5,6 +5,9 @@ import { SENTRY_DSN } from "~/utils/env"; import type { ShelfError } from "~/utils/error"; import { isLikeShelfError } from "~/utils/error"; +export function initSentry() { + console.log("initSentry"); +} if (SENTRY_DSN) { Sentry.init({ dsn: SENTRY_DSN, diff --git a/server/index.ts b/server/index.ts index c5ede90e8..3ca24b5ca 100644 --- a/server/index.ts +++ b/server/index.ts @@ -2,6 +2,7 @@ import type { AppLoadContext } from "@remix-run/node"; import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; import { getSession, session } from "remix-hono/session"; +import { initSentry } from "~/instrument.server"; import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; @@ -63,6 +64,7 @@ export const getLoadContext: HonoServerOptions["getLoadContext"] = ( } satisfies AppLoadContext; }; +initSentry(); export const server = await createHonoServer({ honoOptions: { getPath: (req) => { From 3d731d22cb8c308daabbe757283da59a5fcfa11f Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 16:28:16 +0300 Subject: [PATCH 11/18] adjusting import approach --- app/entry.server.tsx | 5 ---- app/instrument.server.ts | 62 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 7538f528e..191032497 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -1,8 +1,3 @@ -// import the Sentry instrumentation file before anything else. -// It is important to import it as .js for this to work, even if the file is .ts -// eslint-disable-next-line import/no-unresolved -import "./instrument.server.js"; - /* eslint-disable no-console */ import { PassThrough } from "stream"; diff --git a/app/instrument.server.ts b/app/instrument.server.ts index 1db6c1d25..782dcd192 100644 --- a/app/instrument.server.ts +++ b/app/instrument.server.ts @@ -7,39 +7,39 @@ import { isLikeShelfError } from "~/utils/error"; export function initSentry() { console.log("initSentry"); -} -if (SENTRY_DSN) { - Sentry.init({ - dsn: SENTRY_DSN, - // Performance Monitoring - tracesSampleRate: 0.1, - beforeBreadcrumb(breadcrumb) { - // Remove some noisy breadcrumbs - if ( - breadcrumb.message?.startsWith("🚀") || - breadcrumb.message?.startsWith("🌍") - ) { - return null; - } + if (SENTRY_DSN) { + Sentry.init({ + dsn: SENTRY_DSN, + // Performance Monitoring + tracesSampleRate: 0.1, + beforeBreadcrumb(breadcrumb) { + // Remove some noisy breadcrumbs + if ( + breadcrumb.message?.startsWith("🚀") || + breadcrumb.message?.startsWith("🌍") + ) { + return null; + } - if (breadcrumb.message) { - // Remove chalk colors that pollute the logs - breadcrumb.message = breadcrumb.message.replace( - // eslint-disable-next-line no-control-regex -- let me do my thing - /(\x1B\[32m|\x1B\[0m)/gm, - "" - ); - } + if (breadcrumb.message) { + // Remove chalk colors that pollute the logs + breadcrumb.message = breadcrumb.message.replace( + // eslint-disable-next-line no-control-regex -- let me do my thing + /(\x1B\[32m|\x1B\[0m)/gm, + "" + ); + } - return breadcrumb; - }, - beforeSendTransaction(event, hint) { - return handleBeforeSend(event, hint); - }, - beforeSend(event, hint) { - return handleBeforeSend(event, hint); - }, - }); + return breadcrumb; + }, + beforeSendTransaction(event, hint) { + return handleBeforeSend(event, hint); + }, + beforeSend(event, hint) { + return handleBeforeSend(event, hint); + }, + }); + } } /** From b6ed779b44cc91a18daa8f78b35310506f9596dd Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 16:32:13 +0300 Subject: [PATCH 12/18] small adjustment --- app/entry.server.tsx | 3 +- server/index.ts | 2 +- {app => server}/instrument.server.ts | 0 vite.config.ts | 50 ++++++++++++++-------------- 4 files changed, 27 insertions(+), 28 deletions(-) rename {app => server}/instrument.server.ts (100%) diff --git a/app/entry.server.tsx b/app/entry.server.tsx index 191032497..7c0dd4e86 100644 --- a/app/entry.server.tsx +++ b/app/entry.server.tsx @@ -11,6 +11,7 @@ import { registerBookingWorkers } from "./modules/booking/worker.server"; import { ShelfError } from "./utils/error"; import { Logger } from "./utils/logger"; import * as schedulerService from "./utils/scheduler.server"; +export * from "../server"; // === start: register scheduler and workers === schedulerService @@ -175,5 +176,3 @@ function handleBrowserRequest( setTimeout(abort, ABORT_DELAY); }); } - -export * from "../server"; diff --git a/server/index.ts b/server/index.ts index 3ca24b5ca..ed97ca05c 100644 --- a/server/index.ts +++ b/server/index.ts @@ -2,7 +2,7 @@ import type { AppLoadContext } from "@remix-run/node"; import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; import { getSession, session } from "remix-hono/session"; -import { initSentry } from "~/instrument.server"; +import { initSentry } from "server/instrument.server"; import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; diff --git a/app/instrument.server.ts b/server/instrument.server.ts similarity index 100% rename from app/instrument.server.ts rename to server/instrument.server.ts diff --git a/vite.config.ts b/vite.config.ts index 9733f30c8..0c48b780f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -79,31 +79,31 @@ export default defineConfig({ routes: async (defineRoutes) => { return flatRoutes("routes", defineRoutes); }, - buildEnd: async () => { - await esbuild - .build({ - alias: { - "~": "./app", - }, - // The final file name - outdir: "build/server", - // Our server entry point - entryPoints: ["./app/instrument.server.ts"], - // Dependencies that should not be bundled - // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again - external: ["./instrument.server.js"], - platform: "node", - format: "esm", - // Don't include node_modules in the bundle - packages: "external", - bundle: true, - logLevel: "info", - }) - .catch((error: unknown) => { - console.error(error); - process.exit(1); - }); - }, + // buildEnd: async () => { + // await esbuild + // .build({ + // alias: { + // "~": "./app", + // }, + // // The final file name + // outdir: "build/server", + // // Our server entry point + // entryPoints: ["./app/instrument.server.ts"], + // // Dependencies that should not be bundled + // // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again + // external: ["./instrument.server.js"], + // platform: "node", + // format: "esm", + // // Don't include node_modules in the bundle + // packages: "external", + // bundle: true, + // logLevel: "info", + // }) + // .catch((error: unknown) => { + // console.error(error); + // process.exit(1); + // }); + // }, }), tsconfigPaths(), ], From 40609ee4686f3450e291af17627a97bde0392cc2 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 17:01:40 +0300 Subject: [PATCH 13/18] custom buildend --- server/index.ts | 6 ++-- server/instrument.server.ts | 63 ++++++++++++++++++------------------- vite.config.ts | 59 +++++++++++++++++++--------------- 3 files changed, 68 insertions(+), 60 deletions(-) diff --git a/server/index.ts b/server/index.ts index ed97ca05c..47f99a179 100644 --- a/server/index.ts +++ b/server/index.ts @@ -1,8 +1,11 @@ +// import the Sentry instrumentation file before anything else. +// It is important to import it as .js for this to work, even if the file is .ts +import "./instrument.server.js"; + import type { AppLoadContext } from "@remix-run/node"; import type { HonoServerOptions } from "react-router-hono-server/node"; import { createHonoServer } from "react-router-hono-server/node"; import { getSession, session } from "remix-hono/session"; -import { initSentry } from "server/instrument.server"; import { initEnv, env } from "~/utils/env"; import { ShelfError } from "~/utils/error"; @@ -64,7 +67,6 @@ export const getLoadContext: HonoServerOptions["getLoadContext"] = ( } satisfies AppLoadContext; }; -initSentry(); export const server = await createHonoServer({ honoOptions: { getPath: (req) => { diff --git a/server/instrument.server.ts b/server/instrument.server.ts index 782dcd192..9e073319d 100644 --- a/server/instrument.server.ts +++ b/server/instrument.server.ts @@ -5,41 +5,38 @@ import { SENTRY_DSN } from "~/utils/env"; import type { ShelfError } from "~/utils/error"; import { isLikeShelfError } from "~/utils/error"; -export function initSentry() { - console.log("initSentry"); - if (SENTRY_DSN) { - Sentry.init({ - dsn: SENTRY_DSN, - // Performance Monitoring - tracesSampleRate: 0.1, - beforeBreadcrumb(breadcrumb) { - // Remove some noisy breadcrumbs - if ( - breadcrumb.message?.startsWith("🚀") || - breadcrumb.message?.startsWith("🌍") - ) { - return null; - } +if (SENTRY_DSN) { + Sentry.init({ + dsn: SENTRY_DSN, + // Performance Monitoring + tracesSampleRate: 0.1, + beforeBreadcrumb(breadcrumb) { + // Remove some noisy breadcrumbs + if ( + breadcrumb.message?.startsWith("🚀") || + breadcrumb.message?.startsWith("🌍") + ) { + return null; + } - if (breadcrumb.message) { - // Remove chalk colors that pollute the logs - breadcrumb.message = breadcrumb.message.replace( - // eslint-disable-next-line no-control-regex -- let me do my thing - /(\x1B\[32m|\x1B\[0m)/gm, - "" - ); - } + if (breadcrumb.message) { + // Remove chalk colors that pollute the logs + breadcrumb.message = breadcrumb.message.replace( + // eslint-disable-next-line no-control-regex -- let me do my thing + /(\x1B\[32m|\x1B\[0m)/gm, + "" + ); + } - return breadcrumb; - }, - beforeSendTransaction(event, hint) { - return handleBeforeSend(event, hint); - }, - beforeSend(event, hint) { - return handleBeforeSend(event, hint); - }, - }); - } + return breadcrumb; + }, + beforeSendTransaction(event, hint) { + return handleBeforeSend(event, hint); + }, + beforeSend(event, hint) { + return handleBeforeSend(event, hint); + }, + }); } /** diff --git a/vite.config.ts b/vite.config.ts index 0c48b780f..9f738bda1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -7,6 +7,7 @@ import esbuild from "esbuild"; import { flatRoutes } from "remix-flat-routes"; import { cjsInterop } from "vite-plugin-cjs-interop"; import { init } from "@paralleldrive/cuid2"; +import fs from "node:fs"; const createHash = init({ length: 8, @@ -79,31 +80,39 @@ export default defineConfig({ routes: async (defineRoutes) => { return flatRoutes("routes", defineRoutes); }, - // buildEnd: async () => { - // await esbuild - // .build({ - // alias: { - // "~": "./app", - // }, - // // The final file name - // outdir: "build/server", - // // Our server entry point - // entryPoints: ["./app/instrument.server.ts"], - // // Dependencies that should not be bundled - // // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again - // external: ["./instrument.server.js"], - // platform: "node", - // format: "esm", - // // Don't include node_modules in the bundle - // packages: "external", - // bundle: true, - // logLevel: "info", - // }) - // .catch((error: unknown) => { - // console.error(error); - // process.exit(1); - // }); - // }, + buildEnd: async ({ remixConfig }) => { + const sentryInstrument = `instrument.server`; + await esbuild + .build({ + alias: { + "~": `./${remixConfig.appDirectory}`, + }, + outdir: `${remixConfig.buildDirectory}/server`, + entryPoints: [ + `${remixConfig.appDirectory}/server/${sentryInstrument}.ts`, + ], + platform: "node", + format: "esm", + // Don't include node_modules in the bundle + packages: "external", + bundle: true, + logLevel: "info", + }) + .then(() => { + const serverBuildPath = `${remixConfig.buildDirectory}/server/${remixConfig.serverBuildFile}`; + fs.writeFileSync( + serverBuildPath, + Buffer.concat([ + Buffer.from(`import "./${sentryInstrument}.js"\n`), + Buffer.from(fs.readFileSync(serverBuildPath)), + ]) + ); + }) + .catch((error: unknown) => { + console.error(error); + process.exit(1); + }); + }, }), tsconfigPaths(), ], From c0bb558c09027785ae97172fde1436f3400167ee Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 17:08:55 +0300 Subject: [PATCH 14/18] new build end --- vite.config.ts | 31 +++++++++++++++++++++++++++---- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 9f738bda1..46a731dad 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -80,17 +80,40 @@ export default defineConfig({ routes: async (defineRoutes) => { return flatRoutes("routes", defineRoutes); }, + // buildEnd: async () => { + // await esbuild + // .build({ + // alias: { + // "~": "./app", + // }, + // // The final file name + // outdir: "build/server", + // // Our server entry point + // entryPoints: ["./app/instrument.server.ts"], + // // Dependencies that should not be bundled + // // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again + // external: ["./instrument.server.js"], + // platform: "node", + // format: "esm", + // // Don't include node_modules in the bundle + // packages: "external", + // bundle: true, + // logLevel: "info", + // }) + // .catch((error: unknown) => { + // console.error(error); + // process.exit(1); + // }); + // }, buildEnd: async ({ remixConfig }) => { const sentryInstrument = `instrument.server`; await esbuild .build({ alias: { - "~": `./${remixConfig.appDirectory}`, + "~": `./app`, }, outdir: `${remixConfig.buildDirectory}/server`, - entryPoints: [ - `${remixConfig.appDirectory}/server/${sentryInstrument}.ts`, - ], + entryPoints: [`./server/${sentryInstrument}.ts`], platform: "node", format: "esm", // Don't include node_modules in the bundle From ee5e65b475d5141349c2e03438d69bd9e5242df5 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Thu, 22 Aug 2024 18:13:23 +0300 Subject: [PATCH 15/18] cleanup --- vite.config.ts | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 46a731dad..08ee7f142 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,7 +1,6 @@ import { vitePlugin as remix } from "@remix-run/dev"; import { defineConfig } from "vite"; import tsconfigPaths from "vite-tsconfig-paths"; -// import devServer, { defaultOptions } from "@hono/vite-dev-server"; import { devServer } from "react-router-hono-server/dev"; import esbuild from "esbuild"; import { flatRoutes } from "remix-flat-routes"; @@ -66,45 +65,14 @@ export default defineConfig({ ], }), devServer(), - // { - // injectClientScript: false, - // entry: "server/index.ts", // The file path of your server. - // exclude: [/^\/(app)\/.+/, /^\/@.+$/, /^\/node_modules\/.*/], - // } + remix({ ignoredRouteFiles: ["**/.*"], - future: { - // unstable_fogOfWar: true, - // unstable_singleFetch: true, - }, + routes: async (defineRoutes) => { return flatRoutes("routes", defineRoutes); }, - // buildEnd: async () => { - // await esbuild - // .build({ - // alias: { - // "~": "./app", - // }, - // // The final file name - // outdir: "build/server", - // // Our server entry point - // entryPoints: ["./app/instrument.server.ts"], - // // Dependencies that should not be bundled - // // We import the remix build from "../build/server/remix.js", and the sentry build from "../build/server/instrument.server.js", so no need to bundle it again - // external: ["./instrument.server.js"], - // platform: "node", - // format: "esm", - // // Don't include node_modules in the bundle - // packages: "external", - // bundle: true, - // logLevel: "info", - // }) - // .catch((error: unknown) => { - // console.error(error); - // process.exit(1); - // }); - // }, + buildEnd: async ({ remixConfig }) => { const sentryInstrument = `instrument.server`; await esbuild From 1c5c132415ce37edfab2c75be71f45f2f9346d08 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Mon, 2 Sep 2024 16:02:54 +0300 Subject: [PATCH 16/18] adjusting conflicts --- app/database/db.server.ts | 4 ---- app/utils/scheduler.server.ts | 7 ++++--- 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/app/database/db.server.ts b/app/database/db.server.ts index b54c26e41..320604b94 100644 --- a/app/database/db.server.ts +++ b/app/database/db.server.ts @@ -11,10 +11,8 @@ declare global { var __db__: ExtendedPrismaClient; } -console.log("IN DB file at start"); /** Extending prisma client for dynamic findMany */ function getNewPrismaClient() { - console.log("Inside function getNewPrismaClient"); return new PrismaClient().$extends({ model: { $allModels: { @@ -41,6 +39,4 @@ if (NODE_ENV === "production") { void db.$connect(); } -console.log("In DB file before exporting db"); - export { db }; diff --git a/app/utils/scheduler.server.ts b/app/utils/scheduler.server.ts index cb5617513..ae15d25b9 100644 --- a/app/utils/scheduler.server.ts +++ b/app/utils/scheduler.server.ts @@ -9,16 +9,17 @@ declare global { export const init = async () => { if (!scheduler) { + const url = DATABASE_URL.split("?")[0]; if (NODE_ENV === "production") { scheduler = new PgBoss({ - connectionString: DATABASE_URL, - max: 1, + max: 5, + connectionString: url, }); } else { if (!global.scheduler) { global.scheduler = new PgBoss({ max: 5, - connectionString: DATABASE_URL, + connectionString: url, newJobCheckIntervalSeconds: 60 * 5, noScheduling: true, //need to remove it, if we use cron schedulers in the future, but it comes with a cost of 2 additional polling every minute }); From bfe59e7728e1cd76281e1fb4c1af7b5881569212 Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Mon, 2 Sep 2024 16:12:46 +0300 Subject: [PATCH 17/18] lowering max connections for pg-boss to 4 --- app/utils/scheduler.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/utils/scheduler.server.ts b/app/utils/scheduler.server.ts index ae15d25b9..d6d533a64 100644 --- a/app/utils/scheduler.server.ts +++ b/app/utils/scheduler.server.ts @@ -12,13 +12,13 @@ export const init = async () => { const url = DATABASE_URL.split("?")[0]; if (NODE_ENV === "production") { scheduler = new PgBoss({ - max: 5, + max: 4, connectionString: url, }); } else { if (!global.scheduler) { global.scheduler = new PgBoss({ - max: 5, + max: 4, connectionString: url, newJobCheckIntervalSeconds: 60 * 5, noScheduling: true, //need to remove it, if we use cron schedulers in the future, but it comes with a cost of 2 additional polling every minute From 489f6ce5a1c7d2cc818330184b4b770fee51af4c Mon Sep 17 00:00:00 2001 From: Nikolay Bonev Date: Mon, 2 Sep 2024 16:48:04 +0300 Subject: [PATCH 18/18] updating react-router-hono-server --- package-lock.json | 167 ++++++++++++++++++++++++++-------------------- package.json | 2 +- 2 files changed, 96 insertions(+), 73 deletions(-) diff --git a/package-lock.json b/package-lock.json index c2e02877a..9855545b0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -66,7 +66,7 @@ "react-map-gl": "^7.1.7", "react-media-devices": "^1.1.5", "react-microsoft-clarity": "^1.2.0", - "react-router-hono-server": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", + "react-router-hono-server": "^0.1.0", "react-tag-autocomplete": "^7.1.0", "react-to-print": "^2.15.1", "react-zorm": "^0.9.0", @@ -916,9 +916,9 @@ "dev": true }, "node_modules/@cloudflare/workerd-darwin-64": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240806.0.tgz", - "integrity": "sha512-FqcVBBCO//I39K5F+HqE/v+UkqY1UrRnS653Jv+XsNNH9TpX5fTs7VCKG4kDSnmxlAaKttyIN5sMEt7lpuNExQ==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-64/-/workerd-darwin-64-1.20240821.1.tgz", + "integrity": "sha512-CDBpfZKrSy4YrIdqS84z67r3Tzal2pOhjCsIb63IuCnvVes59/ft1qhczBzk9EffeOE2iTCrA4YBT7Sbn7USew==", "cpu": [ "x64" ], @@ -932,9 +932,9 @@ } }, "node_modules/@cloudflare/workerd-darwin-arm64": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240806.0.tgz", - "integrity": "sha512-8c3KvmzYp/wg+82KHSOzDetJK+pThH4MTrU1OsjmsR2cUfedm5dk5Lah9/0Ld68+6A0umFACi4W2xJHs/RoBpA==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-darwin-arm64/-/workerd-darwin-arm64-1.20240821.1.tgz", + "integrity": "sha512-Q+9RedvNbPcEt/dKni1oN94OxbvuNAeJkgHmrLFTGF8zu21wzOhVkQeRNxcYxrMa9mfStc457NAg13OVCj2kHQ==", "cpu": [ "arm64" ], @@ -948,9 +948,9 @@ } }, "node_modules/@cloudflare/workerd-linux-64": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240806.0.tgz", - "integrity": "sha512-/149Bpxw4e2p5QqnBc06g0mx+4sZYh9j0doilnt0wk/uqYkLp0DdXGMQVRB74sBLg2UD3wW8amn1w3KyFhK2tQ==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-64/-/workerd-linux-64-1.20240821.1.tgz", + "integrity": "sha512-j6z3KsPtawrscoLuP985LbqFrmsJL6q1mvSXOXTqXGODAHIzGBipHARdOjms3UQqovzvqB2lQaQsZtLBwCZxtA==", "cpu": [ "x64" ], @@ -964,9 +964,9 @@ } }, "node_modules/@cloudflare/workerd-linux-arm64": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240806.0.tgz", - "integrity": "sha512-lacDWY3S1rKL/xT6iMtTQJEKmTTKrBavPczInEuBFXElmrS6IwVjZwv8hhVm32piyNt/AuFu9BYoJALi9D85/g==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-linux-arm64/-/workerd-linux-arm64-1.20240821.1.tgz", + "integrity": "sha512-I9bHgZOxJQW0CV5gTdilyxzTG7ILzbTirehQWgfPx9X77E/7eIbR9sboOMgyeC69W4he0SKtpx0sYZuTJu4ERw==", "cpu": [ "arm64" ], @@ -980,9 +980,9 @@ } }, "node_modules/@cloudflare/workerd-windows-64": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240806.0.tgz", - "integrity": "sha512-hC6JEfTSQK6//Lg+D54TLVn1ceTPY+fv4MXqDZIYlPP53iN+dL8Xd0utn2SG57UYdlL5FRAhm/EWHcATZg1RgA==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/@cloudflare/workerd-windows-64/-/workerd-windows-64-1.20240821.1.tgz", + "integrity": "sha512-keC97QPArs6LWbPejQM7/Y8Jy8QqyaZow4/ZdsGo+QjlOLiZRDpAenfZx3CBUoWwEeFwQTl2FLO+8hV1SWFFYw==", "cpu": [ "x64" ], @@ -999,6 +999,7 @@ "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", "integrity": "sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw==", + "license": "MIT", "dependencies": { "@jridgewell/trace-mapping": "0.3.9" }, @@ -1010,6 +1011,7 @@ "version": "0.3.9", "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz", "integrity": "sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==", + "license": "MIT", "dependencies": { "@jridgewell/resolve-uri": "^3.0.3", "@jridgewell/sourcemap-codec": "^1.4.10" @@ -1534,6 +1536,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.1.tgz", "integrity": "sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==", + "license": "MIT", "engines": { "node": ">=14" } @@ -1674,6 +1677,35 @@ "tailwindcss": "^3.0" } }, + "node_modules/@hono/node-server": { + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.12.2.tgz", + "integrity": "sha512-xjzhqhSWUE/OhN0g3KCNVzNsQMlFUAL+/8GgPUr3TKcU7cvgZVBGswFofJ8WwGEHTqobzze1lDpGJl9ZNckDhA==", + "license": "MIT", + "engines": { + "node": ">=18.14.1" + }, + "peerDependencies": { + "hono": "^4" + } + }, + "node_modules/@hono/vite-dev-server": { + "version": "0.13.1", + "resolved": "https://registry.npmjs.org/@hono/vite-dev-server/-/vite-dev-server-0.13.1.tgz", + "integrity": "sha512-AK0yQkGwoQvcbf0MeBDDslVnVvzlKjAT00Z2A4Oqyh0RYhLQyCT1aSJzz3eZj7tYytG0B6EGt92DjrkB0tsy1A==", + "license": "MIT", + "dependencies": { + "@hono/node-server": "^1.12.0", + "miniflare": "^3.20240701.0", + "minimatch": "^9.0.3" + }, + "engines": { + "node": ">=18.14.1" + }, + "peerDependencies": { + "hono": "*" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.14", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.14.tgz", @@ -8751,6 +8783,7 @@ "version": "1.0.55", "resolved": "https://registry.npmjs.org/as-table/-/as-table-1.0.55.tgz", "integrity": "sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==", + "license": "MIT", "dependencies": { "printable-characters": "^1.0.42" } @@ -9321,6 +9354,7 @@ "version": "0.7.0", "resolved": "https://registry.npmjs.org/capnp-ts/-/capnp-ts-0.7.0.tgz", "integrity": "sha512-XKxXAC3HVPv7r674zP0VC3RTXz+/JKhfyw94ljvF80yynK6VkTnqE3jMuN8b3dUVmmc43TjyxjW4KTsmB3c86g==", + "license": "MIT", "dependencies": { "debug": "^4.3.1", "tslib": "^2.2.0" @@ -12668,6 +12702,7 @@ "version": "2.0.12", "resolved": "https://registry.npmjs.org/get-source/-/get-source-2.0.12.tgz", "integrity": "sha512-X5+4+iD+HoSeEED+uwrQ07BOQr0kEDFMVqqpBuI+RaZBpBpHCuXxo70bjar6f0b0u/DQJsJ7ssurpP0V60Az+w==", + "license": "Unlicense", "dependencies": { "data-uri-to-buffer": "^2.0.0", "source-map": "^0.6.1" @@ -12676,12 +12711,14 @@ "node_modules/get-source/node_modules/data-uri-to-buffer": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-2.0.2.tgz", - "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==" + "integrity": "sha512-ND9qDTLc6diwj+Xe5cdAgVTbLVdXbtxTJRXRhli8Mowuaan+0EJOtdqJ0QCHNSSPyoXGx9HX2/VMnKeC34AChA==", + "license": "MIT" }, "node_modules/get-source/node_modules/source-map": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "license": "BSD-3-Clause", "engines": { "node": ">=0.10.0" } @@ -12810,7 +12847,8 @@ "node_modules/glob-to-regexp": { "version": "0.4.1", "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", - "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==" + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "license": "BSD-2-Clause" }, "node_modules/global-prefix": { "version": "3.0.0", @@ -13087,9 +13125,9 @@ } }, "node_modules/hono": { - "version": "4.5.8", - "resolved": "https://registry.npmjs.org/hono/-/hono-4.5.8.tgz", - "integrity": "sha512-pqpSlcdqGkpTTRpLYU1PnCz52gVr0zVR9H5GzMyJWuKQLLEBQxh96q45QizJ2PPX8NATtz2mu31/PKW/Jt+90Q==", + "version": "4.5.10", + "resolved": "https://registry.npmjs.org/hono/-/hono-4.5.10.tgz", + "integrity": "sha512-az6tdU1U8o/l0v8O37FIQuc+ER/TeD9vHt/qs8JnBDgMxw6Zu5L2AixUyHeXZNcu87r7iYo8Ey85R7IogOINKA==", "license": "MIT", "engines": { "node": ">=16.0.0" @@ -15745,9 +15783,9 @@ } }, "node_modules/miniflare": { - "version": "3.20240806.1", - "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240806.1.tgz", - "integrity": "sha512-wJq3YQYx9k83L2CNYtxvwWvXSi+uHrC6aFoXYSbzhxIDlUWvMEqippj+3HeKLgsggC31nHJab3b1Pifg9IxIFQ==", + "version": "3.20240821.0", + "resolved": "https://registry.npmjs.org/miniflare/-/miniflare-3.20240821.0.tgz", + "integrity": "sha512-4BhLGpssQxM/O6TZmJ10GkT3wBJK6emFkZ3V87/HyvQmVt8zMxEBvyw5uv6kdtp+7F54Nw6IKFJjPUL8rFVQrQ==", "license": "MIT", "dependencies": { "@cspotcode/source-map-support": "0.8.1", @@ -15758,7 +15796,7 @@ "glob-to-regexp": "^0.4.1", "stoppable": "^1.1.0", "undici": "^5.28.4", - "workerd": "1.20240806.0", + "workerd": "1.20240821.1", "ws": "^8.17.1", "youch": "^3.2.2", "zod": "^3.22.3" @@ -15771,9 +15809,10 @@ } }, "node_modules/miniflare/node_modules/ws": { - "version": "8.17.1", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.17.1.tgz", - "integrity": "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ==", + "version": "8.18.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.18.0.tgz", + "integrity": "sha512-8VbfWfHLbbwu3+N6OKsOMpBdT4kXPDDB9cJk2bJ6mh9ucxdlnNvH1e+roYkKmN9Nxw2yjz7VzeO9oOz2zJ04Pw==", + "license": "MIT", "engines": { "node": ">=10.0.0" }, @@ -16118,6 +16157,7 @@ "version": "4.2.0", "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "license": "MIT", "bin": { "mustache": "bin/mustache" } @@ -18012,6 +18052,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/pretty-cache-header/-/pretty-cache-header-1.0.0.tgz", "integrity": "sha512-xtXazslu25CdnGnUkByU1RoOjK55TqwatJkjjJLg5ZAdz2Lngko/mmaUgeET36P2GMlNwh3fdM7FWBO717pNcw==", + "license": "MIT", "dependencies": { "timestring": "^6.0.0" }, @@ -18069,7 +18110,8 @@ "node_modules/printable-characters": { "version": "1.0.42", "resolved": "https://registry.npmjs.org/printable-characters/-/printable-characters-1.0.42.tgz", - "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==" + "integrity": "sha512-dKp+C4iXWK4vVYZmYSd0KBH5F/h1HoZRsbJ82AVKRO3PEo8L4lBS/vLwhVtpwwuYcoIsVY+1JYKR268yn480uQ==", + "license": "Unlicense" }, "node_modules/prisma": { "version": "5.15.1", @@ -18667,9 +18709,9 @@ } }, "node_modules/react-router-hono-server": { - "version": "0.0.5", - "resolved": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", - "integrity": "sha512-bwiWhHe0Vbi4W3dXtd4eNJmOgzyvdoUvUibWeCECWovNfA//F3bs6YX83FAOkfoIhl3XhAVWgU1uwcC5VeS/rw==", + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/react-router-hono-server/-/react-router-hono-server-0.1.0.tgz", + "integrity": "sha512-kxEczgoER4ci1XxMtBhcKMGLbScdcH2TFur7kMcBixHrB9CfNX4GkwLFGvact6Z1GxhtHMvTM5af7xFUljOJ2g==", "license": "ISC", "workspaces": [ ".", @@ -18698,32 +18740,6 @@ "vite": "^5.0.0" } }, - "node_modules/react-router-hono-server/node_modules/@hono/node-server": { - "version": "1.12.1", - "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-1.12.1.tgz", - "integrity": "sha512-C9l+08O8xtXB7Ppmy8DjBFH1hYji7JKzsU32Yt1poIIbdPp6S7aOI8IldDHD9YFJ55lv2c21ovNrmxatlHfhAg==", - "license": "MIT", - "engines": { - "node": ">=18.14.1" - } - }, - "node_modules/react-router-hono-server/node_modules/@hono/vite-dev-server": { - "version": "0.13.1", - "resolved": "https://registry.npmjs.org/@hono/vite-dev-server/-/vite-dev-server-0.13.1.tgz", - "integrity": "sha512-AK0yQkGwoQvcbf0MeBDDslVnVvzlKjAT00Z2A4Oqyh0RYhLQyCT1aSJzz3eZj7tYytG0B6EGt92DjrkB0tsy1A==", - "license": "MIT", - "dependencies": { - "@hono/node-server": "^1.12.0", - "miniflare": "^3.20240701.0", - "minimatch": "^9.0.3" - }, - "engines": { - "node": ">=18.14.1" - }, - "peerDependencies": { - "hono": "*" - } - }, "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-arm64-gnu": { "version": "4.18.1", "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.18.1.tgz", @@ -18738,9 +18754,9 @@ ] }, "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-x64-gnu": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.0.tgz", - "integrity": "sha512-e2hrvElFIh6kW/UNBQK/kzqMNY5mO+67YtEh9OA65RM5IJXYTWiXjX6fjIiPaqOkBthYF1EqgiZ6OXKcQsM0hg==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.21.2.tgz", + "integrity": "sha512-B90tYAUoLhU22olrafY3JQCFLnT3NglazdwkHyxNDYF/zAxJt5fJUB/yBoWFoIQ7SQj+KLe3iL4BhOMa9fzgpw==", "cpu": [ "x64" ], @@ -18751,9 +18767,9 @@ ] }, "node_modules/react-router-hono-server/node_modules/@rollup/rollup-linux-x64-musl": { - "version": "4.21.0", - "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.0.tgz", - "integrity": "sha512-1vvmgDdUSebVGXWX2lIcgRebqfQSff0hMEkLJyakQ9JQUbLDkEaMsPTLOmyccyC6IJ/l3FZuJbmrBw/u0A0uCQ==", + "version": "4.21.2", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.21.2.tgz", + "integrity": "sha512-7twFizNXudESmC9oneLGIUmoHiiLppz/Xs5uJQ4ShvE6234K0VB1/aJYU3f/4g7PhssLGKBVCC37uRkkOi8wjg==", "cpu": [ "x64" ], @@ -19240,6 +19256,7 @@ "url": "https://github.com/sponsors/sergiodxa" } ], + "license": "MIT", "dependencies": { "@remix-run/server-runtime": "^2.6.0", "hono": "^4.0.0", @@ -20203,6 +20220,7 @@ "version": "2.1.8", "resolved": "https://registry.npmjs.org/stacktracey/-/stacktracey-2.1.8.tgz", "integrity": "sha512-Kpij9riA+UNg7TnphqjH7/CzctQ/owJGNbFkfEeve4Z4uxT5+JapVLFXcsurIfN34gnTWZNJ/f7NMG0E8JDzTw==", + "license": "Unlicense", "dependencies": { "as-table": "^1.0.36", "get-source": "^2.0.12" @@ -20262,6 +20280,7 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/stoppable/-/stoppable-1.1.0.tgz", "integrity": "sha512-KXDYZ9dszj6bzvnEMRYvxgeTHU74QBFL54XKtP3nyMuJ81CFYtABZ3bAzL2EdFUaEwJOBOgENyFj3R7oTzDyyw==", + "license": "MIT", "engines": { "node": ">=4", "npm": ">=6" @@ -21012,6 +21031,7 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/timestring/-/timestring-6.0.0.tgz", "integrity": "sha512-wMctrWD2HZZLuIlchlkE2dfXJh7J2KDI9Dwl+2abPYg0mswQHfOAyQW3jJg1pY5VfttSINZuKcXoB3FGypVklA==", + "license": "MIT", "engines": { "node": ">=8" } @@ -21824,6 +21844,7 @@ "version": "5.28.4", "resolved": "https://registry.npmjs.org/undici/-/undici-5.28.4.tgz", "integrity": "sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==", + "license": "MIT", "dependencies": { "@fastify/busboy": "^2.0.0" }, @@ -23130,9 +23151,9 @@ } }, "node_modules/workerd": { - "version": "1.20240806.0", - "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20240806.0.tgz", - "integrity": "sha512-yyNtyzTMgVY0sgYijHBONqZFVXsOFGj2jDjS8MF/RbO2ZdGROvs4Hkc/9QnmqFWahE0STxXeJ1yW1yVotdF0UQ==", + "version": "1.20240821.1", + "resolved": "https://registry.npmjs.org/workerd/-/workerd-1.20240821.1.tgz", + "integrity": "sha512-y4phjCnEG96u8ZkgkkHB+gSw0i6uMNo23rBmixylWpjxDklB+LWD8dztasvsu7xGaZbLoTxQESdEw956F7VJDA==", "hasInstallScript": true, "license": "Apache-2.0", "bin": { @@ -23142,11 +23163,11 @@ "node": ">=16" }, "optionalDependencies": { - "@cloudflare/workerd-darwin-64": "1.20240806.0", - "@cloudflare/workerd-darwin-arm64": "1.20240806.0", - "@cloudflare/workerd-linux-64": "1.20240806.0", - "@cloudflare/workerd-linux-arm64": "1.20240806.0", - "@cloudflare/workerd-windows-64": "1.20240806.0" + "@cloudflare/workerd-darwin-64": "1.20240821.1", + "@cloudflare/workerd-darwin-arm64": "1.20240821.1", + "@cloudflare/workerd-linux-64": "1.20240821.1", + "@cloudflare/workerd-linux-arm64": "1.20240821.1", + "@cloudflare/workerd-windows-64": "1.20240821.1" } }, "node_modules/wrap-ansi": { @@ -23363,6 +23384,7 @@ "version": "3.3.3", "resolved": "https://registry.npmjs.org/youch/-/youch-3.3.3.tgz", "integrity": "sha512-qSFXUk3UZBLfggAW3dJKg0BMblG5biqSF8M34E06o5CSsZtH92u9Hqmj2RzGiHDi64fhe83+4tENFP2DB6t6ZA==", + "license": "MIT", "dependencies": { "cookie": "^0.5.0", "mustache": "^4.2.0", @@ -23373,6 +23395,7 @@ "version": "0.5.0", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz", "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==", + "license": "MIT", "engines": { "node": ">= 0.6" } diff --git a/package.json b/package.json index 754a5e1d3..9c311317e 100644 --- a/package.json +++ b/package.json @@ -97,7 +97,7 @@ "react-map-gl": "^7.1.7", "react-media-devices": "^1.1.5", "react-microsoft-clarity": "^1.2.0", - "react-router-hono-server": "https://pkg.pr.new/rphlmr/react-router-hono-server@6", + "react-router-hono-server": "^0.1.0", "react-tag-autocomplete": "^7.1.0", "react-to-print": "^2.15.1", "react-zorm": "^0.9.0",