Split up commands and add them to domain modules

This commit is contained in:
Jon Staab
2026-06-16 16:34:43 -07:00
parent 163d2dc355
commit abb9f20747
21 changed files with 526 additions and 496 deletions
+21
View File
@@ -0,0 +1,21 @@
import {makeHttpAuth, sendManagementRequest} from "@welshman/util"
import type {ManagementRequest} from "@welshman/util"
import {User} from "./user.js"
import type {IClient} from "./client.js"
/**
* NIP-86 relay management. Signs an HTTP-auth event as the client's user and
* sends an admin request to a relay's management endpoint.
*/
export class RelayManagement {
constructor(readonly ctx: IClient) {}
post = async (url: string, request: ManagementRequest) => {
url = url.replace(/^ws/, "http")
const authTemplate = await makeHttpAuth(url, "POST", JSON.stringify(request))
const authEvent = await User.require(this.ctx).sign(authTemplate)
return sendManagementRequest(url, request, authEvent)
}
}