Text responses went out uncompressed unless a proxy sat in front of every
runtime. createApp({ compression: true | { threshold, encodings } }), off
by default, implements D13 strategy B as accepted on 2026-10-22.
- One function, compressOutcome, runs after handle() and before either
adapter writes, so Node and the fetch runtimes cannot diverge.
- Accept-Encoding negotiation with q-values, identity, * and q=0; ties go
to server preference (br before gzip). Vary: Accept-Encoding is merged
wherever the request decided the outcome, including every 304. Skips:
existing Content-Encoding or Content-Range, no or an incompressible
Content-Type (ndjson is compressible), Cache-Control: no-transform.
HEAD and bodies under threshold keep Vary; 204 gets none.
- Node, Deno, Bun: node:zlib only, loaded lazily through nodeRequire.
Buffered bodies use the async API, never the sync one; br at quality 4.
Content-Length is dropped from an encoded body.
- Streams (SSE, ndjson): a zlib stream flushed after every frame, error
frame and ping, piped into res on Node and wrapped around the
ReadableStream on fetch runtimes. Backpressure follows the compressor;
a client leaving destroys it.
- Edge: core never encodes and sets Vary only. Edge is recognised by
edgeHandler, which marks the app through an internal symbol, and by
createApp detecting workerd (navigator.userAgent, or node:zlib failing
to load), which covers a bare app.fetch export.
- ETags from CARD-15 are taken on the identity body and stay weak, so the
tag does not change with the coding.
Deno runs zlib's async API on the main thread; that is documented and
pinned by a test, not worked around.
Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
112 lines
3.6 KiB
TypeScript
112 lines
3.6 KiB
TypeScript
/**
|
|
* @green-tea/core — a decorator-driven, type-safe HTTP framework.
|
|
* Public API barrel: application bootstrap, routing/DI decorators, streaming,
|
|
* request validation, security helpers, and the cross-server mesh.
|
|
*/
|
|
import 'reflect-metadata';
|
|
|
|
/**
|
|
* Package version. Kept in step with `package.json` and `deno.json` by hand, and pinned to them by
|
|
* `test/package-metadata.test.ts`.
|
|
*
|
|
* It used to say it was "replaced at publish time", which nothing ever did — not `tsup`, not
|
|
* `stage.yml`, not `release.yml`, which only ever *reads* the version out of `package.json`. So the
|
|
* constant drifted two releases behind while the comment explained why it could not, and the only
|
|
* test touching it checked the CalVer shape, which a stale version satisfies perfectly.
|
|
*/
|
|
export const VERSION = '26.9.0-beta.2';
|
|
|
|
// Application
|
|
export { createApp } from './app';
|
|
export type { App, InspectLine, Explain, MeshConfig } from './app';
|
|
|
|
// Graph visualization
|
|
export { toMermaid, toDOT } from './graph-viz';
|
|
export type { GraphView } from './graph-viz';
|
|
export { buildOpenApi } from './openapi';
|
|
export type { OpenApiDoc, OpenApiInfo, OpenApiRoute } from './openapi';
|
|
|
|
// Views
|
|
export { render } from './views';
|
|
|
|
// Routing & decorators
|
|
export {
|
|
Provider,
|
|
Step,
|
|
Route,
|
|
Get,
|
|
Head,
|
|
Module,
|
|
Transformer,
|
|
Sse,
|
|
Ws,
|
|
Stream,
|
|
Post,
|
|
Put,
|
|
Patch,
|
|
Delete,
|
|
Options,
|
|
Html,
|
|
} from './metadata';
|
|
export type { Transport, HttpMethod, RouteDecorator, TransformerFn } from './metadata';
|
|
export type { Plugin, PluginApi, ScopeApi, ScopeNode } from './plugin';
|
|
export type { Hooks } from './app';
|
|
export type { TeardownFn } from './lifecycle';
|
|
|
|
// Transformers & error signals
|
|
export { JsonTransformer } from './transformers';
|
|
export type { ErrorRenderer, ErrorRequest, ErrorResponse } from './transformers';
|
|
export {
|
|
HttpError,
|
|
Unauthorized,
|
|
NotFound,
|
|
Redirect,
|
|
NotModified,
|
|
ValidationError,
|
|
TransportMismatchError,
|
|
HTTP_ERROR,
|
|
VALIDATION_ERROR,
|
|
isHttpError,
|
|
isValidationError,
|
|
} from './signals';
|
|
export type { HttpErrorLike } from './signals';
|
|
|
|
// Bus & flow
|
|
export { Bus } from './bus';
|
|
export type { LifecycleEvent, EventPayload, Correlation, Events } from './bus';
|
|
export { flow, Flow } from './flow';
|
|
export type { StepFn, CompiledFlow } from './flow';
|
|
|
|
// Parameter decorators
|
|
export { needs, ctx, param, query, body, headers, header, cookies, cookie, inbound, abort } from './params';
|
|
export type { Query, Headers, Context, ArgSpec, ArgDecorator } from './params';
|
|
|
|
// Cookies
|
|
export { setCookie, parseCookies } from './cookies';
|
|
export type { CookieOptions } from './cookies';
|
|
|
|
// Observability
|
|
export { createDefaultLogger, logRequests, withConsoleFallback } from './logger';
|
|
export type { Logger, LogLevel, LogFields } from './logger';
|
|
|
|
// Streaming
|
|
export { channel, isAsyncIterable } from './channel';
|
|
export type { Channel } from './channel';
|
|
export { Rooms } from './rooms';
|
|
export { sse, isSseEvent, sseEncoder, ndjsonEncoder } from './encoders';
|
|
export type { StreamEncoder, SseEvent, SseFields } from './encoders';
|
|
|
|
// HTTP, security & validation
|
|
export type { RequestLimits } from './http';
|
|
export type { CompressionOptions } from './http/compression';
|
|
export { UNMATCHED_ROUTE } from './http/core';
|
|
export type { TlsOptions, CorsOptions, SecurityOptions } from './security';
|
|
export type { UploadedFile, MultipartBody } from './multipart';
|
|
export type { StandardSchemaV1 } from './standard-schema';
|
|
|
|
// Mesh
|
|
export { connectLink } from './mesh/link';
|
|
export { buildRemote, envelopeFrom } from './mesh/teacup';
|
|
export { buildManifest, createMeshControl, MESH_CONTROL_PATH } from './mesh/teapot';
|
|
export type { Manifest, RequestEnvelope, Frame } from './mesh/protocol';
|