@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.
clearCookietype
clearCookie: (response: Response, name: string, options?: CookieOptions) => ResponseReturns a clone of response with a Set-Cookie header that expires and clears name.
CookieOptionstype
CookieOptions: anyOptions controlling how a cookie is set via {@link ServerContext.setCookie}.
Do not derive domain or path from untrusted input; invalid attribute characters are rejected.
domain- ASCII cookie domain without whitespace or attribute delimiters.
expires- expires?: Date;
httpOnly- httpOnly?: boolean;
maxAge- maxAge?: number;
path- Cookie path without control characters or the `;` attribute delimiter.
sameSite- sameSite?: CookieSameSite;
secure- secure?: boolean;
createEventStreamtype
createEventStream: (options?: EventStreamOptions) => EventStreamCreates 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: anyA 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: anyOptions 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) => ResponseBuilds a 200 OK-shaped JSON response, serializing value and setting the JSON content type.
problemtype
problem: (status: number, detail?: string, options?: ProblemOptions & { init?: ResponseInit; }) => ResponseBuilds 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: anyAn 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: anyOptional 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) => ResponseBuilds a redirect response with an empty body and a Location header. Defaults to 302 Found.
ServerSentEventtype
ServerSentEvent: anyA single Server-Sent Event; data is JSON-serialized unless already a string.
data- data?: unknown;
event- event?: string;
id- id?: string;
retry- retry?: number;
setCookietype
setCookie: (response: Response, name: string, value: string, options?: CookieOptions) => ResponseReturns a clone of response with an additional Set-Cookie header appended, serialized
from name, value, and options.
texttype
text: (value: string, init?: ResponseInit) => ResponseBuilds a plain-text response, setting the text/plain; charset=utf-8 content type.