We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
nuxt
Learn more about funding links in repositories.
Report abuse
close
1 parent 9c86298 commit ec7105aCopy full SHA for ec7105a
src/runtime/server/plugins/refresh-cache.ts
@@ -4,12 +4,15 @@ import type { WatchEvent } from 'unstorage';
4
// @ts-expect-error
5
import { useStorage } from '#imports'
6
7
-export default defineNitroPlugin(() => {
+export default defineNitroPlugin(async (nitro) => {
8
const storage = useStorage()
9
10
- storage.watch(async (event: WatchEvent, key: string) => {
+ const unwatch = await storage.watch(async (event: WatchEvent, key: string) => {
11
if (key.startsWith('content:source')) {
12
cleanCachedContents();
13
}
14
});
15
+ nitro.hooks.hook('close', async () => {
16
+ typeof unwatch === 'function' && await unwatch()
17
+ })
18
})
0 commit comments