Skip to content
Français

serveTaskQueue

import { serveTaskQueue } from "@elie-laloum/outpost";

Serve a caller-owned TaskQueue over HTTP at POST /queue, authenticated by bearer tokens. Listens on 127.0.0.1 and a port chosen by the system by default, without TLS. Rejects a fixed token that is not 32 to 512 non-whitespace characters.

Complete example and detailed rules.

  • optionsRequired
    QueueServerOptions
    Queue to serve, accepted bearer tokens, and bind host and port.
  • options.queueRequired
    TaskQueue
    Queue served over HTTP; closing the server leaves it open.
  • options.tokenRequired
    string | (() => readonly string[] | Promise<readonly string[]>)
    Accepted bearer token of 32 to 512 non-whitespace characters, or a function returning the accepted tokens, called on every request. Return the old and new tokens together during a rotation; an empty list or a thrown error rejects every request.
  • options.hostOptional
    string | undefined
    Bind address, default 127.0.0.1.
  • options.portOptional
    number | undefined
    TCP port, default 0: the system picks a free port, shown in url.

Promise<QueueServer>

export declare function serveTaskQueue(
  options: QueueServerOptions,
): Promise<QueueServer>;