yolk/modules/tauri/runtime/storage.ts
2025-08-08 21:54:57 +02:00

36 lines
748 B
TypeScript

import { Store } from 'tauri-plugin-store-api'
import { createStorage } from 'unstorage'
const store = new Store('.servers.dat')
/**
* TODO: Use redis as storage
* - docs: https://unstorage.unjs.io/drivers/redis
* - then we can probably remove need for `/elk/data` (see docker-compose)
*/
const storage = createStorage()
storage.mount('servers', {
getKeys() {
return store.keys()
},
async removeItem(key: string) {
await store.delete(key)
},
clear() {
return store.clear()
},
hasItem(key: string) {
return store.has(key)
},
setItem(key: string, value: any) {
return store.set(key, value)
},
getItem(key: string) {
return store.get(key)
},
})
export function useStorage() {
return storage
}