ServerApiHost

tcmts.cli.web.ServerApiHost · #ec24wz6z · type

import type { Fn } from "#codebase/tcmts/cli/web";

export interface ServerApiHost {
  startWorker: (opts: {
    dataDir: string;
    load: (hash: string) => Promise<Fn>;
    log: (line: string) => void;
  }) => () => void;
  setSchedules: (opts: {
    dataDir: string;
    jobs: { name: string; spec: string; fn: Fn; hash: string }[];
    log?: (line: string) => void;
  }) => void;
  withCall: <T>(
    call: {
      method: string;
      url: string;
      headers: Record<string, string | string[] | undefined>;
      ip: string | undefined;
      signal: AbortSignal;
    },
    opts: { secure: boolean; dataDir?: string; cookiePath?: string },
    fn: () => Promise<T>,
  ) => Promise<
    | { ok: true; value: T; setCookies: string[] }
    | { ok: false; error: unknown; setCookies: string[] }
  >;
  pendingCookies: () => string[];
}

uses

used by