@prismshadow/penguin-library-machine · library/machine/src/machine-api.ts:29

MachineApi

interface

The machine's own API, reached through its tunnel as an authenticated caller.

API

@Interface("@prismshadow/penguin-server#MachineApi")
export abstract class MachineApi {
  abstract request(
      method: "GET" | "POST" | "PUT" | "PATCH",
      path: string,
      body?: unknown,
    ): Promise<MachineAnswer>;
  abstract postBytes(
      path: string,
      contentType: string,
      body: Buffer,
      timeoutMs: number,
      /** Request headers beyond the ones every call carries. */
      headers?: Record<string, string>,
    ): Promise<MachineAnswer>;
}

Members (2)

request

request(method: "GET" | "POST" | "PUT" | "PATCH", path: string, body?: unknown): Promise<MachineAnswer>
@parammethod"GET" | "POST" | "PUT" | "PATCH"
@parampathstring
@parambody?unknown
@returnsPromise<MachineAnswer>

postBytes

postBytes(path: string, contentType: string, body: Buffer, timeoutMs: number, headers?: Record<string, string>): Promise<MachineAnswer>

A POST whose body is bytes rather than JSON, with a deadline of its own. The hot update is megabytes, and the machine unpacks, boots and commits it before answering — a timeout sized for a settings write would call a working upgrade dead halfway through.

@parampathstring
@paramcontentTypestring
@parambodyBuffer
@paramtimeoutMsnumber
@paramheaders?Record<string, string>
@returnsPromise<MachineAnswer>