docs: update portal for WRNexusJS 0.8.0
This commit is contained in:
+225
-12
@@ -10,11 +10,11 @@ page wrnexuscore {
|
||||
<header class="topbar">
|
||||
<a class="brand" href="/"><span>W</span> WRNexusJS</a>
|
||||
<nav aria-label="Primary"><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a></nav>
|
||||
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.7.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
|
||||
<div class="topbar-actions"><a class="preview-pill" href="/access">Private preview · v0.8.0</a><button data-wire-theme-toggle class="theme-button" aria-label="Toggle color theme" title="Toggle color theme">◐</button></div>
|
||||
</header>
|
||||
<div class="mobile-doc-nav"><details><summary>Browse documentation</summary><nav><a href="/getting-started">Get started</a><a href="/packages">Packages</a><a href="https://component.wrnexusjs.dev/">Components</a><a href="/language">Language</a><a href="/architecture">Architecture</a><a href="/tutorial">Tutorial</a><a href="/guides/project-structure">Guides</a><a href="/examples">Examples</a><a href="/search">Search</a></nav></details></div>
|
||||
<main class="portal-main docs-layout">
|
||||
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/core</span></nav><section class="doc-intro"><span class="eyebrow">Core · Package reference</span><h1>@wrnexus/core</h1><p>Contexts, middleware, security, sessions, caching, JSX, and realtime.</p><div class="doc-meta"><span>v0.7.0</span><span>Private registry</span><span>Core</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/core@0.7.0</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><blockquote>The framework core: the request <code>Context</code>, middleware contract, and the security, session, caching, streaming, realtime, and JSX primitives every other WRNexusJS package builds on.</blockquote>
|
||||
<article id="main" class="documentation prose standalone package-document"><nav class="breadcrumbs" aria-label="Breadcrumb"><a href="/">Home</a><span>/</span><a href="/packages">Packages</a><span>/</span><span aria-current="page">@wrnexus/core</span></nav><section class="doc-intro"><span class="eyebrow">Core · Package reference</span><h1>@wrnexus/core</h1><p>Contexts, middleware, security, sessions, caching, JSX, and realtime.</p><div class="doc-meta"><span>v0.8.0</span><span>Private registry</span><span>Core</span></div><section id="access" class="access-callout"><h2>Install the package</h2><p>After WorkRoot approves private registry access, install the release-aligned package:</p><pre><code>bun add @wrnexus/core@0.8.0</code><button type="button" class="copy-button" aria-label="Copy installation command">Copy</button></pre><p><a href="/access">Request preview access</a>. Never put registry tokens in source control.</p></section></section><section id="guide"><blockquote>The framework core: the request <code>Context</code>, middleware contract, and the security, session, caching, streaming, realtime, and JSX primitives every other WRNexusJS package builds on.</blockquote>
|
||||
<p>Part of the <strong>WRNexusJS</strong> framework — an SSR-first, Bun-native full-stack web framework.</p>
|
||||
<h3 id="overview">Overview</h3>
|
||||
<p><code>@wrnexus/core</code> is the shared foundation of WRNexusJS. It defines the <code>Context</code> object that flows through every middleware, page, and API route, plus the <code>Middleware</code>/<code>Next</code> contract they implement. On top of that it ships the building blocks a real app needs: cookie-backed sessions, password auth, CSRF protection, rate limiting, request logging, HTTP + in-memory caching, file uploads, streaming/SSE responses, WebSocket "rooms", security headers/CORS, and a server-side JSX runtime that renders to HTML strings. Everything here is <strong>server-side</strong> and Bun-native (it uses <code>Bun.password</code>, <code>Bun.write</code>, the web-standard <code>Request</code>/<code>Response</code>, and <code>crypto</code>). You depend on it directly and transitively through the rest of the framework.</p>
|
||||
@@ -57,6 +57,23 @@ page wrnexuscore {
|
||||
<thead><tr><th>Export</th><th>Signature</th><th>Notes</th></tr></thead>
|
||||
<tbody><tr><td><code>requestLogger(options?)</code></td><td><code>(RequestLoggerOptions?) => Middleware</code></td><td>One record per request with a request id (stored on <code>ctx.locals[requestIdKey]</code>).</td></tr></tbody></table></div>
|
||||
<p><code>RequestLoggerOptions</code>: <code>format</code> (<code>"pretty"</code> default \| <code>"json"</code>), <code>sink(line, record)</code> (default <code>console.log</code>), <code>requestIdKey</code> (default <code>"requestId"</code>), <code>now</code>. <code>RequestRecord</code> = <code>{ time, id, method, path, status, durationMs }</code>.</p>
|
||||
<h4 id="resilience-wrnexus-core">Resilience — <code>@wrnexus/core</code></h4>
|
||||
<p><code>resilientCall</code> standardizes cancellation-aware timeouts, controlled retries, fixed or exponential backoff, fallback responses, circuit breaking, and bounded concurrency. Reuse a declarative circuit/bulkhead options object, or an explicit <code>CircuitBreaker</code>/<code>Bulkhead</code> instance, wherever calls must share health and capacity state.</p>
|
||||
<pre data-language="ts"><code>import { resilientCall } from "@wrnexus/core";
|
||||
|
||||
const paymentCircuit = { failures: 5, resetAfter: "30s" } as const;
|
||||
|
||||
const status = await resilientCall({
|
||||
timeout: "5s",
|
||||
retries: 3,
|
||||
retryDelay: "100ms",
|
||||
backoff: "exponential",
|
||||
circuitBreaker: paymentCircuit,
|
||||
bulkhead: { concurrency: 20, queue: 100 },
|
||||
run: (signal) => paymentProvider.checkStatus({ signal }),
|
||||
fallback: () => ({ state: "unavailable" }),
|
||||
});</code></pre>
|
||||
<p><code>CircuitBreaker.snapshot()</code> reports <code>closed</code>, <code>open</code>, or <code>half-open</code>, failure and success counts, and the remaining retry delay for health endpoints and development tooling. Fail-fast conditions use stable <code>WRN-RESILIENCE-*</code> codes. Core's existing <code>HealthRegistry</code>, <code>withIdempotency</code>, and pluggable stores/locks cover health reporting, idempotent requests, and distributed coordination.</p>
|
||||
<h4 id="caching-wrnexus-core">Caching — <code>@wrnexus/core</code></h4>
|
||||
<div class="table-wrap"><table>
|
||||
<thead><tr><th>Export</th><th>Kind</th><th>Notes</th></tr></thead>
|
||||
@@ -217,6 +234,36 @@ interface Tenant {
|
||||
name?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
interface TenantResource {
|
||||
tenantId: string;
|
||||
}
|
||||
interface TenantMembership {
|
||||
tenantId: string;
|
||||
userId: string;
|
||||
roles?: string[];
|
||||
workspaceIds?: string[];
|
||||
}
|
||||
interface TenantAuditEvent {
|
||||
tenantId: string;
|
||||
action: string;
|
||||
actorId?: string;
|
||||
resource?: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
createdAt: number;
|
||||
}
|
||||
interface TenantQuota {
|
||||
tenantId: string;
|
||||
resource: string;
|
||||
limit: number;
|
||||
usage: number;
|
||||
}
|
||||
interface TenantDirectoryStore {
|
||||
putMembership(value: TenantMembership): Promise<void>;
|
||||
getMembership(tenantId: string, userId: string): Promise<TenantMembership | null>;
|
||||
listMemberships(tenantId: string): Promise<TenantMembership[]>;
|
||||
putQuota(value: TenantQuota): Promise<void>;
|
||||
getQuota(tenantId: string, resource: string): Promise<TenantQuota | null>;
|
||||
}
|
||||
type TenantResolver = (ctx: Context) => Tenant | null | Promise<Tenant | null>;
|
||||
interface TenantMiddlewareOptions {
|
||||
required?: boolean;
|
||||
@@ -224,11 +271,68 @@ interface TenantMiddlewareOptions {
|
||||
}
|
||||
declare function tenantMiddleware(resolveTenant: TenantResolver, options?: TenantMiddlewareOptions): Middleware;
|
||||
declare function tenantFromSubdomain(lookup: (slug: string, ctx: Context) => Tenant | null | Promise<Tenant | null>, rootDomains?: string[]): TenantResolver;
|
||||
declare function tenantFromDomain(lookup: (domain: string, ctx: Context) => Tenant | null | Promise<Tenant | null>): TenantResolver;
|
||||
declare function tenantFromPath(lookup: (slug: string, ctx: Context) => Tenant | null | Promise<Tenant | null>, prefix?: string): TenantResolver;
|
||||
/** Header resolution is intentionally opt-in and must only be used behind a trusted proxy. */
|
||||
declare function tenantFromHeader(lookup: (id: string, ctx: Context) => Tenant | null | Promise<Tenant | null>, header?: string): TenantResolver;
|
||||
declare function tenantFromSession(resolveId: (ctx: Context) => string | null | Promise<string | null>, lookup: (id: string, ctx: Context) => Tenant | null | Promise<Tenant | null>): TenantResolver;
|
||||
declare function composeTenantResolvers(...resolvers: TenantResolver[]): TenantResolver;
|
||||
declare function requireTenant(ctx: Context): Tenant;
|
||||
/** Wrap a repository so every operation receives the current tenant id. */
|
||||
declare function tenantScope<T extends object>(tenant: Tenant, repository: T): T & {
|
||||
tenantId: string;
|
||||
};
|
||||
declare function assertTenantAccess(tenant: Tenant, resource: TenantResource): void;
|
||||
declare function tenantKey(tenant: Tenant | string, ...parts: Array<string | number>): string;
|
||||
declare function createTenantDirectory(options?: {
|
||||
audit?: (event: TenantAuditEvent) => void | Promise<void>;
|
||||
now?: () => number;
|
||||
}): {
|
||||
addMembership(membership: TenantMembership, actorId?: string): Promise<void>;
|
||||
membership(tenantId: string, userId: string): TenantMembership | null;
|
||||
switchWorkspace(tenantId: string, userId: string, workspaceId: string): Promise<{
|
||||
tenantId: string;
|
||||
workspaceId: string;
|
||||
}>;
|
||||
setQuota(tenantId: string, resource: string, limit: number): void;
|
||||
enforceQuota(tenantId: string, resource: string, usage: number, requested?: number): {
|
||||
usage: number;
|
||||
requested: number;
|
||||
limit: number | undefined;
|
||||
};
|
||||
};
|
||||
declare function memoryTenantDirectoryStore(): TenantDirectoryStore;
|
||||
declare function createPersistentTenantDirectory(store: TenantDirectoryStore, options?: {
|
||||
audit?: (event: TenantAuditEvent) => void | Promise<void>;
|
||||
now?: () => number;
|
||||
}): {
|
||||
addMembership(membership: TenantMembership, actorId?: string): Promise<void>;
|
||||
membership: (tenantId: string, userId: string) => Promise<TenantMembership | null>;
|
||||
memberships: (tenantId: string) => Promise<TenantMembership[]>;
|
||||
switchWorkspace(tenantId: string, userId: string, workspaceId: string): Promise<{
|
||||
tenantId: string;
|
||||
workspaceId: string;
|
||||
}>;
|
||||
setQuota(tenantId: string, resource: string, limit: number, usage?: number): Promise<void>;
|
||||
consumeQuota(tenantId: string, resource: string, requested: number): Promise<TenantQuota | null>;
|
||||
};
|
||||
interface TenantSqlClient {
|
||||
query<T = Record<string, unknown>>(sql: string, parameters?: unknown[]): Promise<{
|
||||
rows: T[];
|
||||
}>;
|
||||
}
|
||||
declare function postgresTenantDirectoryStore(db: TenantSqlClient): TenantDirectoryStore;
|
||||
declare const POSTGRES_TENANT_DIRECTORY_SCHEMA = "CREATE TABLE IF NOT EXISTS wrnexus_tenant_memberships (tenant_id text NOT NULL,user_id text NOT NULL,roles jsonb NOT NULL DEFAULT '[]',workspace_ids jsonb NOT NULL DEFAULT '[]',PRIMARY KEY (tenant_id,user_id)); CREATE TABLE IF NOT EXISTS wrnexus_tenant_quotas (tenant_id text NOT NULL,resource text NOT NULL,quota_limit bigint NOT NULL,usage bigint NOT NULL DEFAULT 0,PRIMARY KEY (tenant_id,resource));";
|
||||
declare function migrateTenants<T extends Tenant>(tenants: T[], migrate: (tenant: T) => void | Promise<void>, options?: {
|
||||
concurrency?: number;
|
||||
continueOnError?: boolean;
|
||||
}): Promise<{
|
||||
migrated: string[];
|
||||
failed: {
|
||||
tenantId: string;
|
||||
error: string;
|
||||
}[];
|
||||
}>;
|
||||
|
||||
interface SpanRecord {
|
||||
name: string;
|
||||
@@ -432,6 +536,47 @@ declare function createContext(req: Request, url: URL): Context;
|
||||
/** Apply headers accumulated on the context, such as Set-Cookie. */
|
||||
declare function withContextHeaders(ctx: Context, res: Response): Response;
|
||||
|
||||
type ExecutionKind = "http" | "api" | "action" | "loader" | "middleware" | "realtime" | "queue" | "cron" | "webhook";
|
||||
interface ResponseContext {
|
||||
status: number;
|
||||
headers: Headers;
|
||||
setStatus(status: number): void;
|
||||
}
|
||||
interface ExecutionContext {
|
||||
kind: ExecutionKind;
|
||||
id: string;
|
||||
request: Request;
|
||||
response: ResponseContext;
|
||||
user: unknown | null;
|
||||
session: unknown | null;
|
||||
tenant: Tenant | null;
|
||||
locale: string;
|
||||
timezone: string;
|
||||
db?: unknown;
|
||||
cache?: unknown;
|
||||
logger?: unknown;
|
||||
trace?: Tracer;
|
||||
signal: AbortSignal;
|
||||
deadline: Date | null;
|
||||
metadata: Record<string, unknown>;
|
||||
authorize(permission: string): void | Promise<void>;
|
||||
}
|
||||
interface ExecutionContextInput extends Partial<Omit<ExecutionContext, "kind" | "id" | "request" | "response" | "signal" | "deadline" | "metadata" | "authorize">> {
|
||||
kind: ExecutionKind;
|
||||
id?: string;
|
||||
request?: Request;
|
||||
response?: Partial<Pick<ResponseContext, "status">> & {
|
||||
headers?: HeadersInit;
|
||||
};
|
||||
signal?: AbortSignal;
|
||||
deadline?: Date | number | null;
|
||||
timeoutMs?: number;
|
||||
metadata?: Record<string, unknown>;
|
||||
authorize?: (permission: string) => void | Promise<void>;
|
||||
}
|
||||
declare function createExecutionContext(input: ExecutionContextInput): ExecutionContext;
|
||||
declare function executionContextFromHttp(context: Context, kind?: Extract<ExecutionKind, "http" | "api" | "action" | "loader" | "middleware" | "webhook">, input?: Omit<ExecutionContextInput, "kind" | "request" | "user" | "tenant" | "locale" | "trace">): ExecutionContext;
|
||||
|
||||
/**
|
||||
* Small, dependency-free security helpers shared across packages.
|
||||
*/
|
||||
@@ -861,7 +1006,7 @@ interface RealtimeSecurityOptions {
|
||||
/** Called when a connection is rejected or closed for a policy violation. */
|
||||
onViolation?(reason: string, client?: RoomClient): void;
|
||||
}
|
||||
interface RoomHandlers<TData = Record<string, unknown>> {
|
||||
interface RoomHandlers<TData = Record<string, unknown>, TMessage = any> {
|
||||
/** Per-room abuse and payload controls. */
|
||||
security?: RealtimeSecurityOptions;
|
||||
/**
|
||||
@@ -872,16 +1017,16 @@ interface RoomHandlers<TData = Record<string, unknown>> {
|
||||
/** A client connected (a new tab joined the room). */
|
||||
onConnect?(client: RoomClient<TData>): void | Promise<void>;
|
||||
/** A message arrived (JSON is parsed; non-JSON arrives as a string). */
|
||||
onMessage?(client: RoomClient<TData>, message: any): void | Promise<void>;
|
||||
onMessage?(client: RoomClient<TData>, message: TMessage): void | Promise<void>;
|
||||
/** A client disconnected. */
|
||||
onLeave?(client: RoomClient<TData>): void | Promise<void>;
|
||||
}
|
||||
interface RoomDefinition<TData = Record<string, unknown>> {
|
||||
interface RoomDefinition<TData = Record<string, unknown>, TMessage = any> {
|
||||
readonly __wrnexusRoom: true;
|
||||
readonly handlers: RoomHandlers<TData>;
|
||||
readonly handlers: RoomHandlers<TData, TMessage>;
|
||||
}
|
||||
/** Define a realtime room. Export the result as the `default` of a realtime file. */
|
||||
declare function defineRoom<TData = Record<string, unknown>>(handlers: RoomHandlers<TData>): RoomDefinition<TData>;
|
||||
declare function defineRoom<TData = Record<string, unknown>, TMessage = any>(handlers: RoomHandlers<TData, TMessage>): RoomDefinition<TData, TMessage>;
|
||||
declare function isRoomDefinition(value: unknown): value is RoomDefinition;
|
||||
interface RealtimeConnectMeta {
|
||||
room: string;
|
||||
@@ -1085,6 +1230,11 @@ declare function withSecurityHeaders(req: Request, res: Response, mode: Mode, se
|
||||
interface SchemaLike<T> {
|
||||
parse(input: unknown): T;
|
||||
}
|
||||
interface OutputSchemaLike<T> {
|
||||
readonly __output: T;
|
||||
parse(input: unknown): unknown;
|
||||
}
|
||||
type InferEndpointSchema<TSchema> = TSchema extends OutputSchemaLike<infer TValue> ? TValue : never;
|
||||
interface EndpointErrorBody {
|
||||
code: string;
|
||||
message: string;
|
||||
@@ -1097,8 +1247,8 @@ declare class EndpointError extends Error {
|
||||
constructor(status: number, code: string, message: string, details?: unknown | undefined);
|
||||
}
|
||||
interface EndpointDefinition<I, O> {
|
||||
input?: SchemaLike<I>;
|
||||
output?: SchemaLike<O>;
|
||||
input?: SchemaLike<I> | OutputSchemaLike<I>;
|
||||
output?: SchemaLike<O> | OutputSchemaLike<O>;
|
||||
auth?: "optional" | "required";
|
||||
description?: string;
|
||||
tags?: string[];
|
||||
@@ -1109,6 +1259,10 @@ interface DefinedEndpoint<I, O> {
|
||||
(ctx: Context, input?: unknown): Promise<Response>;
|
||||
}
|
||||
/** Define a validated, typed endpoint that can also drive SDK/OpenAPI generation. */
|
||||
declare function defineEndpoint<InputSchema extends OutputSchemaLike<unknown>, OutputSchema extends OutputSchemaLike<unknown>>(definition: Omit<EndpointDefinition<InferEndpointSchema<InputSchema>, InferEndpointSchema<OutputSchema>>, "input" | "output"> & {
|
||||
input: InputSchema;
|
||||
output: OutputSchema;
|
||||
}): DefinedEndpoint<InferEndpointSchema<InputSchema>, InferEndpointSchema<OutputSchema>>;
|
||||
declare function defineEndpoint<I = unknown, O = unknown>(definition: EndpointDefinition<I, O>): DefinedEndpoint<I, O>;
|
||||
interface RpcClientOptions {
|
||||
baseUrl?: string;
|
||||
@@ -1199,6 +1353,65 @@ interface BudgetViolation {
|
||||
declare const recommendedWebBudgets: Readonly<PerformanceBudgets>;
|
||||
declare function checkPerformanceBudgets(budgets: PerformanceBudgets, measurement: PerformanceMeasurement): BudgetViolation[];
|
||||
|
||||
type Duration = number | `${number}${"ms" | "s" | "m" | "h"}`;
|
||||
type BackoffStrategy = "fixed" | "exponential" | ((attempt: number) => Duration);
|
||||
interface CircuitBreakerOptions {
|
||||
failures: number;
|
||||
resetAfter: Duration;
|
||||
successesToClose?: number;
|
||||
}
|
||||
interface CircuitBreakerSnapshot {
|
||||
state: "closed" | "open" | "half-open";
|
||||
failures: number;
|
||||
successes: number;
|
||||
retryAfterMs: number;
|
||||
}
|
||||
declare class ResilienceError extends Error {
|
||||
readonly code: "WRN-RESILIENCE-TIMEOUT" | "WRN-RESILIENCE-ABORTED" | "WRN-RESILIENCE-CIRCUIT-OPEN" | "WRN-RESILIENCE-BULKHEAD-FULL";
|
||||
constructor(code: "WRN-RESILIENCE-TIMEOUT" | "WRN-RESILIENCE-ABORTED" | "WRN-RESILIENCE-CIRCUIT-OPEN" | "WRN-RESILIENCE-BULKHEAD-FULL", message: string, options?: ErrorOptions);
|
||||
}
|
||||
declare function durationMs(value: Duration): number;
|
||||
declare class CircuitBreaker {
|
||||
private readonly options;
|
||||
private failures;
|
||||
private successes;
|
||||
private openedAt;
|
||||
private probing;
|
||||
constructor(options: CircuitBreakerOptions);
|
||||
snapshot(now?: number): CircuitBreakerSnapshot;
|
||||
execute<T>(operation: () => Promise<T>): Promise<T>;
|
||||
}
|
||||
interface BulkheadOptions {
|
||||
concurrency: number;
|
||||
queue?: number;
|
||||
}
|
||||
declare class Bulkhead {
|
||||
private readonly options;
|
||||
private active;
|
||||
private readonly waiting;
|
||||
constructor(options: BulkheadOptions);
|
||||
get snapshot(): Readonly<{
|
||||
active: number;
|
||||
queued: number;
|
||||
capacity: number;
|
||||
}>;
|
||||
execute<T>(operation: () => Promise<T>): Promise<T>;
|
||||
}
|
||||
interface ResilientCallOptions<T> {
|
||||
run: (signal: AbortSignal, attempt: number) => Promise<T>;
|
||||
timeout?: Duration;
|
||||
retries?: number;
|
||||
retryDelay?: Duration;
|
||||
backoff?: BackoffStrategy;
|
||||
circuitBreaker?: CircuitBreaker | CircuitBreakerOptions;
|
||||
bulkhead?: Bulkhead | BulkheadOptions;
|
||||
signal?: AbortSignal;
|
||||
retryWhen?: (error: unknown, attempt: number) => boolean | Promise<boolean>;
|
||||
fallback?: (error: unknown, signal: AbortSignal) => T | Promise<T>;
|
||||
onRetry?: (error: unknown, attempt: number, delayMs: number) => void;
|
||||
}
|
||||
declare function resilientCall<T>(options: ResilientCallOptions<T>): Promise<T>;
|
||||
|
||||
interface ProblemDetails {
|
||||
type: string;
|
||||
title: string;
|
||||
@@ -1273,7 +1486,7 @@ declare function withIdempotency<T>(store: IdempotencyStore<T>, key:
|
||||
replayed: boolean;
|
||||
}>;
|
||||
|
||||
export { type ActionDefinition, ApplicationLifecycle, type AsyncSessionBackend, type Bucket, type BudgetViolation, CSRF_COOKIE, CSRF_HEADER, type CacheControlOptions, type CachePolicy, type ContentSecurityPolicyConfig, type Context, type CookieOptions, type CookieStore, type CorsConfig, type CorsOrigin, type CspDirectiveValue, type CsrfProtectionOptions, type DefinedAction, type DefinedEndpoint, type DefinedLoader, type EndpointDefinition, EndpointError, type EndpointErrorBody, type FeatureFlags, type FeatureRule, type FeatureValue, type HealthCheck, type HealthCheckResult, HealthRegistry, type HstsConfig, type IdempotencyRecord, type IdempotencyStore, type LifecycleHandler, type LifecyclePhase, type LoaderDefinition, type LocalStorageSnapshot, type Middleware, type Mode, type Next, type PageComponent, type PageMeta, type PerformanceBudgets, type PerformanceMeasurement, type PermissionsPolicyConfig, type ProblemDetails, type ProblemDetailsInput, type RateLimitOptions, type RateLimitStore, type RawSocket, type RealtimeBridge, type RealtimeBus, type RealtimeConnectMeta, type RealtimeEnvelope, type RealtimeHandler, type RealtimeRegistry, type RealtimeRegistryOptions, type RealtimeSecurityOptions, type RealtimeSocket, type RequestLimitsConfig, type RequestLoggerOptions, type RequestRecord, type RequireAuthOptions, type Room, type RoomAuthInfo, type RoomClient, type RoomDefinition, type RoomHandlers, type RpcClientOptions, SESSION_USER_KEY, type SaveUploadOptions, type SavedUpload, type SchemaLike, type SecureUploadOptions, type SecurityConfig, type SeoConfig, type ServerSentEvent, ServiceContainer, type ServiceToken, type SessionBackend, type SessionEntry, type SessionPolicy, type SessionStore, type Span, type SpanRecord, type StreamResponseInit, type TFunction, TTLCache, type Target, type Tenant, type TenantMiddlewareOptions, type TenantResolver, type Tracer, type TrustedTypesConfig, UploadError, type UploadInspectionResult, type UploadInspector, type UploadScanner, bridgeRealtime, cacheControl, checkPerformanceBudgets, collectUploads, createContext, createCorsPreflightResponse, createRealtimeRegistry, createRpcClient, createTracer, csrfProtection, csrfToken, dedupe, defaultKey, defineAction, defineEndpoint, defineFeatureFlags, defineLoader, defineRoom, escapeHtml, etag, getUser, hashPassword, isRoomDefinition, isSafeIslandName, isSafeRequestPath, isWebSocketOriginAllowed, loadSession, logIn, logOut, memoryIdempotencyStore, notModified, peerKey, problem, proxyKey, randomUploadFilename, rateLimit, recommendedWebBudgets, renderDevError, renderError, renderNotFound, renderProdError, renderStatusPage, requestId, requestLogger, requireAuth, requireTenant, resolveRequestUrl, sanitizeFilename, saveUpload, saveUploadSecure, secureDownloadHeaders, serviceToken, sessionAuth, setSessionBackend, setSessionPolicy, sse, streamResponse, tenantFromSubdomain, tenantMiddleware, tenantScope, tracingMiddleware, verifyCsrf, verifyPassword, withCacheControl, withContextHeaders, withIdempotency, withSecurityHeaders, withSpan };
|
||||
export { type ActionDefinition, ApplicationLifecycle, type AsyncSessionBackend, type BackoffStrategy, type Bucket, type BudgetViolation, Bulkhead, type BulkheadOptions, CSRF_COOKIE, CSRF_HEADER, type CacheControlOptions, type CachePolicy, CircuitBreaker, type CircuitBreakerOptions, type CircuitBreakerSnapshot, type ContentSecurityPolicyConfig, type Context, type CookieOptions, type CookieStore, type CorsConfig, type CorsOrigin, type CspDirectiveValue, type CsrfProtectionOptions, type DefinedAction, type DefinedEndpoint, type DefinedLoader, type Duration, type EndpointDefinition, EndpointError, type EndpointErrorBody, type ExecutionContext, type ExecutionContextInput, type ExecutionKind, type FeatureFlags, type FeatureRule, type FeatureValue, type HealthCheck, type HealthCheckResult, HealthRegistry, type HstsConfig, type IdempotencyRecord, type IdempotencyStore, type InferEndpointSchema, type LifecycleHandler, type LifecyclePhase, type LoaderDefinition, type LocalStorageSnapshot, type Middleware, type Mode, type Next, type OutputSchemaLike, POSTGRES_TENANT_DIRECTORY_SCHEMA, type PageComponent, type PageMeta, type PerformanceBudgets, type PerformanceMeasurement, type PermissionsPolicyConfig, type ProblemDetails, type ProblemDetailsInput, type RateLimitOptions, type RateLimitStore, type RawSocket, type RealtimeBridge, type RealtimeBus, type RealtimeConnectMeta, type RealtimeEnvelope, type RealtimeHandler, type RealtimeRegistry, type RealtimeRegistryOptions, type RealtimeSecurityOptions, type RealtimeSocket, type RequestLimitsConfig, type RequestLoggerOptions, type RequestRecord, type RequireAuthOptions, ResilienceError, type ResilientCallOptions, type ResponseContext, type Room, type RoomAuthInfo, type RoomClient, type RoomDefinition, type RoomHandlers, type RpcClientOptions, SESSION_USER_KEY, type SaveUploadOptions, type SavedUpload, type SchemaLike, type SecureUploadOptions, type SecurityConfig, type SeoConfig, type ServerSentEvent, ServiceContainer, type ServiceToken, type SessionBackend, type SessionEntry, type SessionPolicy, type SessionStore, type Span, type SpanRecord, type StreamResponseInit, type TFunction, TTLCache, type Target, type Tenant, type TenantAuditEvent, type TenantDirectoryStore, type TenantMembership, type TenantMiddlewareOptions, type TenantQuota, type TenantResolver, type TenantResource, type TenantSqlClient, type Tracer, type TrustedTypesConfig, UploadError, type UploadInspectionResult, type UploadInspector, type UploadScanner, assertTenantAccess, bridgeRealtime, cacheControl, checkPerformanceBudgets, collectUploads, composeTenantResolvers, createContext, createCorsPreflightResponse, createExecutionContext, createPersistentTenantDirectory, createRealtimeRegistry, createRpcClient, createTenantDirectory, createTracer, csrfProtection, csrfToken, dedupe, defaultKey, defineAction, defineEndpoint, defineFeatureFlags, defineLoader, defineRoom, durationMs, escapeHtml, etag, executionContextFromHttp, getUser, hashPassword, isRoomDefinition, isSafeIslandName, isSafeRequestPath, isWebSocketOriginAllowed, loadSession, logIn, logOut, memoryIdempotencyStore, memoryTenantDirectoryStore, migrateTenants, notModified, peerKey, postgresTenantDirectoryStore, problem, proxyKey, randomUploadFilename, rateLimit, recommendedWebBudgets, renderDevError, renderError, renderNotFound, renderProdError, renderStatusPage, requestId, requestLogger, requireAuth, requireTenant, resilientCall, resolveRequestUrl, sanitizeFilename, saveUpload, saveUploadSecure, secureDownloadHeaders, serviceToken, sessionAuth, setSessionBackend, setSessionPolicy, sse, streamResponse, tenantFromDomain, tenantFromHeader, tenantFromPath, tenantFromSession, tenantFromSubdomain, tenantKey, tenantMiddleware, tenantScope, tracingMiddleware, verifyCsrf, verifyPassword, withCacheControl, withContextHeaders, withIdempotency, withSecurityHeaders, withSpan };
|
||||
</code></pre></section><section id="examples" class="examples"><h2>Examples</h2><p>Copy-ready examples from the installed package documentation.</p><div class="example-grid"><article class="example-card"><h3>A minimal middleware chain</h3><pre data-language="ts"><code>import {
|
||||
createContext,
|
||||
withContextHeaders,
|
||||
@@ -1335,9 +1548,9 @@ import { redisDriver } from "@wrnexus/pubsub/redis";
|
||||
|
||||
const registry = createRealtimeRegistry();
|
||||
bridgeRealtime(registry, createPubSub(redisDriver(process.env.REDIS_URL)));</code></pre></article></div></section></article>
|
||||
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-3" href="#overview">Overview</a><a class="toc-level-3" href="#api">API</a><a class="toc-level-4" href="#context-middleware-wrnexus-core">Context & middleware — @wrnexus/core</a><a class="toc-level-4" href="#authentication-wrnexus-core">Authentication — @wrnexus/core</a><a class="toc-level-4" href="#csrf-wrnexus-core">CSRF — @wrnexus/core</a><a class="toc-level-4" href="#rate-limiting-wrnexus-core">Rate limiting — @wrnexus/core</a><a class="toc-level-4" href="#request-logging-wrnexus-core">Request logging — @wrnexus/core</a><a class="toc-level-4" href="#caching-wrnexus-core">Caching — @wrnexus/core</a><a class="toc-level-4" href="#file-uploads-wrnexus-core">File uploads — @wrnexus/core</a><a class="toc-level-4" href="#streaming-sse-wrnexus-core">Streaming & SSE — @wrnexus/core</a><a class="toc-level-4" href="#realtime-rooms-wrnexus-core">Realtime rooms — @wrnexus/core</a><a class="toc-level-4" href="#error-pages-wrnexus-core">Error pages — @wrnexus/core</a><a class="toc-level-4" href="#security-headers-cors-wrnexus-core">Security headers & CORS — @wrnexus/core</a><a class="toc-level-4" href="#storage-cookies-sessions-localstorage-wrnexus-core">Storage: cookies, sessions, localStorage — @wrnexus/core</a><a class="toc-level-4" href="#low-level-security-helpers-wrnexus-core">Low-level security helpers — @wrnexus/core</a><a class="toc-level-4" href="#jsx-runtime-wrnexus-core-wrnexus-core-jsx-runtime-wrnexus-core-jsx-dev-runtime">JSX runtime — @wrnexus/core, @wrnexus/core/jsx-runtime, @wrnexus/core/jsx-dev-runtime</a><a class="toc-level-3" href="#usage">Usage</a><a class="toc-level-4" href="#a-minimal-middleware-chain">A minimal middleware chain</a><a class="toc-level-4" href="#password-auth">Password auth</a><a class="toc-level-4" href="#http-caching-with-etags">HTTP caching with ETags</a><a class="toc-level-4" href="#streaming-sse">Streaming SSE</a><a class="toc-level-4" href="#a-realtime-room">A realtime room</a><a class="toc-level-4" href="#jsx-rendering">JSX rendering</a><a class="toc-level-3" href="#requirements-notes">Requirements / Notes</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
|
||||
<aside class="on-this-page"><h2>On this page</h2><nav><a class="toc-level-2" href="#guide">Guide</a><a class="toc-level-3" href="#overview">Overview</a><a class="toc-level-3" href="#api">API</a><a class="toc-level-4" href="#context-middleware-wrnexus-core">Context & middleware — @wrnexus/core</a><a class="toc-level-4" href="#authentication-wrnexus-core">Authentication — @wrnexus/core</a><a class="toc-level-4" href="#csrf-wrnexus-core">CSRF — @wrnexus/core</a><a class="toc-level-4" href="#rate-limiting-wrnexus-core">Rate limiting — @wrnexus/core</a><a class="toc-level-4" href="#request-logging-wrnexus-core">Request logging — @wrnexus/core</a><a class="toc-level-4" href="#resilience-wrnexus-core">Resilience — @wrnexus/core</a><a class="toc-level-4" href="#caching-wrnexus-core">Caching — @wrnexus/core</a><a class="toc-level-4" href="#file-uploads-wrnexus-core">File uploads — @wrnexus/core</a><a class="toc-level-4" href="#streaming-sse-wrnexus-core">Streaming & SSE — @wrnexus/core</a><a class="toc-level-4" href="#realtime-rooms-wrnexus-core">Realtime rooms — @wrnexus/core</a><a class="toc-level-4" href="#error-pages-wrnexus-core">Error pages — @wrnexus/core</a><a class="toc-level-4" href="#security-headers-cors-wrnexus-core">Security headers & CORS — @wrnexus/core</a><a class="toc-level-4" href="#storage-cookies-sessions-localstorage-wrnexus-core">Storage: cookies, sessions, localStorage — @wrnexus/core</a><a class="toc-level-4" href="#low-level-security-helpers-wrnexus-core">Low-level security helpers — @wrnexus/core</a><a class="toc-level-4" href="#jsx-runtime-wrnexus-core-wrnexus-core-jsx-runtime-wrnexus-core-jsx-dev-runtime">JSX runtime — @wrnexus/core, @wrnexus/core/jsx-runtime, @wrnexus/core/jsx-dev-runtime</a><a class="toc-level-3" href="#usage">Usage</a><a class="toc-level-4" href="#a-minimal-middleware-chain">A minimal middleware chain</a><a class="toc-level-4" href="#password-auth">Password auth</a><a class="toc-level-4" href="#http-caching-with-etags">HTTP caching with ETags</a><a class="toc-level-4" href="#streaming-sse">Streaming SSE</a><a class="toc-level-4" href="#a-realtime-room">A realtime room</a><a class="toc-level-4" href="#jsx-rendering">JSX rendering</a><a class="toc-level-3" href="#requirements-notes">Requirements / Notes</a><a class="toc-level-2" href="#api">Complete API</a><a class="toc-level-2" href="#examples">Examples</a></nav></aside>
|
||||
</main>
|
||||
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.7.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
|
||||
<footer><div class="footer-brand"><span class="footer-mark" aria-hidden="true">W</span><p><strong>WRNexusJS 0.8.0</strong><span>Complete API documentation generated from installed package declarations.</span></p></div><nav aria-label="Footer"><a href="/packages">All packages</a><a href="/getting-started">Get started</a><a href="/security">Security</a><a href="/support">Support</a><a href="/llms.txt">AI guide</a></nav><p class="footer-meta">Private Developer Preview · Bun-native</p></footer>
|
||||
<BackToTop />
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user