feat: add Vercel KV (#2533)

This commit is contained in:
Matty Jorgensen 2024-01-02 04:58:37 -06:00 committed by GitHub
parent 77588c1890
commit b016320eaf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 74 additions and 29 deletions

View file

@ -8,7 +8,7 @@ NUXT_CLOUDFLARE_ACCOUNT_ID=
NUXT_CLOUDFLARE_NAMESPACE_ID=
NUXT_CLOUDFLARE_API_TOKEN=
# 'cloudflare' | 'fs'
# 'cloudflare' | 'vercel' | 'fs'
NUXT_STORAGE_DRIVER=
NUXT_STORAGE_FS_BASE=

View file

@ -102,6 +102,12 @@ export default defineNuxtConfig({
namespaceId: '',
apiToken: '',
},
vercel: {
url: '',
token: '',
env: '',
base: '',
},
public: {
privacyPolicyUrl: '',
// We use LibreTranslate (https://github.com/LibreTranslate/LibreTranslate) as

View file

@ -57,6 +57,8 @@
"@tiptap/suggestion": "2.1.8",
"@tiptap/vue-3": "2.1.8",
"@unocss/nuxt": "^0.53.4",
"@upstash/redis": "^1.27.1",
"@vercel/kv": "^1.0.1",
"@vue-macros/nuxt": "^1.6.0",
"@vueuse/core": "^10.2.1",
"@vueuse/gesture": "2.0.0-beta.1",

View file

@ -34,7 +34,7 @@ importers:
version: 2.1.7
'@nuxt/devtools':
specifier: ^1.0.0-beta.1
version: 1.0.4(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0)
version: 1.0.4(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0)
'@nuxt/test-utils':
specifier: ^3.9.0-alpha.1
version: 3.9.0-alpha.1(@vue/test-utils@2.4.3)(h3@1.9.0)(happy-dom@10.5.2)(rollup@2.79.1)(vite@4.5.0)(vitest@1.1.0)(vue-router@4.2.5)(vue@3.3.9)
@ -92,6 +92,12 @@ importers:
'@unocss/nuxt':
specifier: ^0.53.4
version: 0.53.4(postcss@8.4.32)(rollup@2.79.1)(vite@4.5.0)(webpack@5.89.0)
'@upstash/redis':
specifier: ^1.27.1
version: 1.27.1
'@vercel/kv':
specifier: ^1.0.1
version: 1.0.1
'@vue-macros/nuxt':
specifier: ^1.6.0
version: 1.6.0(@vue-macros/reactivity-transform@0.3.23)(@vueuse/core@10.2.1)(nuxt@3.8.2)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)(vue@3.3.9)(webpack@5.89.0)
@ -299,7 +305,7 @@ importers:
version: 14.0.1
nuxt:
specifier: 3.8.2
version: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
version: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
prettier:
specifier: ^3.0.3
version: 3.0.3
@ -333,10 +339,10 @@ importers:
devDependencies:
'@nuxt-themes/docus':
specifier: ^1.14.6
version: 1.14.6(idb-keyval@6.2.1)(nuxt@3.8.2)(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9)
version: 1.14.6(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9)
nuxt:
specifier: ^3.7.0
version: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
version: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
packages:
@ -2804,13 +2810,13 @@ packages:
transitivePeerDependencies:
- supports-color
/@nuxt-themes/docus@1.14.6(idb-keyval@6.2.1)(nuxt@3.8.2)(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9):
/@nuxt-themes/docus@1.14.6(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9):
resolution: {integrity: sha512-tkSG7j0jhVo53wEpK9V48hIvaK0XEzVU64hXhFfnIMv6LJu99cKOC//boebPbN9qLbJmkBdo4IAIJ0tN5MD0qw==}
dependencies:
'@nuxt-themes/elements': 0.9.4(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9)
'@nuxt-themes/tokens': 1.9.1(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9)
'@nuxt-themes/typography': 0.11.0(postcss@8.4.32)(rollup@3.29.4)(vue@3.3.9)
'@nuxt/content': 2.7.2(idb-keyval@6.2.1)(rollup@3.29.4)
'@nuxt/content': 2.7.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(rollup@3.29.4)
'@nuxthq/studio': 0.13.4(rollup@3.29.4)
'@vueuse/integrations': 10.2.1(focus-trap@7.5.2)(fuse.js@6.6.2)(idb-keyval@6.2.1)(vue@3.3.9)
'@vueuse/nuxt': 10.2.1(nuxt@3.8.2)(rollup@3.29.4)(vue@3.3.9)
@ -2893,7 +2899,7 @@ packages:
- vue
dev: true
/@nuxt/content@2.7.2(idb-keyval@6.2.1)(rollup@3.29.4):
/@nuxt/content@2.7.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(rollup@3.29.4):
resolution: {integrity: sha512-fP0nrnyjtFbluKltKUtC7jSMFc1xAH+bwweZyLwXb3gkIap2EHlVL+e9ptGt39+4HIkRkLgME7TNr/fUO+CHug==}
dependencies:
'@nuxt/kit': 3.8.2(rollup@3.29.4)
@ -2930,7 +2936,7 @@ packages:
unist-util-position: 5.0.0
unist-util-stringify-position: 4.0.0
unist-util-visit: 5.0.0
unstorage: 1.9.0(idb-keyval@6.2.1)
unstorage: 1.9.0(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
ws: 8.14.2
transitivePeerDependencies:
- '@azure/app-configuration'
@ -2962,7 +2968,7 @@ packages:
'@nuxt/kit': 3.8.2(rollup@2.79.1)
'@nuxt/schema': 3.8.2(rollup@2.79.1)
execa: 7.2.0
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
vite: 4.5.0
transitivePeerDependencies:
- rollup
@ -2977,7 +2983,7 @@ packages:
'@nuxt/kit': 3.8.2(rollup@3.29.4)
'@nuxt/schema': 3.8.2(rollup@3.29.4)
execa: 7.2.0
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
vite: 4.5.0
transitivePeerDependencies:
- rollup
@ -2999,7 +3005,7 @@ packages:
rc9: 2.1.1
semver: 7.5.4
/@nuxt/devtools@1.0.4(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0):
/@nuxt/devtools@1.0.4(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0):
resolution: {integrity: sha512-G1Oo9+TaOYzePIXpNX+Zzalw/rJyIZKZpZmXfzolPlOJSA1i0JKzZX6Z7iQHdqPwNJ8t+HnVaF4PghPIpo1kwg==}
hasBin: true
peerDependencies:
@ -3025,8 +3031,8 @@ packages:
launch-editor: 2.6.1
local-pkg: 0.5.0
magicast: 0.3.2
nitropack: 2.8.1(idb-keyval@6.2.1)
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nitropack: 2.8.1(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nypm: 0.3.3
ofetch: 1.3.3
ohash: 1.1.3
@ -3065,7 +3071,7 @@ packages:
- utf-8-validate
- xml2js
/@nuxt/devtools@1.0.4(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@3.29.4)(vite@4.5.0):
/@nuxt/devtools@1.0.4(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@3.29.4)(vite@4.5.0):
resolution: {integrity: sha512-G1Oo9+TaOYzePIXpNX+Zzalw/rJyIZKZpZmXfzolPlOJSA1i0JKzZX6Z7iQHdqPwNJ8t+HnVaF4PghPIpo1kwg==}
hasBin: true
peerDependencies:
@ -3091,8 +3097,8 @@ packages:
launch-editor: 2.6.1
local-pkg: 0.5.0
magicast: 0.3.2
nitropack: 2.8.1(idb-keyval@6.2.1)
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nitropack: 2.8.1(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nypm: 0.3.3
ofetch: 1.3.3
ohash: 1.1.3
@ -5123,6 +5129,22 @@ packages:
- rollup
dev: false
/@upstash/redis@1.25.1:
resolution: {integrity: sha512-ACj0GhJ4qrQyBshwFgPod6XufVEfKX2wcaihsEvSdLYnY+m+pa13kGt1RXm/yTHKf4TQi/Dy2A8z/y6WUEOmlg==}
dependencies:
crypto-js: 4.2.0
/@upstash/redis@1.27.1:
resolution: {integrity: sha512-K9UgTBypJ4Dx65s2u5auoyf/5YoCQjaN91QtxlkNg+3g0rqXXy4ELtzACstk1v+bTa547Mm3rzTjotDX/s9+Zg==}
dependencies:
crypto-js: 4.2.0
/@vercel/kv@1.0.1:
resolution: {integrity: sha512-uTKddsqVYS2GRAM/QMNNXCTuw9N742mLoGRXoNDcyECaxEXvIHG0dEY+ZnYISV4Vz534VwJO+64fd9XeSggSKw==}
engines: {node: '>=14.6'}
dependencies:
'@upstash/redis': 1.25.1
/@vercel/nft@0.24.3:
resolution: {integrity: sha512-IyBdIxmFAeGZnEfMgt4QrGK7XX4lWazlQj34HEi9dw04/WeDBJ7r1yaOIO5tTf9pbfvwUFodj9b0H+NDGGoOMg==}
engines: {node: '>=16'}
@ -5618,7 +5640,7 @@ packages:
'@vue-macros/common': 1.7.2(rollup@2.79.1)(vue@3.3.9)
'@vue-macros/short-vmodel': 1.2.15(rollup@2.79.1)(vue@3.3.9)
'@vue-macros/volar': 0.13.3(@vue-macros/reactivity-transform@0.3.23)(rollup@2.79.1)(typescript@5.1.6)(vue-tsc@1.8.8)(vue@3.3.9)
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
unplugin-vue-macros: 2.4.4(@vueuse/core@10.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue@3.3.9)(webpack@5.89.0)
transitivePeerDependencies:
- '@vue-macros/reactivity-transform'
@ -6037,7 +6059,7 @@ packages:
'@vueuse/core': 10.2.1(vue@3.3.9)
'@vueuse/metadata': 10.2.1
local-pkg: 0.4.3
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
vue-demi: 0.14.5(vue@3.3.9)
transitivePeerDependencies:
- '@vue/composition-api'
@ -6055,7 +6077,7 @@ packages:
'@vueuse/core': 10.2.1(vue@3.3.9)
'@vueuse/metadata': 10.2.1
local-pkg: 0.4.3
nuxt: 3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
nuxt: 3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8)
vue-demi: 0.14.5(vue@3.3.9)
transitivePeerDependencies:
- '@vue/composition-api'
@ -7185,6 +7207,9 @@ packages:
resolution: {integrity: sha512-mCxBlsHFYh9C+HVpiEacem8FEBnMXgU9gy4zmNC+SXAZNB/1idgp/aulFJ4FgCi7GPEVbfyng092GqL2k2rmow==}
dev: false
/crypto-js@4.2.0:
resolution: {integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==}
/crypto-random-string@2.0.0:
resolution: {integrity: sha512-v1plID3y9r/lPhviJ1wrXpLeyUIGAZ2SHNYTEapm7/8A9nLPoyvVp3RK/EPFqn5kEznyWgYZNsRtYYIWbuG8KA==}
engines: {node: '>=8'}
@ -10675,7 +10700,7 @@ packages:
resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==}
dev: false
/nitropack@2.8.1(idb-keyval@6.2.1):
/nitropack@2.8.1(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1):
resolution: {integrity: sha512-pODv2kEEzZSDQR+1UMXbGyNgMedUDq/qUomtiAnQKQvLy52VGlecXO1xDfH3i0kP1yKEcKTnWsx1TAF5gHM7xQ==}
engines: {node: ^16.11.0 || >=17.0.0}
hasBin: true
@ -10748,7 +10773,7 @@ packages:
unctx: 2.3.1
unenv: 1.8.0
unimport: 3.6.0(rollup@4.6.0)
unstorage: 1.9.0(idb-keyval@6.2.1)
unstorage: 1.9.0(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
transitivePeerDependencies:
- '@azure/app-configuration'
- '@azure/cosmos'
@ -11043,7 +11068,7 @@ packages:
dev: false
patched: true
/nuxt@3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8):
/nuxt@3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@2.79.1)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8):
resolution: {integrity: sha512-HUAyifmqTs2zcQBGvcby3KNs2pBAk+l7ZbLjD1oCNqQQ+wBuZ1qgLC4Ebu++y4g3o3Y8WAWSvpafbKRLQZziPw==}
engines: {node: ^14.18.0 || >=16.10.0}
hasBin: true
@ -11057,7 +11082,7 @@ packages:
optional: true
dependencies:
'@nuxt/devalue': 2.0.2
'@nuxt/devtools': 1.0.4(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0)
'@nuxt/devtools': 1.0.4(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@2.79.1)(vite@4.5.0)
'@nuxt/kit': 3.8.2(rollup@2.79.1)
'@nuxt/schema': 3.8.2(rollup@2.79.1)
'@nuxt/telemetry': 2.5.2(rollup@2.79.1)
@ -11086,7 +11111,7 @@ packages:
knitwork: 1.0.0
magic-string: 0.30.5
mlly: 1.4.2
nitropack: 2.8.1(idb-keyval@6.2.1)
nitropack: 2.8.1(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
nuxi: 3.10.0
nypm: 0.3.3
ofetch: 1.3.3
@ -11146,7 +11171,7 @@ packages:
- vue-tsc
- xml2js
/nuxt@3.8.2(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8):
/nuxt@3.8.2(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(eslint@8.49.0)(idb-keyval@6.2.1)(rollup@3.29.4)(typescript@5.1.6)(vite@4.5.0)(vue-tsc@1.8.8):
resolution: {integrity: sha512-HUAyifmqTs2zcQBGvcby3KNs2pBAk+l7ZbLjD1oCNqQQ+wBuZ1qgLC4Ebu++y4g3o3Y8WAWSvpafbKRLQZziPw==}
engines: {node: ^14.18.0 || >=16.10.0}
hasBin: true
@ -11160,7 +11185,7 @@ packages:
optional: true
dependencies:
'@nuxt/devalue': 2.0.2
'@nuxt/devtools': 1.0.4(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@3.29.4)(vite@4.5.0)
'@nuxt/devtools': 1.0.4(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)(nuxt@3.8.2)(rollup@3.29.4)(vite@4.5.0)
'@nuxt/kit': 3.8.2(rollup@3.29.4)
'@nuxt/schema': 3.8.2(rollup@3.29.4)
'@nuxt/telemetry': 2.5.2(rollup@3.29.4)
@ -11189,7 +11214,7 @@ packages:
knitwork: 1.0.0
magic-string: 0.30.5
mlly: 1.4.2
nitropack: 2.8.1(idb-keyval@6.2.1)
nitropack: 2.8.1(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1)
nuxi: 3.10.0
nypm: 0.3.3
ofetch: 1.3.3
@ -14248,7 +14273,7 @@ packages:
webpack-sources: 3.2.3
webpack-virtual-modules: 0.6.1
/unstorage@1.9.0(idb-keyval@6.2.1):
/unstorage@1.9.0(@upstash/redis@1.27.1)(@vercel/kv@1.0.1)(idb-keyval@6.2.1):
resolution: {integrity: sha512-VpD8ZEYc/le8DZCrny3bnqKE4ZjioQxBRnWE+j5sGNvziPjeDlaS1NaFFHzl/kkXaO3r7UaF8MGQrs14+1B4pQ==}
peerDependencies:
'@azure/app-configuration': ^1.4.1
@ -14286,6 +14311,8 @@ packages:
idb-keyval:
optional: true
dependencies:
'@upstash/redis': 1.27.1
'@vercel/kv': 1.0.1
anymatch: 3.1.3
chokidar: 3.5.3
destr: 2.0.2

View file

@ -1,6 +1,7 @@
import fs from 'unstorage/drivers/fs'
import memory from 'unstorage/drivers/memory'
import kv from 'unstorage/drivers/cloudflare-kv-http'
import vercelKVDriver from 'unstorage/drivers/vercel-kv'
import { $fetch } from 'ofetch'
@ -29,6 +30,15 @@ else if (driver === 'cloudflare') {
apiToken: config.cloudflare.apiToken,
})))
}
else if (driver === 'vercel') {
const config = useRuntimeConfig()
storage.mount('servers', cached(vercelKVDriver({
url: config.vercel.url,
token: config.vercel.token,
env: config.vercel.env,
base: config.vercel.base,
})))
}
else if (driver === 'memory') {
storage.mount('servers', memory())
}