Skip to content

Commit b2584df

Browse files
authored
feat: add vercel runtime cache for API routes (#4)
1 parent d60b342 commit b2584df

3 files changed

Lines changed: 25 additions & 0 deletions

File tree

modules/cache.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { defineNuxtModule } from 'nuxt/kit'
2+
import { provider } from 'std-env'
3+
4+
export default defineNuxtModule({
5+
meta: {
6+
name: 'vercel-cache',
7+
},
8+
setup(_, nuxt) {
9+
if (provider !== 'vercel') {
10+
return
11+
}
12+
13+
nuxt.hook('nitro:config', (nitroConfig) => {
14+
nitroConfig.storage = nitroConfig.storage || {}
15+
nitroConfig.storage.cache = {
16+
driver: 'vercel-runtime-cache',
17+
...nitroConfig.storage.cache,
18+
}
19+
})
20+
},
21+
})

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"marked": "^17.0.1",
6464
"playwright-core": "^1.57.0",
6565
"simple-git-hooks": "2.13.1",
66+
"std-env": "^3.10.0",
6667
"typescript": "5.9.3",
6768
"unocss": "^66.6.0",
6869
"vitest": "^4.0.18",

pnpm-lock.yaml

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

0 commit comments

Comments
 (0)