diff --git a/.changeset/famous-shirts-vanish.md b/.changeset/famous-shirts-vanish.md new file mode 100644 index 0000000..518c567 --- /dev/null +++ b/.changeset/famous-shirts-vanish.md @@ -0,0 +1,5 @@ +--- +"stackspulse": minor +--- + +Migrate to libsql. diff --git a/.env.development b/.env.development index ef14f54..62a5e02 100644 --- a/.env.development +++ b/.env.development @@ -1,7 +1,7 @@ NEXT_TELEMETRY_DISABLED=1 CHAINHOOKS_API_TOKEN=dev-api-token CRON_API_TOKEN=dev-api-token -DATABASE_PATH=./sqlite.db +DATABASE_PATH=file:sqlite.db TWITTER_API_KEY=dev TWITTER_API_SECRET_KEY=dev TWITTER_ACCESS_TOKEN=dev diff --git a/.env.production.build b/.env.production.build index 39e75a1..8b620d4 100644 --- a/.env.production.build +++ b/.env.production.build @@ -2,7 +2,7 @@ NEXT_TELEMETRY_DISABLED=1 CHAINHOOKS_API_TOKEN=dev-api-token CRON_API_TOKEN=dev-api-token -DATABASE_PATH=./sqlite.db +DATABASE_PATH=file:sqlite.db TWITTER_API_KEY=dev TWITTER_API_SECRET_KEY=dev TWITTER_ACCESS_TOKEN=dev diff --git a/Dockerfile b/Dockerfile index ee20651..86d7e24 100644 --- a/Dockerfile +++ b/Dockerfile @@ -33,7 +33,7 @@ COPY --link . . # Add fake environment file for build to succeed COPY --link .env.production.build .env.production.local -RUN pnpm db:migrate +RUN pnpm db:push # Build application RUN pnpm run build @@ -54,10 +54,10 @@ COPY --from=build /app/public ./public COPY --from=build /app/.next/standalone ./ COPY --from=build /app/.next/static ./.next/static -# Setup sqlite3 on a separate volume +# Setup sqlite on a separate volume RUN mkdir -p /data VOLUME /data -ENV DATABASE_PATH="/data/sqlite.db" +ENV DATABASE_PATH="file:/data/sqlite.db" # Start the server by default, this can be overwritten at runtime EXPOSE 3000 diff --git a/drizzle.config.ts b/drizzle.config.ts index 79a6e6e..85ce46a 100644 --- a/drizzle.config.ts +++ b/drizzle.config.ts @@ -5,6 +5,6 @@ export default { out: "./drizzle", dialect: "sqlite", dbCredentials: { - url: "./sqlite.db", + url: "file:./sqlite.db", }, } satisfies Config; diff --git a/package.json b/package.json index 494031b..3e81895 100644 --- a/package.json +++ b/package.json @@ -20,13 +20,13 @@ }, "dependencies": { "@dotenvx/dotenvx": "0.40.0", + "@libsql/client": "0.4.3", "@radix-ui/themes": "3.0.5", "@sentry/nextjs": "8.2.1", "@stacks/transactions": "6.15.0", "@t3-oss/env-core": "0.10.1", "@t3-oss/env-nextjs": "0.10.1", "@tabler/icons-react": "3.4.0", - "better-sqlite3": "10.0.0", "class-variance-authority": "0.7.0", "clsx": "2.1.1", "drizzle-orm": "0.30.10", @@ -47,7 +47,6 @@ "@biomejs/biome": "1.7.3", "@changesets/cli": "2.27.2", "@flydotio/dockerfile": "0.5.7", - "@types/better-sqlite3": "7.6.10", "@types/node": "20.12.12", "@types/react": "18.3.2", "@types/react-dom": "18.3.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 7faee36..c66f7ab 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: '@dotenvx/dotenvx': specifier: 0.40.0 version: 0.40.0 + '@libsql/client': + specifier: 0.4.3 + version: 0.4.3 '@radix-ui/themes': specifier: 3.0.5 version: 3.0.5(@types/react-dom@18.3.0)(@types/react@18.3.2)(react-dom@18.3.1(react@18.3.1))(react@18.3.1) @@ -29,9 +32,6 @@ importers: '@tabler/icons-react': specifier: 3.4.0 version: 3.4.0(react@18.3.1) - better-sqlite3: - specifier: 10.0.0 - version: 10.0.0 class-variance-authority: specifier: 0.7.0 version: 0.7.0 @@ -40,7 +40,7 @@ importers: version: 2.1.1 drizzle-orm: specifier: 0.30.10 - version: 0.30.10(@opentelemetry/api@1.8.0)(@types/better-sqlite3@7.6.10)(@types/pg@8.6.1)(@types/react@18.3.2)(better-sqlite3@10.0.0)(react@18.3.1) + version: 0.30.10(@libsql/client@0.4.3)(@opentelemetry/api@1.8.0)(@types/better-sqlite3@7.6.10)(@types/pg@8.6.1)(@types/react@18.3.2)(better-sqlite3@10.0.0)(react@18.3.1) fathom-client: specifier: 3.6.0 version: 3.6.0 @@ -87,9 +87,6 @@ importers: '@flydotio/dockerfile': specifier: 0.5.7 version: 0.5.7 - '@types/better-sqlite3': - specifier: 7.6.10 - version: 7.6.10 '@types/node': specifier: 20.12.12 version: 20.12.12 @@ -829,12 +826,65 @@ packages: '@jridgewell/trace-mapping@0.3.25': resolution: {integrity: sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==} + '@libsql/client@0.4.3': + resolution: {integrity: sha512-AUYKnSPqAsFBVWBvmtrb4dG3pQlvTKT92eztAest9wQU2iJkabH8WzHLDb3dKFWKql7/kiCqvBQUVpozDwhekQ==} + + '@libsql/core@0.4.3': + resolution: {integrity: sha512-r28iYBtaLBW9RRgXPFh6cGCsVI/rwRlOzSOpAu/1PVTm6EJ3t233pUf97jETVHU0vjdr1d8VvV6fKAvJkokqCw==} + + '@libsql/darwin-arm64@0.2.0': + resolution: {integrity: sha512-+qyT2W/n5CFH1YZWv2mxW4Fsoo4dX9Z9M/nvbQqZ7H84J8hVegvVAsIGYzcK8xAeMEcpU5yGKB1Y9NoDY4hOSQ==} + cpu: [arm64] + os: [darwin] + + '@libsql/darwin-x64@0.2.0': + resolution: {integrity: sha512-hwmO2mF1n8oDHKFrUju6Jv+n9iFtTf5JUK+xlnIE3Td0ZwGC/O1R/Z/btZTd9nD+vsvakC8SJT7/Q6YlWIkhEw==} + cpu: [x64] + os: [darwin] + + '@libsql/hrana-client@0.5.6': + resolution: {integrity: sha512-mjQoAmejZ1atG+M3YR2ZW+rg6ceBByH/S/h17ZoYZkqbWrvohFhXyz2LFxj++ARMoY9m6w3RJJIRdJdmnEUlFg==} + + '@libsql/isomorphic-fetch@0.1.12': + resolution: {integrity: sha512-MRo4UcmjAGAa3ac56LoD5OE13m2p0lu0VEtZC2NZMcogM/jc5fU9YtMQ3qbPjFJ+u2BBjFZgMPkQaLS1dlMhpg==} + + '@libsql/isomorphic-ws@0.1.5': + resolution: {integrity: sha512-DtLWIH29onUYR00i0GlQ3UdcTRC6EP4u9w/h9LxpUZJWRMARk6dQwZ6Jkd+QdwVpuAOrdxt18v0K2uIYR3fwFg==} + + '@libsql/linux-arm64-gnu@0.2.0': + resolution: {integrity: sha512-1w2lPXIYtnBaK5t/Ej5E8x7lPiE+jP3KATI/W4yei5Z/ONJh7jQW5PJ7sYU95vTME3hWEM1FXN6kvzcpFAte7w==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-arm64-musl@0.2.0': + resolution: {integrity: sha512-lkblBEJ7xuNiWNjP8DDq0rqoWccszfkUS7Efh5EjJ+GDWdCBVfh08mPofIZg0fZVLWQCY3j+VZCG1qZfATBizg==} + cpu: [arm64] + os: [linux] + + '@libsql/linux-x64-gnu@0.2.0': + resolution: {integrity: sha512-+x/d289KeJydwOhhqSxKT+6MSQTCfLltzOpTzPccsvdt5fxg8CBi+gfvEJ4/XW23Sa+9bc7zodFP0i6MOlxX7w==} + cpu: [x64] + os: [linux] + + '@libsql/linux-x64-musl@0.2.0': + resolution: {integrity: sha512-5Xn0c5A6vKf9D1ASpgk7mef//FuY7t5Lktj/eiU4n3ryxG+6WTpqstTittJUgepVjcleLPYxIhQAYeYwTYH1IQ==} + cpu: [x64] + os: [linux] + + '@libsql/win32-x64-msvc@0.2.0': + resolution: {integrity: sha512-rpK+trBIpRST15m3cMYg5aPaX7kvCIottxY7jZPINkKAaScvfbn9yulU/iZUM9YtuK96Y1ZmvwyVIK/Y5DzoMQ==} + cpu: [x64] + os: [win32] + '@manypkg/find-root@1.1.0': resolution: {integrity: sha512-mki5uBvhHzO8kYYix/WRy2WX8S3B5wdVSc9D6KcU5lQNglP2yt58/VfLuAK49glRXChosY8ap2oJ1qgma3GUVA==} '@manypkg/get-packages@1.1.3': resolution: {integrity: sha512-fo+QhuU3qE/2TQMQmbVMqaQ6EWbMhi4ABWP+O4AM1NqPBuy0OrApV5LO6BrrgnhtAHS2NH6RrVk9OL181tTi8A==} + '@neon-rs/load@0.0.4': + resolution: {integrity: sha512-kTPhdZyTQxB+2wpiRcFWrDcejc4JI6tkPuS7UZCG4l6Zvc5kU/gGQ/ozvHTh1XR5tS+UlfAfGuPajjzQjCiHCw==} + '@next/env@14.2.3': resolution: {integrity: sha512-W7fd7IbkfmeeY2gXrzJYDx8D2lWKbVoTIj1o1ScPHNzvp30s1AuoEFSdr39bC5sjxJaxTtq3OTCZboNp0lNWHA==} @@ -1985,6 +2035,9 @@ packages: '@types/mysql@2.15.22': resolution: {integrity: sha512-wK1pzsJVVAjYCSZWQoWHziQZbNggXFDUEIGf54g4ZM/ERuP86uGdWeKZWMYlqTPMZfHJJvLPyogXGvCOg87yLQ==} + '@types/node-fetch@2.6.11': + resolution: {integrity: sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==} + '@types/node@12.20.55': resolution: {integrity: sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==} @@ -2036,6 +2089,9 @@ packages: '@types/wrap-ansi@3.0.0': resolution: {integrity: sha512-ltIpx+kM7g/MLRZfkbL7EsCEjfzCcScLpkg37eXEtx5kmrAKBkTJwd1GIAjDSL8wTpM6Hzn5YO4pSb91BEwu1g==} + '@types/ws@8.5.10': + resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==} + '@typescript-eslint/parser@7.2.0': resolution: {integrity: sha512-5FKsVcHTk6TafQKQbuIVkXq58Fnbkd2wDL4LB7AURN7RUOu1utVP+G8+6u3ZhEroW3DF6hyo3ZEXxgKgp4KeCg==} engines: {node: ^16.0.0 || >=18.0.0} @@ -2270,6 +2326,9 @@ packages: async@3.2.5: resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} + asynckit@0.4.0: + resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} + atomically@1.7.0: resolution: {integrity: sha512-Xcz9l0z7y9yQ9rdDaxlmaI4uJHf/T8g9hOEzJcsEqX2SjCj4J20uK7+ldkDHMbpJDK76wF7xEIgxc/vSlsfw5w==} engines: {node: '>=10.12.0'} @@ -2491,6 +2550,10 @@ packages: colorspace@1.1.4: resolution: {integrity: sha512-BgvKJiuVu1igBUF2kEjRCZXol6wiiGbY5ipL/oVPwm0BL9sIpMIzM8IK7vwuxIIzOXMV3Ey5w+vxhm0rR/TN8w==} + combined-stream@1.0.8: + resolution: {integrity: sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==} + engines: {node: '>= 0.8'} + commander@11.1.0: resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} engines: {node: '>=16'} @@ -2604,6 +2667,10 @@ packages: damerau-levenshtein@1.0.8: resolution: {integrity: sha512-sdQSFB7+llfUcQHUQO3+B8ERRj0Oa4w9POWMI/puGtuf7gFywGmkaLCElnudfTiKZV+NvHqL0ifzdrI8Ro7ESA==} + data-uri-to-buffer@4.0.1: + resolution: {integrity: sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==} + engines: {node: '>= 12'} + data-view-buffer@1.0.1: resolution: {integrity: sha512-0lht7OugA5x3iJLOWFhWK/5ehONdprk0ISXqVFn/NFrDu+cuc8iADFrGQz5BnRK7LLU3JmkbXSxaqX+/mXYtUA==} engines: {node: '>= 0.4'} @@ -2674,6 +2741,10 @@ packages: resolution: {integrity: sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==} engines: {node: '>= 0.4'} + delayed-stream@1.0.0: + resolution: {integrity: sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==} + engines: {node: '>=0.4.0'} + dequal@2.0.3: resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} engines: {node: '>=6'} @@ -2682,6 +2753,10 @@ packages: resolution: {integrity: sha512-reYkTUJAZb9gUuZ2RvVCNhVHdg62RHnJ7WJl8ftMi4diZ6NWlciOzQN88pUhSELEwflJht4oQDv0F0BMlwaYtA==} engines: {node: '>=8'} + 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'} @@ -3129,6 +3204,10 @@ packages: fecha@4.2.3: resolution: {integrity: sha512-OP2IUU6HeYKJi3i0z4A19kHMQoLVs4Hc+DPqqxI2h/DPZHTm/vjsfC6P0b4jCMy14XizLBqvndQ+UilD7707Jw==} + fetch-blob@3.2.0: + resolution: {integrity: sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==} + engines: {node: ^12.20 || >= 14.13} + figures@3.2.0: resolution: {integrity: sha512-yaduQFRKLXYOGgEn6AZau90j3ggSOyiqXU0F9JZfeXYhNa+Jk4X+s45A2zg5jns87GAFa34BBm2kXw4XpNcbdg==} engines: {node: '>=8'} @@ -3179,6 +3258,14 @@ packages: resolution: {integrity: sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==} engines: {node: '>=14'} + form-data@4.0.0: + resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} + engines: {node: '>= 6'} + + formdata-polyfill@4.0.10: + resolution: {integrity: sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==} + engines: {node: '>=12.20.0'} + fraction.js@4.3.7: resolution: {integrity: sha512-ZsDfxO51wGAXREY55a7la9LScWpwv9RxIrYABrlvOFBlH/ShPnrtsXeuUIfXKKOVicNxQ+o8JTbJvjS4M89yew==} @@ -3629,6 +3716,9 @@ packages: resolution: {integrity: sha512-gFqAIbuKyyso/3G2qhiO2OM6shY6EPP/R0+mkDbyspxKazh8BXDC5FiFsUjlczgdNz/vfra0da2y+aHrusLG/Q==} hasBin: true + js-base64@3.7.7: + resolution: {integrity: sha512-7rCnleh0z2CkXhH67J8K1Ytz0b2Y+yxTPL+/KOJoa20hfnVQ/3/T6W/KflYI4bRHRagNeXeU2bkNGI3v1oS/lw==} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -3708,6 +3798,11 @@ packages: resolution: {integrity: sha512-+bT2uH4E5LGE7h/n3evcS/sQlJXCpIp6ym8OWJ5eV6+67Dsql/LaaT7qJBAt2rzfoa/5QBGBhxDix1dMt2kQKQ==} engines: {node: '>= 0.8.0'} + libsql@0.2.0: + resolution: {integrity: sha512-ELBRqhpJx5Dap0187zKQnntZyk4EjlDHSrjIVL8t+fQ5e8IxbQTeYgZgigMjB1EvrETdkm0Y0VxBGhzPQ+t0Jg==} + cpu: [x64, arm64] + os: [darwin, linux, win32] + lilconfig@2.1.0: resolution: {integrity: sha512-utWOt/GHzuUxnLKxB6dk81RoOeoNeHgbrXiuGk4yyF5qlRz+iIVWu56E2fqGHFrXz0QNUhLB/8nKqvRH66JKGQ==} engines: {node: '>=10'} @@ -3950,6 +4045,10 @@ packages: resolution: {integrity: sha512-CPMcGa+y33xuL1E0TcNIu4YyaZCxnnvkVaEXrsosR3FxN+fV8xvb7Mzpb7IgKler10qeMkE6+Dp8qJhpzdq35g==} engines: {node: '>=10'} + node-domexception@1.0.0: + resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} + engines: {node: '>=10.5.0'} + node-fetch@2.7.0: resolution: {integrity: sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==} engines: {node: 4.x || >=6.0.0} @@ -3959,6 +4058,10 @@ packages: encoding: optional: true + node-fetch@3.3.2: + resolution: {integrity: sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + node-releases@2.0.14: resolution: {integrity: sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw==} @@ -4965,6 +5068,10 @@ packages: wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} + web-streams-polyfill@3.3.3: + resolution: {integrity: sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==} + engines: {node: '>= 8'} + webidl-conversions@3.0.1: resolution: {integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==} @@ -5058,6 +5165,18 @@ packages: wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} + ws@8.17.0: + resolution: {integrity: sha512-uJq6108EgZMAl20KagGkzCKfMEjxmKvZHG7Tlq0Z6nOky7YF7aq4mOx6xK8TJ/i1LeK4Qus7INktacctDgY8Ow==} + engines: {node: '>=10.0.0'} + peerDependencies: + bufferutil: ^4.0.1 + utf-8-validate: '>=5.0.2' + peerDependenciesMeta: + bufferutil: + optional: true + utf-8-validate: + optional: true + xtend@4.0.2: resolution: {integrity: sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==} engines: {node: '>=0.4'} @@ -5807,6 +5926,69 @@ snapshots: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 + '@libsql/client@0.4.3': + dependencies: + '@libsql/core': 0.4.3 + '@libsql/hrana-client': 0.5.6 + js-base64: 3.7.7 + optionalDependencies: + libsql: 0.2.0 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + + '@libsql/core@0.4.3': + dependencies: + js-base64: 3.7.7 + + '@libsql/darwin-arm64@0.2.0': + optional: true + + '@libsql/darwin-x64@0.2.0': + optional: true + + '@libsql/hrana-client@0.5.6': + dependencies: + '@libsql/isomorphic-fetch': 0.1.12 + '@libsql/isomorphic-ws': 0.1.5 + js-base64: 3.7.7 + node-fetch: 3.3.2 + transitivePeerDependencies: + - bufferutil + - encoding + - utf-8-validate + + '@libsql/isomorphic-fetch@0.1.12': + dependencies: + '@types/node-fetch': 2.6.11 + node-fetch: 2.7.0 + transitivePeerDependencies: + - encoding + + '@libsql/isomorphic-ws@0.1.5': + dependencies: + '@types/ws': 8.5.10 + ws: 8.17.0 + transitivePeerDependencies: + - bufferutil + - utf-8-validate + + '@libsql/linux-arm64-gnu@0.2.0': + optional: true + + '@libsql/linux-arm64-musl@0.2.0': + optional: true + + '@libsql/linux-x64-gnu@0.2.0': + optional: true + + '@libsql/linux-x64-musl@0.2.0': + optional: true + + '@libsql/win32-x64-msvc@0.2.0': + optional: true + '@manypkg/find-root@1.1.0': dependencies: '@babel/runtime': 7.24.5 @@ -5823,6 +6005,9 @@ snapshots: globby: 11.1.0 read-yaml-file: 1.1.0 + '@neon-rs/load@0.0.4': + optional: true + '@next/env@14.2.3': {} '@next/eslint-plugin-next@14.2.3': @@ -7100,6 +7285,7 @@ snapshots: '@types/better-sqlite3@7.6.10': dependencies: '@types/node': 20.12.12 + optional: true '@types/bn.js@5.1.5': dependencies: @@ -7218,6 +7404,11 @@ snapshots: dependencies: '@types/node': 20.12.12 + '@types/node-fetch@2.6.11': + dependencies: + '@types/node': 20.12.12 + form-data: 4.0.0 + '@types/node@12.20.55': {} '@types/node@18.19.33': @@ -7274,6 +7465,10 @@ snapshots: '@types/wrap-ansi@3.0.0': {} + '@types/ws@8.5.10': + dependencies: + '@types/node': 20.12.12 + '@typescript-eslint/parser@7.2.0(eslint@8.57.0)(typescript@5.4.5)': dependencies: '@typescript-eslint/scope-manager': 7.2.0 @@ -7567,6 +7762,8 @@ snapshots: async@3.2.5: {} + asynckit@0.4.0: {} + atomically@1.7.0: {} autoprefixer@10.4.19(postcss@8.4.38): @@ -7603,12 +7800,14 @@ snapshots: dependencies: bindings: 1.5.0 prebuild-install: 7.1.2 + optional: true binary-extensions@2.3.0: {} bindings@1.5.0: dependencies: file-uri-to-path: 1.0.0 + optional: true bl@4.1.0: dependencies: @@ -7710,7 +7909,8 @@ snapshots: optionalDependencies: fsevents: 2.3.3 - chownr@1.1.4: {} + chownr@1.1.4: + optional: true chrome-trace-event@1.0.3: {} @@ -7803,6 +8003,10 @@ snapshots: color: 3.2.1 text-hex: 1.0.0 + combined-stream@1.0.8: + dependencies: + delayed-stream: 1.0.0 + commander@11.1.0: {} commander@2.20.3: {} @@ -7912,6 +8116,8 @@ snapshots: damerau-levenshtein@1.0.8: {} + data-uri-to-buffer@4.0.1: {} + data-view-buffer@1.0.1: dependencies: call-bind: 1.0.7 @@ -7954,8 +8160,10 @@ snapshots: decompress-response@6.0.0: dependencies: mimic-response: 3.1.0 + optional: true - deep-extend@0.6.0: {} + deep-extend@0.6.0: + optional: true deep-is@0.1.4: {} @@ -7977,10 +8185,15 @@ snapshots: has-property-descriptors: 1.0.2 object-keys: 1.1.1 + delayed-stream@1.0.0: {} + dequal@2.0.3: {} detect-indent@6.1.0: {} + detect-libc@2.0.2: + optional: true + detect-libc@2.0.3: {} detect-node-es@1.1.0: {} @@ -8040,8 +8253,9 @@ snapshots: transitivePeerDependencies: - supports-color - drizzle-orm@0.30.10(@opentelemetry/api@1.8.0)(@types/better-sqlite3@7.6.10)(@types/pg@8.6.1)(@types/react@18.3.2)(better-sqlite3@10.0.0)(react@18.3.1): + drizzle-orm@0.30.10(@libsql/client@0.4.3)(@opentelemetry/api@1.8.0)(@types/better-sqlite3@7.6.10)(@types/pg@8.6.1)(@types/react@18.3.2)(better-sqlite3@10.0.0)(react@18.3.1): optionalDependencies: + '@libsql/client': 0.4.3 '@opentelemetry/api': 1.8.0 '@types/better-sqlite3': 7.6.10 '@types/pg': 8.6.1 @@ -8074,6 +8288,7 @@ snapshots: end-of-stream@1.4.4: dependencies: once: 1.4.0 + optional: true enhanced-resolve@5.16.1: dependencies: @@ -8530,7 +8745,8 @@ snapshots: signal-exit: 4.1.0 strip-final-newline: 3.0.0 - expand-template@2.0.3: {} + expand-template@2.0.3: + optional: true ext@1.7.0: dependencies: @@ -8568,6 +8784,11 @@ snapshots: fecha@4.2.3: {} + fetch-blob@3.2.0: + dependencies: + node-domexception: 1.0.0 + web-streams-polyfill: 3.3.3 + figures@3.2.0: dependencies: escape-string-regexp: 1.0.5 @@ -8576,7 +8797,8 @@ snapshots: dependencies: flat-cache: 3.2.0 - file-uri-to-path@1.0.0: {} + file-uri-to-path@1.0.0: + optional: true filelist@1.0.4: dependencies: @@ -8624,9 +8846,20 @@ snapshots: cross-spawn: 7.0.3 signal-exit: 4.1.0 + form-data@4.0.0: + dependencies: + asynckit: 0.4.0 + combined-stream: 1.0.8 + mime-types: 2.1.35 + + formdata-polyfill@4.0.10: + dependencies: + fetch-blob: 3.2.0 + fraction.js@4.3.7: {} - fs-constants@1.0.0: {} + fs-constants@1.0.0: + optional: true fs-extra@7.0.1: dependencies: @@ -8686,7 +8919,8 @@ snapshots: dependencies: resolve-pkg-maps: 1.0.0 - github-from-package@0.0.0: {} + github-from-package@0.0.0: + optional: true glob-parent@5.1.2: dependencies: @@ -8866,7 +9100,8 @@ snapshots: inherits@2.0.4: {} - ini@1.3.8: {} + ini@1.3.8: + optional: true internal-slot@1.0.7: dependencies: @@ -9057,6 +9292,8 @@ snapshots: jiti@1.21.0: {} + js-base64@3.7.7: {} + js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -9126,6 +9363,20 @@ snapshots: prelude-ls: 1.2.1 type-check: 0.4.0 + libsql@0.2.0: + dependencies: + '@neon-rs/load': 0.0.4 + detect-libc: 2.0.2 + optionalDependencies: + '@libsql/darwin-arm64': 0.2.0 + '@libsql/darwin-x64': 0.2.0 + '@libsql/linux-arm64-gnu': 0.2.0 + '@libsql/linux-arm64-musl': 0.2.0 + '@libsql/linux-x64-gnu': 0.2.0 + '@libsql/linux-x64-musl': 0.2.0 + '@libsql/win32-x64-msvc': 0.2.0 + optional: true + lilconfig@2.1.0: {} lilconfig@3.0.0: {} @@ -9285,7 +9536,8 @@ snapshots: mimic-fn@4.0.0: {} - mimic-response@3.1.0: {} + mimic-response@3.1.0: + optional: true min-indent@1.0.1: {} @@ -9323,7 +9575,8 @@ snapshots: mixme@0.5.10: {} - mkdirp-classic@0.5.3: {} + mkdirp-classic@0.5.3: + optional: true module-details-from-path@1.0.3: {} @@ -9341,7 +9594,8 @@ snapshots: nanoid@3.3.7: {} - napi-build-utils@1.0.2: {} + napi-build-utils@1.0.2: + optional: true natural-compare@1.4.0: {} @@ -9378,11 +9632,20 @@ snapshots: node-abi@3.62.0: dependencies: semver: 7.6.2 + optional: true + + node-domexception@1.0.0: {} node-fetch@2.7.0: dependencies: whatwg-url: 5.0.0 + node-fetch@3.3.2: + dependencies: + data-uri-to-buffer: 4.0.1 + fetch-blob: 3.2.0 + formdata-polyfill: 4.0.10 + node-releases@2.0.14: {} normalize-package-data@2.5.0: @@ -9667,6 +9930,7 @@ snapshots: simple-get: 4.0.1 tar-fs: 2.1.1 tunnel-agent: 0.6.0 + optional: true preferred-pm@3.1.3: dependencies: @@ -9695,6 +9959,7 @@ snapshots: dependencies: end-of-stream: 1.4.4 once: 1.4.0 + optional: true punycode@2.3.1: {} @@ -9714,6 +9979,7 @@ snapshots: ini: 1.3.8 minimist: 1.2.8 strip-json-comments: 2.0.1 + optional: true react-dom@18.3.1(react@18.3.1): dependencies: @@ -10019,13 +10285,15 @@ snapshots: signal-exit@4.1.0: {} - simple-concat@1.0.1: {} + simple-concat@1.0.1: + optional: true simple-get@4.0.1: dependencies: decompress-response: 6.0.0 once: 1.4.0 simple-concat: 1.0.1 + optional: true simple-swizzle@0.2.2: dependencies: @@ -10172,7 +10440,8 @@ snapshots: dependencies: min-indent: 1.0.1 - strip-json-comments@2.0.1: {} + strip-json-comments@2.0.1: + optional: true strip-json-comments@3.1.1: {} @@ -10250,6 +10519,7 @@ snapshots: mkdirp-classic: 0.5.3 pump: 3.0.0 tar-stream: 2.2.0 + optional: true tar-stream@2.2.0: dependencies: @@ -10258,6 +10528,7 @@ snapshots: fs-constants: 1.0.0 inherits: 2.0.4 readable-stream: 3.6.2 + optional: true term-size@2.2.1: {} @@ -10342,6 +10613,7 @@ snapshots: tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 + optional: true twitter-api-v2@1.16.1: {} @@ -10481,6 +10753,8 @@ snapshots: dependencies: defaults: 1.0.4 + web-streams-polyfill@3.3.3: {} + webidl-conversions@3.0.1: {} webpack-sources@3.2.3: {} @@ -10630,6 +10904,8 @@ snapshots: wrappy@1.0.2: {} + ws@8.17.0: {} + xtend@4.0.2: {} xxhashjs@0.2.2: diff --git a/scripts/docker-runtime-deps.mjs b/scripts/docker-runtime-deps.mjs index 89ed115..50e94ae 100644 --- a/scripts/docker-runtime-deps.mjs +++ b/scripts/docker-runtime-deps.mjs @@ -12,7 +12,7 @@ const __dirname = dirname(new URL(import.meta.url).pathname); const packageJsonPath = join(__dirname, "..", "package.json"); const dependenciesToInstall = [ "husky", - "better-sqlite3", + "@libsql/client", "drizzle-orm", "@dotenvx/dotenvx", ]; diff --git a/scripts/drizzle-migrate.mjs b/scripts/drizzle-migrate.mjs index 044b4ca..8cfb628 100644 --- a/scripts/drizzle-migrate.mjs +++ b/scripts/drizzle-migrate.mjs @@ -1,8 +1,10 @@ -import sqlite from "better-sqlite3"; -import { drizzle } from "drizzle-orm/better-sqlite3"; -import { migrate } from "drizzle-orm/better-sqlite3/migrator"; +import { createClient } from "@libsql/client"; +import { drizzle } from "drizzle-orm/libsql"; +import { migrate } from "drizzle-orm/libsql/migrator"; -const client = sqlite(process.env.DATABASE_PATH); +const client = createClient({ + url: process.env.DATABASE_PATH, +}); const db = drizzle(client); diff --git a/src/db/db.ts b/src/db/db.ts index 6b4bcec..e6a8333 100644 --- a/src/db/db.ts +++ b/src/db/db.ts @@ -1,6 +1,6 @@ import { env } from "@/env"; -import Database from "better-sqlite3"; -import { drizzle } from "drizzle-orm/better-sqlite3"; +import { createClient } from "@libsql/client"; +import { drizzle } from "drizzle-orm/libsql"; import * as schema from "./schema"; // Patch BigInt to be JSON serializable @@ -19,7 +19,7 @@ BigInt.prototype.toJSON = function () { // } // } -export const sqlite = new Database(env.DATABASE_PATH); +export const sqlite = createClient({ url: env.DATABASE_PATH }); export const db = drizzle(sqlite, { schema, // Enable to log all queries for debugging