@askrjs/server/http
Exports from the declarations published in @askrjs/server. Signatures reflect the published artifact.
Exports
This entrypoint publishes 33 exports. Use the anchored symbol rows for direct links. Type-only exports are labeled separately from runtime values.
acceptedtype
accepted: (value?: JsonValue, init?: ResponseInit) => ResponseBuilds a `202 Accepted` response; JSON-serializes `value` if given, otherwise an empty body.
acceptstype
accepts: (value: string, expected: string) => booleanbadtype
bad: (detail?: string, init?: ResponseInit) => ResponseAlias for {@link badRequest}.
badRequesttype
badRequest: (detail?: string, init?: ResponseInit) => ResponseBuilds a `400 Bad Request` Problem Details response.
challengetype
challenge: (options?: ChallengeOptions) => ResponseBuilds a `401`/`407` Problem Details response with a `WWW-Authenticate` (or `Proxy-Authenticate` for `407`) challenge header.
clearCookietype
clearCookie: (response: Response, name: string, options?: CookieOptions) => ResponseReturns a clone of `response` with a `Set-Cookie` header that expires and clears `name`.
conflicttype
conflict: (detail?: string, init?: ResponseInit) => ResponseBuilds a `409 Conflict` Problem Details response.
contentTypetype
contentType: (value: string | null) => string | undefinedcreatedtype
created: (value?: JsonValue, init?: ResponseInit) => ResponseBuilds a `201 Created` response; JSON-serializes `value` if given, otherwise an empty body.
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.
errortype
error: (status?: number, detail?: string, init?: ResponseInit) => ResponseBuilds a Problem Details error response with a configurable status (default `500`).
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;
explicitlyAcceptstype
explicitlyAccepts: (value: string, expected: string) => booleanforbiddentype
forbidden: (detail?: string, init?: ResponseInit) => ResponseBuilds a `403 Forbidden` Problem Details response.
formatServerSentEventtype
formatServerSentEvent: (event: ServerSentEvent) => stringSerializes a {@link ServerSentEvent} to the `text/event-stream` wire format, escaping multi-line data/comment fields and validating that `event`/`id` contain no line breaks.
internalServerErrortype
internalServerError: (detail?: string, init?: ResponseInit) => ResponseBuilds a `500 Internal Server Error` Problem Details response.
jsontype
json: (value: JsonValue, init?: ResponseInit) => ResponseBuilds a `200 OK`-shaped JSON response, serializing `value` and setting the JSON content type.
methodNotAllowedtype
methodNotAllowed: (allow?: string | readonly string[], init?: ResponseInit) => ResponseBuilds a `405 Method Not Allowed` Problem Details response, setting the `Allow` header if given.
noContenttype
noContent: (init?: ResponseInit) => ResponseBuilds a `204 No Content` response with an empty body.
notFoundtype
notFound: (detail?: string, init?: ResponseInit) => ResponseBuilds a `404 Not Found` Problem Details response.
notImplementedtype
notImplemented: (detail?: string, init?: ResponseInit) => ResponseBuilds a `501 Not Implemented` Problem Details response.
oktype
ok: (value?: JsonValue, init?: ResponseInit) => ResponseBuilds a `200 OK` response; JSON-serializes `value` if given, otherwise an empty body.
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").
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`.
serverErrortype
serverError: (detail?: string, init?: ResponseInit) => ResponseAlias for {@link internalServerError}.
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;
serviceUnavailabletype
serviceUnavailable: (detail?: string, init?: ResponseInit) => ResponseBuilds a `503 Service Unavailable` Problem Details response.
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.
tooManyRequeststype
tooManyRequests: (detail?: string, init?: ResponseInit) => ResponseBuilds a `429 Too Many Requests` Problem Details response.
unauthorizedtype
unauthorized: (detail?: string, init?: ResponseInit) => ResponseBuilds a `401 Unauthorized` Problem Details response.
unprocessableEntitytype
unprocessableEntity: (detail?: string, init?: ResponseInit) => ResponseBuilds a `422 Unprocessable Entity` Problem Details response.