From f2711fd80f48fc83848970ae02404904da4aac0a Mon Sep 17 00:00:00 2001 From: Ou Date: Thu, 3 Oct 2024 23:11:10 +0800 Subject: [PATCH] feat: support cache on cloudflare page --- package.json | 12 +- pnpm-lock.yaml | 350 ++++++++++++++------------------------- server/cache.ts | 12 +- server/routes/[id].ts | 5 +- server/sources/zaobao.ts | 4 +- server/utils/date.ts | 4 +- shared/dir.ts | 3 + vite.config.ts | 17 +- 8 files changed, 157 insertions(+), 250 deletions(-) create mode 100644 shared/dir.ts diff --git a/package.json b/package.json index 9b4ff90..a0e7d20 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,9 @@ "build": "vite build", "lint": "eslint .", "favicon": "tsx ./scripts/favicon.ts", + "start": "PORT=4444 node dist/output/server/index.mjs", + "preview": "CF_PAGES=1 pnpm run build && wrangler pages dev", + "deploy": "CF_PAGES=1 pnpm run build && wrangler pages deploy", "test": "vitest" }, "dependencies": { @@ -20,14 +23,15 @@ "@tanstack/react-router": "^1.58.9", "@tanstack/router-devtools": "^1.58.9", "@unocss/reset": "^0.62.4", - "better-sqlite3": "^9.4.3", "cheerio": "^1.0.0", "clsx": "^2.1.1", "dayjs": "^1.11.13", + "db0": "npm:@ourongxing/db0@latest", "fast-xml-parser": "^4.5.0", "favicons-scraper": "^1.3.2", "iconv-lite": "^0.6.3", "jotai": "^2.10.0", + "libsql": "^0.4.5", "overlayscrollbars": "^2.10.0", "overlayscrollbars-react": "^0.5.6", "react": "^18.3.1", @@ -48,7 +52,6 @@ "eslint": "^9.11.1", "eslint-plugin-react-hooks": "^5.1.0-rc-778e1ed2-20240926", "eslint-plugin-react-refresh": "^0.4.12", - "nitro-cloudflare-dev": "^0.1.6", "nitropack": "^2.9.7", "ofetch": "^1.4.0", "tsx": "^4.19.1", @@ -60,5 +63,10 @@ "vite-tsconfig-paths": "^5.0.1", "vitest": "^2.1.1", "wrangler": "^3.79.0" + }, + "pnpm": { + "overrides": { + "db0": "npm:@ourongxing/db0@latest" + } } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 9fa6aae..ca0ca45 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,9 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +overrides: + db0: npm:@ourongxing/db0@latest + importers: .: @@ -32,9 +35,6 @@ importers: '@unocss/reset': specifier: ^0.62.4 version: 0.62.4 - better-sqlite3: - specifier: ^9.4.3 - version: 9.6.0 cheerio: specifier: ^1.0.0 version: 1.0.0 @@ -44,6 +44,9 @@ importers: dayjs: specifier: ^1.11.13 version: 1.11.13 + db0: + specifier: npm:@ourongxing/db0@latest + version: '@ourongxing/db0@0.1.5(libsql@0.4.5)' fast-xml-parser: specifier: ^4.5.0 version: 4.5.0 @@ -56,6 +59,9 @@ importers: jotai: specifier: ^2.10.0 version: 2.10.0(@types/react@18.3.9)(react@18.3.1) + libsql: + specifier: ^0.4.5 + version: 0.4.5 overlayscrollbars: specifier: ^2.10.0 version: 2.10.0 @@ -111,12 +117,9 @@ importers: eslint-plugin-react-refresh: specifier: ^0.4.12 version: 0.4.12(eslint@9.11.1(jiti@1.21.6)) - nitro-cloudflare-dev: - specifier: ^0.1.6 - version: 0.1.6 nitropack: specifier: ^2.9.7 - version: 2.9.7(better-sqlite3@9.6.0)(encoding@0.1.13)(magicast@0.3.5) + version: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5) ofetch: specifier: ^1.4.0 version: 1.4.0 @@ -137,7 +140,7 @@ importers: version: 5.4.8(@types/node@22.6.1)(terser@5.33.0) vite-plugin-with-nitro: specifier: 0.0.0-beta.4 - version: 0.0.0-beta.4(better-sqlite3@9.6.0)(encoding@0.1.13)(magicast@0.3.5)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)) + version: 0.0.0-beta.4(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)) vite-tsconfig-paths: specifier: ^5.0.1 version: 5.0.1(typescript@5.6.2)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)) @@ -1160,10 +1163,48 @@ packages: '@jridgewell/trace-mapping@0.3.9': resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} + '@libsql/darwin-arm64@0.4.5': + resolution: {integrity: sha512-xLdnn0NrgSk6OMi716FFs/27Hs33jtSd2fkKi/72Ey/qBtPWcB1BMurDQekzi0yAcfQTjGqIz7tpOibyjiEPyQ==} + cpu: [arm64] + os: [darwin] + + '@libsql/darwin-x64@0.4.5': + resolution: {integrity: sha512-rZsEWj0H7oCqd5Y2pe0RzKmuQXC2OB1RbnFy4CvjeAjT6MP6mFp+Vx9mTCAUuJMhuoSVMsFPUJRpAQznl9E3Tg==} + cpu: [x64] + os: [darwin] + + '@libsql/linux-arm64-gnu@0.4.5': + resolution: {integrity: sha512-VR09iu6KWGJ6fauCn59u/jJ9OA+/A2yQ0dr2HDN2zkRueLC6D2oGYt4gPfLZPFKf+WJpVMtIhNfd+Ru9MMaFkA==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-arm64-musl@0.4.5': + resolution: {integrity: sha512-74hvD5ej4rBshhxFGNYU16a3m8B/NjIPvhlZ/flG1Oeydfo6AuUXSSNFi+H5+zi9/uWuzyz5TLVeQcraoUV10A==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-x64-gnu@0.4.5': + resolution: {integrity: sha512-gb5WObGO3+rbuG8h9font1N02iF+zgYAgY0wNa8BNiZ5A9UolZKFxiqGFS7eHaAYfemHJKKTT+aAt3X2p5TibA==} + cpu: [x64] + os: [linux] + + '@libsql/linux-x64-musl@0.4.5': + resolution: {integrity: sha512-JfyE6OVC5X4Nr4cFF77VhB1o+hBRxAqYT9YdeqnWdAQSYc/ASi5HnRALLAQEsGacFPZZ32pixfraQmPE3iJFfw==} + cpu: [x64] + os: [linux] + + '@libsql/win32-x64-msvc@0.4.5': + resolution: {integrity: sha512-57GGurNJhOhq3XIopLdGnCoQ4kQAcmbmzzFoC4tpvDE/KSbwZ/13zqJWhQA41nMGk/PKM1XKfKmbIybKx1+eqA==} + cpu: [x64] + os: [win32] + '@mapbox/node-pre-gyp@1.0.11': resolution: {integrity: sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==} hasBin: true + '@neon-rs/load@0.0.4': + resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==} + '@netlify/functions@2.8.1': resolution: {integrity: sha512-+6wtYdoz0yE06dSa9XkP47tw5zm6g13QMeCwM3MmHx1vn8hzwFa51JtmfraprdkL7amvb7gaNM+OOhQU1h6T8A==} engines: {node: '>=14.0.0'} @@ -1204,6 +1245,20 @@ packages: resolution: {integrity: sha512-T8TbSnGsxo6TDBJx/Sgv/BlVJL3tshxZP7Aq5R1mSnM5OcHY2dQaxLMu2+E8u3gN0MLOzdjurqN4ZRVuzQycOQ==} engines: {node: '>=8.0'} + '@ourongxing/db0@0.1.5': + resolution: {integrity: sha512-Lm1BXhVZbuwd7rrJwQqv5JrKkq7KExzhu9WzSEwUEb0qUX7iM6P0V0bk4t0rR2y2DMlrbYDwzVaR5e8iKxy/QA==} + peerDependencies: + '@libsql/client': ^0.14.0 + drizzle-orm: ^0.33.0 + libsql: ^0.4.5 + peerDependenciesMeta: + '@libsql/client': + optional: true + drizzle-orm: + optional: true + libsql: + optional: true + '@ourongxing/eslint-config@3.2.3-beta.4': resolution: {integrity: sha512-xxqpu/yvKwgl4hTe6dmlLbmsWO63rg0wt/RkCQmZv3+h9sLgsT8fUmOJRge/so/q/YKLYL0+Y6bJdPxXD3criQ==} hasBin: true @@ -2038,9 +2093,6 @@ packages: base64-js@1.5.1: resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} - better-sqlite3@9.6.0: - resolution: {integrity: sha512-yR5HATnqeYNVnkaUTf4bOP2dJSnyhP4puJN/QPRyx4YkBEEUxib422n2XzPqDEHjQQqazoYoADdAm5vE15+dAQ==} - binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -2051,9 +2103,6 @@ packages: birecord@0.1.1: resolution: {integrity: sha512-VUpsf/qykW0heRlC8LooCq28Kxn3mAqKohhDG/49rrsQ1dT1CXyj/pgXS+5BSRzFTR/3DyIBOqQOrGyZOh71Aw==} - bl@4.1.0: - resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} - blake3-wasm@2.1.5: resolution: {integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==} @@ -2082,9 +2131,6 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} - buffer@5.7.1: - resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} @@ -2160,9 +2206,6 @@ packages: resolution: {integrity: sha512-7VT13fmjotKpGipCW9JEQAusEPE+Ei8nl6/g4FBAmIm0GOOLMua9NDDo/DWp0ZAxCr3cPq5ZpBqmPAQgDda2Pw==} engines: {node: '>= 8.10.0'} - chownr@1.1.4: - resolution: {integrity: sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg==} - chownr@2.0.0: resolution: {integrity: sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==} engines: {node: '>=10'} @@ -2317,20 +2360,6 @@ packages: dayjs@1.11.13: resolution: {integrity: sha512-oaMBel6gjolK862uaPQOVTA7q3TZhuSvuMQAAglQDOWYO9A91IrAOUJEyKVlqJlHE0vq5p5UXxzdPfMH/x6xNg==} - db0@0.1.4: - resolution: {integrity: sha512-Ft6eCwONYxlwLjBXSJxw0t0RYtA5gW9mq8JfBXn9TtC0nDPlqePAhpv9v4g9aONBi6JI1OXHTKKkUYGd+BOrCA==} - peerDependencies: - '@libsql/client': ^0.5.2 - better-sqlite3: ^9.4.3 - drizzle-orm: ^0.29.4 - peerDependenciesMeta: - '@libsql/client': - optional: true - better-sqlite3: - optional: true - drizzle-orm: - optional: true - debug@2.6.9: resolution: {integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==} peerDependencies: @@ -2356,18 +2385,10 @@ packages: supports-color: optional: true - decompress-response@6.0.0: - resolution: {integrity: sha512-aW35yZM6Bb/4oJlZncMH2LCoZtJXTRxES17vE3hoRiowU2kWHaJKFkSBDnDR+cm9J+9QhXmREyIfv0pji9ejCQ==} - engines: {node: '>=10'} - deep-eql@5.0.2: resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} engines: {node: '>=6'} - deep-extend@0.6.0: - resolution: {integrity: sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA==} - engines: {node: '>=4.0.0'} - deep-is@0.1.4: resolution: {integrity: sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==} @@ -2405,6 +2426,10 @@ packages: engines: {node: '>=0.10'} hasBin: true + detect-libc@2.0.2: + resolution: {integrity: sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==} + engines: {node: '>=8'} + detect-libc@2.0.3: resolution: {integrity: sha512-bwy0MGW55bG41VqxxypOsdSdGqLwXPI/focwgTYCFMbdUiBAxLg9CFzG08sz2aqzknwiX7Hkl0bQENjg8iLByw==} engines: {node: '>=8'} @@ -2466,9 +2491,6 @@ packages: encoding@0.1.13: resolution: {integrity: sha512-ETBauow1T35Y/WZMkio9jiM0Z5xjHHmJ4XmjZOq1l/dXz3lr2sRn87nJy20RupqSh1F2m3HHPSp8ShIPQJrJ3A==} - end-of-stream@1.4.4: - resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} - enhanced-resolve@5.17.1: resolution: {integrity: sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==} engines: {node: '>=10.13.0'} @@ -2821,10 +2843,6 @@ packages: resolution: {integrity: sha512-eNTPlAD67BmP31LDINZ3U7HSF8l57TxOY2PmBJ1shpCvpnxBF93mWCE8YHBnXs8qiUZJc9WDcWIeC3a2HIAMfw==} engines: {node: '>=6'} - expand-template@2.0.3: - resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} - engines: {node: '>=6'} - fast-deep-equal@3.1.3: resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} @@ -2906,9 +2924,6 @@ packages: front-matter@4.0.2: resolution: {integrity: sha512-I8ZuJ/qG92NWX8i5x1Y8qyj3vizhXS31OxjKDu3LKP+7/qBgfIKValiZIEwoVoJKUHlhWtYrktkxV1XsX+pPlg==} - fs-constants@1.0.0: - resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} - fs-extra@11.2.0: resolution: {integrity: sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw==} engines: {node: '>=14.14'} @@ -2961,9 +2976,6 @@ packages: resolution: {integrity: sha512-8EHPljDvs7qKykr6uw8b+lqLiUc/vUg+KVTI0uND4s63TdsZM2Xus3mflvF0DDG9SiM4RlCkFGL+7aAjRmV7KA==} hasBin: true - github-from-package@0.0.0: - resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} - glob-parent@5.1.2: resolution: {integrity: sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==} engines: {node: '>= 6'} @@ -3112,9 +3124,6 @@ packages: inherits@2.0.4: resolution: {integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==} - ini@1.3.8: - resolution: {integrity: sha512-JV/yugV2uzW5iMRSiZAyDtQd+nxtUnjeLt0acNdw98kKLrvuRVyB80tsREOE7yvGVgalhZ6RNXCmEHkUKBKxew==} - inline-style-prefixer@7.0.1: resolution: {integrity: sha512-lhYo5qNTQp3EvSSp3sRvXMbVQTLrvGV6DycRMJ5dm2BLMiJ30wpXKdDdgX+GmJZ5uQMucwRKHamXSst3Sj/Giw==} @@ -3328,6 +3337,11 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + libsql@0.4.5: + resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==} + cpu: [x64, arm64, wasm32] + os: [darwin, linux, win32] + lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} @@ -3434,10 +3448,6 @@ packages: resolution: {integrity: sha512-vqiC06CuhBTUdZH+RYl8sFrL096vA45Ok5ISO6sE/Mr1jRbGH4Csnhi8f3wKVl7x8mO4Au7Ir9D3Oyv1VYMFJw==} engines: {node: '>=12'} - mimic-response@3.1.0: - resolution: {integrity: sha512-z0yWI+4FDrrweS8Zmt4Ej5HdJmky15+L2e6Wgn3+iK5fWzb6T3fhNFq2+MeTRb064c6Wr4N/wv0DzQTjNzHNGQ==} - engines: {node: '>=10'} - min-indent@1.0.1: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} @@ -3462,9 +3472,6 @@ packages: resolution: {integrity: sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==} engines: {node: '>=16 || 14 >=14.17'} - minimist@1.2.8: - resolution: {integrity: sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==} - minipass@3.3.6: resolution: {integrity: sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==} engines: {node: '>=8'} @@ -3481,9 +3488,6 @@ packages: resolution: {integrity: sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==} engines: {node: '>= 8'} - mkdirp-classic@0.5.3: - resolution: {integrity: sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==} - mkdirp@1.0.4: resolution: {integrity: sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==} engines: {node: '>=10'} @@ -3521,18 +3525,12 @@ packages: engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} hasBin: true - napi-build-utils@1.0.2: - resolution: {integrity: sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg==} - natural-compare-lite@1.4.0: resolution: {integrity: sha512-Tj+HTDSJJKaZnfiuw+iaF9skdPpTo2GtEly5JHnWV/hfv2Qj/9RKsGISQtLh2ox3l5EAGw487hnBee0sIJ6v2g==} natural-compare@1.4.0: resolution: {integrity: sha512-OWND8ei3VtNC9h7V60qff3SVobHr996CTwgxubgyQYEpg290h9J0buyECNNJexkFm5sOajh5G116RYA1c8ZMSw==} - nitro-cloudflare-dev@0.1.6: - resolution: {integrity: sha512-7YcLTJsTZSZZ89XrTEaDEnFsVWbppBgLO0Rr5n3Nf93gKHTBkBfeGH8//8FVwV2poi6SabVbJ0a2eoJRoII81w==} - nitropack@2.9.7: resolution: {integrity: sha512-aKXvtNrWkOCMsQbsk4A0qQdBjrJ1ZcvwlTQevI/LAgLWLYc5L7Q/YiYxGLal4ITyNSlzir1Cm1D2ZxnYhmpMEw==} engines: {node: ^16.11.0 || >=17.0.0} @@ -3543,10 +3541,6 @@ packages: xml2js: optional: true - node-abi@3.68.0: - resolution: {integrity: sha512-7vbj10trelExNjFSBm5kTvZXXa7pZyKWx9RCKIyqe6I9Ev3IzGpQoqBP3a+cOdxY+pWj6VkP28n/2wWysBHD/A==} - engines: {node: '>=10'} - node-addon-api@7.1.1: resolution: {integrity: sha512-5m3bsyrjFWE1xf7nz7YXdN4udnVtXK6/Yfgn5qnahL6bCkf2yKt4k3nuTKAtT4r3IG8JNR2ncsIMdZuAzJjHQQ==} @@ -3767,11 +3761,6 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} - prebuild-install@7.1.2: - resolution: {integrity: sha512-UnNke3IQb6sgarcZIDU3gbMeTp/9SSU1DAIkil7PrqG1vZlBtY5msYccSKSHDqa3hNg436IXK+SNImReuA1wEQ==} - engines: {node: '>=10'} - hasBin: true - prelude-ls@1.2.1: resolution: {integrity: sha512-vkcDPrRZo1QZLbn5RLGPpg/WmIQ65qoWWhcGKf/b5eplkkarX0m9z8ppCat4mlOqUsWpyNuYgO3VRyrYHSzX5g==} engines: {node: '>= 0.8.0'} @@ -3795,9 +3784,6 @@ packages: resolution: {integrity: sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==} engines: {node: '>= 0.6.0'} - pump@3.0.2: - resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==} - punycode@2.3.1: resolution: {integrity: sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==} engines: {node: '>=6'} @@ -3821,10 +3807,6 @@ packages: rc9@2.1.2: resolution: {integrity: sha512-btXCnMmRIBINM2LDZoEmOogIZU7Qe7zn4BpomSKZ/ykbLObuBdvG+mFq11DL6fjH1DRwHhrlgtYWG96bJiC7Cg==} - rc@1.2.8: - resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} - hasBin: true - react-dom@18.3.1: resolution: {integrity: sha512-5m4nQKp+rZRb09LNH59GM4BxTh9251/ylbKIbpe7TpGxfJ+9kv6BLkLBXIjjspbgbnIBNqlI23tRnTWT0snUIw==} peerDependencies: @@ -4060,12 +4042,6 @@ packages: resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} engines: {node: '>=14'} - simple-concat@1.0.1: - resolution: {integrity: sha512-cSFtAPtRhljv69IK0hTVZQ+OfE9nePi/rtJmw5UjHeVyVroEqJXP1sFztKUy1qU+xvz3u/sfYJLa947b7nAN2Q==} - - simple-get@4.0.1: - resolution: {integrity: sha512-brv7p5WgH0jmQJr1ZDDfKDOSeWWg+OVypG99A/5vYGPqJ6pxiaHLy8nxtFjBA7oMa01ebA9gfh1uMCFqOuXxvA==} - sirv@2.0.4: resolution: {integrity: sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==} engines: {node: '>= 10'} @@ -4195,10 +4171,6 @@ packages: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} - strip-json-comments@2.0.1: - resolution: {integrity: sha512-4gB8na07fecVVkOI6Rs4e7T6NOTki5EmL7TUduTs6bu3EdnSycntVJ4re8kgZA+wx9IueI2Y11bfbgwtzuE0KQ==} - engines: {node: '>=0.10.0'} - strip-json-comments@3.1.1: resolution: {integrity: sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==} engines: {node: '>=8'} @@ -4244,13 +4216,6 @@ packages: resolution: {integrity: sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ==} engines: {node: '>=6'} - tar-fs@2.1.1: - resolution: {integrity: sha512-V0r2Y9scmbDRLCNex/+hYzvp/zyYjvFbHPNgVTKfQvVrb6guiE/fxP+XblDNR011utopbkex2nM4dHNV6GDsng==} - - tar-stream@2.2.0: - resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} - engines: {node: '>=6'} - tar-stream@3.1.7: resolution: {integrity: sha512-qJj60CXt7IU1Ffyc3NJMjh6EkuCFej46zUqJ4J7pqYlThyd9bO0XBTmcOIhSzZJVWfsLks0+nle/j538YAW9RQ==} @@ -4362,9 +4327,6 @@ packages: engines: {node: '>=18.0.0'} hasBin: true - tunnel-agent@0.6.0: - resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} - type-check@0.4.0: resolution: {integrity: sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==} engines: {node: '>= 0.8.0'} @@ -5531,6 +5493,27 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.5.0 + '@libsql/darwin-arm64@0.4.5': + optional: true + + '@libsql/darwin-x64@0.4.5': + optional: true + + '@libsql/linux-arm64-gnu@0.4.5': + optional: true + + '@libsql/linux-arm64-musl@0.4.5': + optional: true + + '@libsql/linux-x64-gnu@0.4.5': + optional: true + + '@libsql/linux-x64-musl@0.4.5': + optional: true + + '@libsql/win32-x64-msvc@0.4.5': + optional: true + '@mapbox/node-pre-gyp@1.0.11(encoding@0.1.13)': dependencies: detect-libc: 2.0.3 @@ -5546,6 +5529,8 @@ snapshots: - encoding - supports-color + '@neon-rs/load@0.0.4': {} + '@netlify/functions@2.8.1': dependencies: '@netlify/serverless-functions-api': 1.19.1 @@ -5586,6 +5571,10 @@ snapshots: '@oozcitak/util@8.3.8': {} + '@ourongxing/db0@0.1.5(libsql@0.4.5)': + optionalDependencies: + libsql: 0.4.5 + '@ourongxing/eslint-config@3.2.3-beta.4(@eslint-react/eslint-plugin@1.14.2(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(@typescript-eslint/utils@8.7.0(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2))(@vue/compiler-sfc@3.5.8)(eslint-plugin-react-hooks@5.1.0-rc-fb9a90fa48-20240614(eslint@9.11.1(jiti@1.21.6)))(eslint-plugin-react-refresh@0.4.12(eslint@9.11.1(jiti@1.21.6)))(eslint@9.11.1(jiti@1.21.6))(typescript@5.6.2)(vitest@2.1.1(@types/node@22.6.1)(terser@5.33.0))': dependencies: '@antfu/install-pkg': 0.4.1 @@ -6482,11 +6471,6 @@ snapshots: base64-js@1.5.1: {} - better-sqlite3@9.6.0: - dependencies: - bindings: 1.5.0 - prebuild-install: 7.1.2 - binary-extensions@2.3.0: {} bindings@1.5.0: @@ -6495,12 +6479,6 @@ snapshots: birecord@0.1.1: {} - bl@4.1.0: - dependencies: - buffer: 5.7.1 - inherits: 2.0.4 - readable-stream: 3.6.2 - blake3-wasm@2.1.5: {} boolbase@1.0.0: {} @@ -6529,11 +6507,6 @@ snapshots: buffer-from@1.1.2: {} - buffer@5.7.1: - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - buffer@6.0.3: dependencies: base64-js: 1.5.1 @@ -6640,8 +6613,6 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chownr@1.1.4: {} - chownr@2.0.0: {} ci-info@4.0.0: {} @@ -6773,10 +6744,6 @@ snapshots: dayjs@1.11.13: {} - db0@0.1.4(better-sqlite3@9.6.0): - optionalDependencies: - better-sqlite3: 9.6.0 - debug@2.6.9: dependencies: ms: 2.0.0 @@ -6789,14 +6756,8 @@ snapshots: dependencies: ms: 2.1.3 - decompress-response@6.0.0: - dependencies: - mimic-response: 3.1.0 - deep-eql@5.0.2: {} - deep-extend@0.6.0: {} - deep-is@0.1.4: {} deepmerge@4.3.1: {} @@ -6817,6 +6778,8 @@ snapshots: detect-libc@1.0.3: {} + detect-libc@2.0.2: {} + detect-libc@2.0.3: {} doctrine@3.0.0: @@ -6873,10 +6836,6 @@ snapshots: iconv-lite: 0.6.3 optional: true - end-of-stream@1.4.4: - dependencies: - once: 1.4.0 - enhanced-resolve@5.17.1: dependencies: graceful-fs: 4.2.11 @@ -7475,8 +7434,6 @@ snapshots: exit-hook@2.2.1: {} - expand-template@2.0.3: {} - fast-deep-equal@3.1.3: {} fast-fifo@1.3.2: {} @@ -7551,8 +7508,6 @@ snapshots: dependencies: js-yaml: 3.14.1 - fs-constants@1.0.0: {} - fs-extra@11.2.0: dependencies: graceful-fs: 4.2.11 @@ -7612,8 +7567,6 @@ snapshots: pathe: 1.1.2 tar: 6.2.1 - github-from-package@0.0.0: {} - glob-parent@5.1.2: dependencies: is-glob: 4.0.3 @@ -7782,8 +7735,6 @@ snapshots: inherits@2.0.4: {} - ini@1.3.8: {} - inline-style-prefixer@7.0.1: dependencies: css-in-js-utils: 3.1.0 @@ -7965,6 +7916,19 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + libsql@0.4.5: + dependencies: + '@neon-rs/load': 0.0.4 + detect-libc: 2.0.2 + optionalDependencies: + '@libsql/darwin-arm64': 0.4.5 + '@libsql/darwin-x64': 0.4.5 + '@libsql/linux-arm64-gnu': 0.4.5 + '@libsql/linux-arm64-musl': 0.4.5 + '@libsql/linux-x64-gnu': 0.4.5 + '@libsql/linux-x64-musl': 0.4.5 + '@libsql/win32-x64-msvc': 0.4.5 + lines-and-columns@1.2.4: {} listhen@1.7.2: @@ -8086,8 +8050,6 @@ snapshots: mimic-fn@4.0.0: {} - mimic-response@3.1.0: {} - min-indent@1.0.1: {} miniflare@3.20240925.0: @@ -8125,8 +8087,6 @@ snapshots: dependencies: brace-expansion: 2.0.1 - minimist@1.2.8: {} - minipass@3.3.6: dependencies: yallist: 4.0.0 @@ -8140,8 +8100,6 @@ snapshots: minipass: 3.3.6 yallist: 4.0.0 - mkdirp-classic@0.5.3: {} - mkdirp@1.0.4: {} mlly@1.7.1: @@ -8176,19 +8134,11 @@ snapshots: nanoid@3.3.7: {} - napi-build-utils@1.0.2: {} - natural-compare-lite@1.4.0: {} natural-compare@1.4.0: {} - nitro-cloudflare-dev@0.1.6: - dependencies: - consola: 3.2.3 - mlly: 1.7.1 - pkg-types: 1.2.0 - - nitropack@2.9.7(better-sqlite3@9.6.0)(encoding@0.1.13)(magicast@0.3.5): + nitropack@2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5): dependencies: '@cloudflare/kv-asset-handler': 0.3.4 '@netlify/functions': 2.8.1 @@ -8211,7 +8161,7 @@ snapshots: cookie-es: 1.2.2 croner: 8.1.1 crossws: 0.2.4 - db0: 0.1.4(better-sqlite3@9.6.0) + db0: '@ourongxing/db0@0.1.5(libsql@0.4.5)' defu: 6.1.4 destr: 2.0.3 dot-prop: 8.0.2 @@ -8269,19 +8219,15 @@ snapshots: - '@planetscale/database' - '@upstash/redis' - '@vercel/kv' - - better-sqlite3 - drizzle-orm - encoding - idb-keyval + - libsql - magicast - supports-color - uWebSockets.js - webpack-sources - node-abi@3.68.0: - dependencies: - semver: 7.6.3 - node-addon-api@7.1.1: {} node-fetch-native@1.6.4: {} @@ -8502,21 +8448,6 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 - prebuild-install@7.1.2: - dependencies: - detect-libc: 2.0.3 - expand-template: 2.0.3 - github-from-package: 0.0.0 - minimist: 1.2.8 - mkdirp-classic: 0.5.3 - napi-build-utils: 1.0.2 - node-abi: 3.68.0 - pump: 3.0.2 - rc: 1.2.8 - simple-get: 4.0.1 - tar-fs: 2.1.1 - tunnel-agent: 0.6.0 - prelude-ls@1.2.1: {} prettier@3.3.3: {} @@ -8529,11 +8460,6 @@ snapshots: process@0.11.10: {} - pump@3.0.2: - dependencies: - end-of-stream: 1.4.4 - once: 1.4.0 - punycode@2.3.1: {} queue-microtask@1.2.3: {} @@ -8553,13 +8479,6 @@ snapshots: defu: 6.1.4 destr: 2.0.3 - rc@1.2.8: - dependencies: - deep-extend: 0.6.0 - ini: 1.3.8 - minimist: 1.2.8 - strip-json-comments: 2.0.1 - react-dom@18.3.1(react@18.3.1): dependencies: loose-envify: 1.4.0 @@ -8831,14 +8750,6 @@ snapshots: signal-exit@4.1.0: {} - simple-concat@1.0.1: {} - - simple-get@4.0.1: - dependencies: - decompress-response: 6.0.0 - once: 1.4.0 - simple-concat: 1.0.1 - sirv@2.0.4: dependencies: '@polka/url': 1.0.0-next.28 @@ -8967,8 +8878,6 @@ snapshots: dependencies: min-indent: 1.0.1 - strip-json-comments@2.0.1: {} - strip-json-comments@3.1.1: {} strip-literal@2.1.0: @@ -9004,21 +8913,6 @@ snapshots: tapable@2.2.1: {} - tar-fs@2.1.1: - dependencies: - chownr: 1.1.4 - mkdirp-classic: 0.5.3 - pump: 3.0.2 - tar-stream: 2.2.0 - - tar-stream@2.2.0: - dependencies: - bl: 4.1.0 - end-of-stream: 1.4.4 - fs-constants: 1.0.0 - inherits: 2.0.4 - readable-stream: 3.6.2 - tar-stream@3.1.7: dependencies: b4a: 1.6.6 @@ -9112,10 +9006,6 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - tunnel-agent@0.6.0: - dependencies: - safe-buffer: 5.2.1 - type-check@0.4.0: dependencies: prelude-ls: 1.2.1 @@ -9319,13 +9209,13 @@ snapshots: - supports-color - terser - vite-plugin-with-nitro@0.0.0-beta.4(better-sqlite3@9.6.0)(encoding@0.1.13)(magicast@0.3.5)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)): + vite-plugin-with-nitro@0.0.0-beta.4(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5)(vite@5.4.8(@types/node@22.6.1)(terser@5.33.0)): dependencies: esbuild: 0.24.0 fast-glob: 3.3.2 front-matter: 4.0.2 h3: 1.12.0 - nitropack: 2.9.7(better-sqlite3@9.6.0)(encoding@0.1.13)(magicast@0.3.5) + nitropack: 2.9.7(encoding@0.1.13)(libsql@0.4.5)(magicast@0.3.5) vite: 5.4.8(@types/node@22.6.1)(terser@5.33.0) xmlbuilder2: 3.1.1 transitivePeerDependencies: @@ -9341,10 +9231,10 @@ snapshots: - '@planetscale/database' - '@upstash/redis' - '@vercel/kv' - - better-sqlite3 - drizzle-orm - encoding - idb-keyval + - libsql - magicast - supports-color - uWebSockets.js diff --git a/server/cache.ts b/server/cache.ts index 31f8472..73a939d 100644 --- a/server/cache.ts +++ b/server/cache.ts @@ -1,18 +1,22 @@ import { TTL } from "@shared/consts" import type { CacheInfo } from "@shared/types" +import type { Database } from "db0" export class Cache { private db - constructor(db: any) { + constructor(db: Database) { this.db = db - this.db.exec(` + } + + async init() { + await this.db.prepare(` CREATE TABLE IF NOT EXISTS cache ( id TEXT PRIMARY KEY, data TEXT, updated INTEGER, expires INTEGER ); - `) + `).run() } async set(key: string, value: any) { @@ -23,7 +27,7 @@ export class Cache { } async get(key: string): Promise { - const row = await this.db.prepare(`SELECT id, data, updated, expires FROM cache WHERE id = ?`).get(key) + const row: any = await this.db.prepare(`SELECT id, data, updated, expires FROM cache WHERE id = ?`).get(key) return row ? { ...row, diff --git a/server/routes/[id].ts b/server/routes/[id].ts index 4a21386..482feca 100644 --- a/server/routes/[id].ts +++ b/server/routes/[id].ts @@ -11,6 +11,7 @@ export default defineEventHandler(async (event) => { const db = useDatabase() const cacheStore = db ? new Cache(db) : undefined if (cacheStore) { + await cacheStore.init() const cache = await cacheStore.get(id) if (cache) { if (!latest && cache.expires > Date.now()) { @@ -29,14 +30,14 @@ export default defineEventHandler(async (event) => { if (!sources[id]) { const data = await fallback(id) - if (cacheStore) cacheStore.set(id, data) + if (cacheStore) await cacheStore.set(id, data) return { status: "success", data, } } else { const data = await sources[id]() - if (cacheStore) cacheStore.set(id, data) + if (cacheStore) await cacheStore.set(id, data) return { status: "success", data, diff --git a/server/sources/zaobao.ts b/server/sources/zaobao.ts index a8ec1df..e692c43 100644 --- a/server/sources/zaobao.ts +++ b/server/sources/zaobao.ts @@ -15,7 +15,7 @@ const columns = [ "国际视野", ] as const export async function zaobao(type: typeof columns[number] = "中国聚焦"): Promise { - const response = await $fetch("https://www.kzaobao.com/top.html", { + const response: ArrayBuffer = await $fetch("https://www.kzaobao.com/top.html", { responseType: "arrayBuffer", }) const base = "https://www.kzaobao.com" @@ -23,7 +23,7 @@ export async function zaobao(type: typeof columns[number] = "中国聚焦"): Pro const $ = cheerio.load(utf8String) // const all = [] // columns.forEach((column, index) => { - const $main = $(`#cd0${2}`) + const $main = $(`#cd0${columns.indexOf(type) + 1}`) const news: NewsItem[] = [] $main.find("tr").each((_, el) => { const a = $(el).find("h3>a") diff --git a/server/utils/date.ts b/server/utils/date.ts index b010fdf..b3ca477 100644 --- a/server/utils/date.ts +++ b/server/utils/date.ts @@ -1,6 +1,6 @@ import dayjs from "dayjs" -import utcPlugin from "dayjs/plugin/utc" -import timezonePlugin from "dayjs/plugin/timezone" +import utcPlugin from "dayjs/plugin/utc.js" +import timezonePlugin from "dayjs/plugin/timezone.js" dayjs.extend(utcPlugin) dayjs.extend(timezonePlugin) diff --git a/shared/dir.ts b/shared/dir.ts new file mode 100644 index 0000000..db9d1ae --- /dev/null +++ b/shared/dir.ts @@ -0,0 +1,3 @@ +import { fileURLToPath } from "node:url" + +export const projectDir = fileURLToPath(new URL("..", import.meta.url)) diff --git a/vite.config.ts b/vite.config.ts index 854cafb..f8b3af1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,12 +1,14 @@ import process from "node:process" -import { fileURLToPath } from "node:url" -import nitroCloudflareBindings from "nitro-cloudflare-dev" +import { join } from "node:path" import { defineConfig } from "vite" import react from "@vitejs/plugin-react-swc" import nitro from "vite-plugin-with-nitro" import { TanStackRouterVite } from "@tanstack/router-plugin/vite" import tsconfigPath from "vite-tsconfig-paths" import unocss from "unocss/vite" +import { projectDir } from "./shared/dir" + +const isCF = process.env.CF_PAGES export default defineConfig({ resolve: { @@ -21,13 +23,12 @@ export default defineConfig({ react(), nitro({ ssr: false }, { srcDir: "server", - modules: [nitroCloudflareBindings], experimental: { database: true, }, database: { default: { - connector: "cloudflare-d1", + connector: isCF ? "cloudflare-d1" : "libsql", options: { bindingName: "CACHE_DB", }, @@ -35,14 +36,14 @@ export default defineConfig({ }, devDatabase: { default: { - connector: "sqlite", + connector: "libsql", }, }, alias: { - "@shared": fileURLToPath(new URL("shared", import.meta.url)), - "#": fileURLToPath(new URL("server", import.meta.url)), + "@shared": join(projectDir, "shared"), + "#": join(projectDir, "server"), }, - preset: "cloudflare-pages", + preset: isCF ? "cloudflare-pages" : "node-server", }), ], })