Skip to content

Commit

Permalink
fix: prevent import cache in development
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 13, 2024
1 parent e098115 commit 8ea4de1
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/runtime/presets/node/database-handler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
import { eventHandler, getRouterParam } from 'h3'
import { useStorage } from 'nitropack/runtime'

export default eventHandler(async (event) => {
const collection = getRouterParam(event, 'collection')!

const data = await useStorage().getItem(`build:content:database.compressed.mjs`) || ''
if (data) {
const lineStart = `export const ${collection} = "`
const content = String(data).split('\n').find(line => line.startsWith(lineStart))
if (content) {
return content
.substring(lineStart.length, content.length - 1)
}
}

return await import('#content/dump').then(m => m[collection])
})

0 comments on commit 8ea4de1

Please sign in to comment.