Skip to content

Commit f414587

Browse files
committed
fix: migrate to upstash unstorage driver in prod
1 parent 16b012a commit f414587

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

modules/cache.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import process from 'node:process'
2-
import { defineNuxtModule } from 'nuxt/kit'
2+
import { defineNuxtModule, useRuntimeConfig } from 'nuxt/kit'
33
import { provider } from 'std-env'
44

55
// Storage key for fetch cache - must match shared/utils/fetch-cache-config.ts
@@ -14,9 +14,17 @@ export default defineNuxtModule({
1414
return
1515
}
1616

17+
const config = useRuntimeConfig()
18+
1719
nuxt.hook('nitro:config', nitroConfig => {
1820
nitroConfig.storage = nitroConfig.storage || {}
1921

22+
const upstash = {
23+
driver: 'upstash' as const,
24+
url: config.upstash.redisRestUrl,
25+
token: config.upstash.redisRestToken,
26+
}
27+
2028
// Main cache storage (for defineCachedFunction, etc.)
2129
nitroConfig.storage.cache = {
2230
...nitroConfig.storage.cache,
@@ -30,9 +38,8 @@ export default defineNuxtModule({
3038
}
3139

3240
const env = process.env.VERCEL_ENV
33-
nitroConfig.storage.atproto = {
34-
driver: env === 'production' ? 'vercel-kv' : 'vercel-runtime-cache',
35-
}
41+
nitroConfig.storage.atproto =
42+
env === 'production' ? upstash : { driver: 'vercel-runtime-cache' }
3643
})
3744
},
3845
})

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
"@unocss/nuxt": "66.6.0",
6868
"@unocss/preset-wind4": "66.6.0",
6969
"@upstash/redis": "1.36.1",
70-
"@vercel/kv": "3.0.0",
7170
"@vite-pwa/assets-generator": "1.0.2",
7271
"@vite-pwa/nuxt": "1.1.0",
7372
"@voidzero-dev/vite-plus-core": "0.0.0-833c515fa25cef20905a7f9affb156dfa6f151ab",

pnpm-lock.yaml

Lines changed: 1 addition & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)