Implement standalone control server

This commit is contained in:
Max Goodhart
2025-06-14 06:46:27 +00:00
parent ec6b7bd360
commit 9ded048667
29 changed files with 3414 additions and 415 deletions

View File

@@ -0,0 +1,31 @@
import type { Low } from 'lowdb'
import { JSONFilePreset } from 'lowdb/node'
import process from 'node:process'
import type { AuthToken } from './auth.ts'
export interface StoredData {
auth: {
salt: string | null
tokens: AuthToken[]
}
streamwallToken: null | {
tokenId: string
secret: string
}
}
const defaultData: StoredData = {
auth: {
salt: null,
tokens: [],
},
streamwallToken: null,
}
export type StorageDB = Low<StoredData>
export async function loadStorage() {
const dbPath = process.env.DB_PATH || 'storage.json'
const db = await JSONFilePreset<StoredData>(dbPath, defaultData)
return db
}