feat(api): list servers

This commit is contained in:
Anthony Fu 2022-12-24 01:07:38 +01:00
parent 6c9908d030
commit 52a8ae47fe
3 changed files with 26 additions and 0 deletions

View file

@ -64,3 +64,16 @@ export async function getApp(server: string) {
return null
}
}
export async function listServers() {
const keys = await storage.getKeys()
const servers = new Set<string>()
for await (const key of keys) {
if (!key.startsWith('servers:'))
continue
const id = key.split(':').pop()!.replace(/\.json$/, '')
if (id)
servers.add(id)
}
return Array.from(servers).sort()
}