Askr documentation
Generated API snapshot

@askrjs/server/http

Exports from the declarations published in @askrjs/server. Signatures reflect the published artifact.

Exports

This entrypoint publishes 13 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.

createEventStreamtype

createEventStream: (options?: EventStreamOptions) => EventStream

Creates a Server-Sent Events stream backed by a text/event-stream Response, with bounded backpressure-aware writes, optional heartbeat comments, and automatic closing when options.signal aborts or close() is called.

EventStreamtype

EventStream: any

A live Server-Sent Events stream, backed by a streaming Response.

response
readonly response: Response;
closed
readonly closed: Promise<void>;
send
Queues an event in order. Await or otherwise handle the returned promise before producing without bound. Rejects with `QuotaExceededError` when the pending-write limit is full.
comment
Queues an SSE comment in order. Rejects with `QuotaExceededError` when the pending-write limit is full.
close
close(): Promise<void>;

EventStreamOptionstype

EventStreamOptions: any

Options for {@link createEventStream}.

signal
Aborting this signal closes the stream.
heartbeatInterval
If set, sends a `heartbeat` comment on this interval (in ms) to keep the connection alive.
highWaterMark
Backpressure threshold for the underlying `ReadableStream` and maximum number of unresolved `send()`/`comment()` calls admitted at once. Defaults to 16.
headers
headers?: HeadersInit;

jsontype

json: (value: JsonValue, init?: ResponseInit) => Response

Builds a 200 OK-shaped JSON response, serializing value and setting the JSON content type.

problemtype

problem: (status: number, detail?: string, options?: ProblemOptions & { init?: ResponseInit; }) => Response

Builds an RFC 9457 application/problem+json response, defaulting type to about:blank and title to a standard reason phrase for the given status (falling back to "HTTP Error").

Problemtype

Problem: any

An RFC 9457 Problem Details object, as produced by {@link ServerContext.problem}.

type
type: string;
title
title: string;
status
status: number;
detail
detail?: string;
instance
instance?: string;

ProblemOptionstype

ProblemOptions: any

Optional fields used to customize a {@link Problem} response.

type
type?: string;
title
title?: string;
instance
instance?: string;
extensions
extensions?: Record<string, unknown>;

redirecttype

redirect: (location: string, status?: 301 | 302 | 303 | 307 | 308) => Response

Builds a redirect response with an empty body and a Location header. Defaults to 302 Found.

ServerSentEventtype

ServerSentEvent: any

A single Server-Sent Event; data is JSON-serialized unless already a string.

data
data?: unknown;
event
event?: string;
id
id?: string;
retry
retry?: number;

texttype

text: (value: string, init?: ResponseInit) => Response

Builds a plain-text response, setting the text/plain; charset=utf-8 content type.