logigate/server/plugins/storage.ts

12 lines
421 B
TypeScript
Raw Permalink Normal View History

// Mounts the crash-safe file storage for share links and accounts.
import { join, resolve } from 'node:path'
export default defineNitroPlugin(() => {
const root = resolve(process.cwd(), 'data')
const storage = useStorage()
for (const name of ['shares', 'users', 'sessions', 'accounts', 'puzzles', 'library']) {
storage.mount(name, safeFsDriver({ base: join(root, name) }))
}
void removeStaleTemp(root)
})