Skip to content

Commit

Permalink
feat(katzencore): Storage Management improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
maxlkatze committed Jul 22, 2024
1 parent e2eeadf commit b505150
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/runtime/server/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { defineEventHandler, readBody, useRuntimeConfig } from '#imports'
export default defineEventHandler(async (event) => {
const runtimeConfig = useRuntimeConfig()
const storage = await useContentStorage(runtimeConfig)
let savedContent = await storage.getItem(runtimeConfig.storageKey)

const body = await readBody(event) || {}
const token = body.token || ''
Expand Down Expand Up @@ -35,6 +34,7 @@ export default defineEventHandler(async (event) => {
},
}
}
let savedContent = await storage.getItem(runtimeConfig.storageKey)
// add or replace content inside content
// merge data with content
savedContent = { ...savedContent as object, ...content }
Expand Down Expand Up @@ -69,6 +69,7 @@ export default defineEventHandler(async (event) => {
},
}
}
const savedContent = await storage.getItem(runtimeConfig.storageKey)

return {
success: true,
Expand Down
1 change: 1 addition & 0 deletions src/runtime/storage/StorageManagment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const useContentStorage = async (runtimeConfig: RuntimeConfig): Promise<S
driver = (await import(`unstorage/drivers/${runtimeConfig.storage.type}`)).default(JSON.parse(JSON.stringify(runtimeConfig.storage.options)))
}
catch (e) {
console.error(e)
throw new Error(`Driver ${runtimeConfig.storage.type} not found`)
}
}
Expand Down

0 comments on commit b505150

Please sign in to comment.