From ac614f647b5648355d9ae2951a63227234174d9a Mon Sep 17 00:00:00 2001 From: Dinh Le Date: Fri, 14 Aug 2026 07:47:22 +0700 Subject: [PATCH 1/2] docs: symlink root README to core and add ecosystem package table The core README now doubles as the repo front page via a root symlink, gains per-body-type sections (JSON, forms, file, event-stream, octet-stream), and every package README opens with the same ecosystem package table using relative links. The peer README documents why resolveBody ignores the hint argument. --- README.md | 143 +--------------------------------- packages/aws-lambda/README.md | 16 +++- packages/core/README.md | 140 ++++++++++++++++++++++++++++++--- packages/fastify/README.md | 16 +++- packages/fetch/README.md | 16 +++- packages/node/README.md | 16 +++- packages/peer/README.md | 20 ++++- packages/shared/README.md | 16 +++- 8 files changed, 213 insertions(+), 170 deletions(-) mode change 100644 => 120000 README.md diff --git a/README.md b/README.md deleted file mode 100644 index 9e07c67..0000000 --- a/README.md +++ /dev/null @@ -1,142 +0,0 @@ -# Standard Server - -
- - codecov - - - weekly downloads - - - CodSpeed - - - MIT License - - - Discord - - - Ask DeepWiki - -
- -**Standard Server** provides a unified interface for client-server communication over HTTP and message-based transports. - -```ts -import type { StandardLazyRequest, StandardResponse } from '@standardserver/core' - -export async function handle(request: StandardLazyRequest): Promise { - const body = await request.resolveBody() - - return { - status: 200, - headers: { 'content-type': 'application/json' }, - async* body() { // <- SSE response - yield 'Hello, World!' - }, - } -} -``` - -## Why Standard Server? - -Every JavaScript runtime speaks a slightly different HTTP dialect: `Request` and `Response` in Fetch runtimes, `IncomingMessage` and `ServerResponse` in Node.js, proxy events in AWS Lambda, framework objects in Fastify β€” and no HTTP at all over WebSocket or MessagePort. Standard Server defines one small request/response contract and ships adapters that translate each transport to and from it, so the same handler runs everywhere, including streaming bodies and server-sent events. - -## Packages - -| Package | Purpose | -| ------------------------------------------------------------- | ----------------------------------------------------------------------------- | -| [`@standardserver/core`](packages/core/README.md) | The shared contract: request/response types, body parsing rules, SSE helpers | -| [`@standardserver/fetch`](packages/fetch/README.md) | Fetch API adapter (browsers, Cloudflare Workers, Bun, Deno, service workers) | -| [`@standardserver/node`](packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](packages/fastify/README.md) | Fastify adapter, built on the Node.js adapter | -| [`@standardserver/aws-lambda`](packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](packages/peer/README.md) | Message-based adapter (WebSocket, MessagePort, Electron IPC, custom channels) | -| [`@standardserver/shared`](packages/shared/README.md) | Internal utilities shared across the ecosystem | - -Start with the [`@standardserver/core` README](packages/core/README.md) β€” it documents the contract every package shares, including [the `standard-server` header](packages/core/README.md#the-standard-server-header) and [how body parsing works](packages/core/README.md#how-body-parsing-works) β€” then pick the adapter README for your transport. - -## Sponsors - -Like what we build over at [middleapi](https://github.com/middleapi)? You can help keep it going here: [GitHub Sponsors](https://github.com/sponsors/dinwwwh). Every bit helps! πŸš€ - -### πŸ† Platinum Sponsor - - - - - -
ScreenshotOne.com
ScreenshotOne.com
- -### πŸ₯ˆ Silver Sponsor - - - - - -
ζ‘δΈŠγ•γ‚“
ζ‘δΈŠγ•γ‚“
- -### Generous Sponsors - - - - - -
LN Markets
LN Markets
- -### Sponsors - - - - - - - - - - - - - - - - - - - - - - - -
Reece McDonald
Reece McDonald
あわわわとーにゅ
あわわわとーにゅ
nk
nk
supastarter
supastarter
Dexter Miguel
Dexter Miguel
herrfugbaum
herrfugbaum
Ryota Murakami
Ryota Murakami
David Cramer
David Cramer
Valerii Petryniak
Valerii Petryniak
Valerii Strilets
Valerii Strilets
Kyle Mistele
Kyle Mistele
christ12938
christ12938
Ryan Soderberg
Ryan Soderberg
shota
shota
Ellis Driscoll
Ellis Driscoll
- -### Backers - - - - - - - - - - - - - - - - - - - - - - - - - -
David Walsh
David Walsh
Robbe Vaes
Robbe Vaes
Aidan Sunbury
Aidan Sunbury
soonoo
soonoo
Kevin Porten
Kevin Porten
Denis
Denis
Christopher Kapic
Christopher Kapic
Tom Ballinger
Tom Ballinger
Sam
Sam
Titoine
Titoine
Igor Makowski
Igor Makowski
hanayashiki
hanayashiki
Lev Dubinets
Lev Dubinets
Kelly Peilin Chan
Kelly Peilin Chan
Guy Ariely
Guy Ariely
Alex
Alex
Andrey Gubanov
Andrey Gubanov
- -With thanks to 37 past sponsors who helped get us here. diff --git a/README.md b/README.md new file mode 120000 index 0000000..dfd012e --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +packages/core/README.md \ No newline at end of file diff --git a/packages/aws-lambda/README.md b/packages/aws-lambda/README.md index f08c06a..0437dee 100644 --- a/packages/aws-lambda/README.md +++ b/packages/aws-lambda/README.md @@ -25,6 +25,18 @@ Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you write handlers against the same request, response, body, and streaming primitives whether the underlying transport is the Fetch API, Node.js HTTP, HTTP/2, or a peer-style message channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | + This package is the AWS Lambda adapter for that model. It converts an API Gateway proxy event β€” payload format version 1.0 or 2.0, the latter also used by Lambda Function URLs β€” into a `StandardLazyRequest`, and writes a `StandardResponse` back through the stream provided by `awslambda.streamifyResponse`, so streaming bodies such as server-sent events flow to the client as they are produced instead of being buffered. ## Package overview @@ -96,9 +108,7 @@ The event carries the request body as a fully buffered, optionally base64-encode ## Learn more -For the higher-level project overview, see the root [Standard Server README](../../README.md). - -For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md), and for the shared contract, see the [core documentation](../core/README.md). +For the project overview and the shared contract, see the [core documentation](../core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md). ## Sponsors diff --git a/packages/core/README.md b/packages/core/README.md index 1171fc7..820421f 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -1,4 +1,4 @@ -# @standardserver/core +# Standard Server
@@ -21,9 +21,19 @@
-`@standardserver/core` is the shared contract package for Standard Server. +`@standardserver/core` is the shared contract package for **Standard Server** β€” a unified interface for client-server communication across HTTP and message-based transports. It lets you keep handler and client code transport-agnostic by working with the same request, response, body, and streaming abstractions whether the transport is Fetch, Node.js HTTP, or a peer-style message channel. -Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you keep handler and client code transport-agnostic by working with the same request, response, body, and streaming abstractions whether the transport is Fetch, Node.js HTTP, or a peer-style message channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | This package is the foundation of that model. It defines the request and response types every adapter converts to and from, the body parsing rules they all share, runtime validators, header and URL utilities, and event stream (SSE) helpers. @@ -69,7 +79,7 @@ export async function handle(request: StandardLazyRequest): Promise [!TIP] +> HTML forms submit data as `application/x-www-form-urlencoded` or `multipart/form-data`, so these body types are especially helpful there. + +### File and Blob body + +Standard Server treats [File](https://developer.mozilla.org/en-US/docs/Web/API/File) and [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) as fixed-size binary payloads. + > [!NOTE] > Since `File` extends `Blob`, `resolveBody` always returns a `File` when representing either `File` or `Blob` bodies. +```ts +import type { StandardResponse } from '@standardserver/core' + +const response: StandardResponse = { + status: 200, + headers: { + 'content-disposition': [], // <- remove auto-set header + }, + body: new File(['Hello, World!'], 'hello.txt', { type: 'text/plain' }), +} +``` + +When sending a file or blob body, adapters automatically set the `content-length`, `content-type`, `content-disposition`, and `standard-server` headers based on the provided body. You can override any of them by explicitly providing a header value, or remove one entirely by assigning an empty array. + +### Event-stream body + +Standard Server uses [AsyncIteratorObject](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator) to represent an event stream body, and you can use `withEventMeta()` to attach additional [SSE event metadata](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#event_stream_format) to each emitted event. + +```ts +import type { StandardResponse } from '@standardserver/core' +import { ErrorEvent, withEventMeta } from '@standardserver/core' + +const response: StandardResponse = { + status: 200, + headers: {}, + async* body() { + yield withEventMeta( + { message: 'Hello, World!' }, + { id: '1', retry: 3000, comments: ['hidden'] }, + ) + + throw new ErrorEvent({ message: 'Something went wrong' }) + + return { message: 'This is the end of the stream' } + }, +} +``` + +Events are interpreted as follows: `yield` emits a `message`, `throw` emits an `error`, and `return` emits a `close` event. Note that `close` does not cause [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) to close the connection because it is not part of the SSE specification. However, when using Standard Server for client-side streaming, `close` is treated as the end of the stream, so the connection is closed and no reconnection is attempted. + +For explicit SSE encoding, decoding, and metadata handling, see the [Event-Stream Helpers](#event-stream-helpers) below. + +### Octet-stream body + +Standard Server uses [ReadableStream](https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream) to represent a binary streaming body. + +```ts +import type { StandardResponse } from '@standardserver/core' + +const response: StandardResponse = { + status: 200, + headers: { + 'content-type': 'application/octet-stream', + }, + body: new ReadableStream({ + start(controller) { + const encoder = new TextEncoder() + controller.enqueue(encoder.encode('Hello, World!')) + controller.close() + }, + }), +} +``` + +When sending a binary streaming body, adapters automatically set the `content-type` and `standard-server` headers. You can override `content-type` by providing an explicit header value, or remove it entirely by assigning an empty array. + ## How body parsing works > [!NOTE] -> This section applies to the HTTP adapters (Fetch, Node.js, Fastify, AWS Lambda). It does not apply to the [peer adapter](../peer/README.md), which identifies body types through its own message protocol β€” a different but fairly similar mechanism. +> This section applies to the HTTP adapters (Fetch, Node.js, Fastify, AWS Lambda). It does not apply to the [peer adapter](../peer/README.md#body-resolution), which identifies body types through its own message protocol β€” a different but fairly similar mechanism. `resolveBody(hint?)` on `StandardLazyRequest` and `StandardLazyResponse` resolves the body lazily β€” the underlying stream is only consumed once you call it. The `StandardBodyHint` that decides how the raw body is parsed comes from three places: an explicit `hint` argument, the `standard-server` header, or inference from the content headers. @@ -309,8 +433,6 @@ const response: StandardResponse = { } ``` -Events are interpreted as follows: `yield` emits a `message`, `throw` emits an `error`, and `return` emits a `close` event. Note that `close` does not cause [EventSource](https://developer.mozilla.org/en-US/docs/Web/API/EventSource) to close the connection because it is not part of the SSE specification. However, when using Standard Server for client-side streaming, `close` is treated as the end of the stream, so the connection is closed and no reconnection is attempted. - > [!WARNING] > Metadata is validated before it is attached: `id`, `event`, and comments must not contain line breaks, and `retry` must be a non-negative integer. @@ -340,9 +462,7 @@ error.data ## Learn more -For the higher-level project overview and adapter quick-starts, see the root [Standard Server README](../../README.md). - -Adapter documentation: [Fetch](../fetch/README.md) Β· [Node.js](../node/README.md) Β· [Fastify](../fastify/README.md) Β· [AWS Lambda](../aws-lambda/README.md) Β· [Peer](../peer/README.md) +For transport-specific quick-starts and options, see the adapter documentation: [Fetch](../fetch/README.md) Β· [Node.js](../node/README.md) Β· [Fastify](../fastify/README.md) Β· [AWS Lambda](../aws-lambda/README.md) Β· [Peer](../peer/README.md) ## Sponsors diff --git a/packages/fastify/README.md b/packages/fastify/README.md index 04ea30e..7bb4f2e 100644 --- a/packages/fastify/README.md +++ b/packages/fastify/README.md @@ -25,6 +25,18 @@ Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you write handlers against the same request, response, body, and streaming primitives whether the underlying transport is the Fetch API, Node.js HTTP, HTTP/2, or a peer-style message channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | + This package is the Fastify adapter for that model. It builds on [`@standardserver/node`](../node/README.md), reusing the same body, URL, and abort-signal primitives, while routing the response back through Fastify's reply lifecycle so hooks, plugins, and serializers keep working. Both `Fastify()` and `Fastify({ http2: true })` instances are supported. `fastify` is a peer dependency, so the adapter always uses the Fastify version installed in your project. @@ -123,9 +135,7 @@ Fastify owns the reply lifecycle, so a few of its rules apply to the response th ## Learn more -For the higher-level project overview, see the root [Standard Server README](../../README.md). - -For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md), and for the shared contract, see the [core documentation](../core/README.md). +For the project overview and the shared contract, see the [core documentation](../core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md). ## Sponsors diff --git a/packages/fetch/README.md b/packages/fetch/README.md index 9950aa1..6cb4138 100644 --- a/packages/fetch/README.md +++ b/packages/fetch/README.md @@ -25,6 +25,18 @@ Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you write handlers and clients against the same request, response, body, and streaming primitives whether the underlying transport is Fetch, Node.js HTTP, or a peer-style message channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | + This package is the Fetch API adapter for that model. It converts between native `Request`, `Response`, `Headers`, and stream values and the corresponding Standard Server shapes from [`@standardserver/core`](../core/README.md). ## Package overview @@ -108,9 +120,7 @@ const payload = await standardResponse.resolveBody() ## Learn more -For the higher-level project overview, see the root [Standard Server README](../../README.md). - -For the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). ## Sponsors diff --git a/packages/node/README.md b/packages/node/README.md index eb6e223..e317be7 100644 --- a/packages/node/README.md +++ b/packages/node/README.md @@ -25,6 +25,18 @@ Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you write handlers against the same request, response, body, and streaming primitives whether the underlying transport is the Fetch API, Node.js HTTP, HTTP/2, or a peer-style message channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | + This package is the Node.js adapter for that model. It converts between native Node request and response objects and the corresponding Standard Server shapes from [`@standardserver/core`](../core/README.md), while also exposing lower-level utilities for body parsing, URL normalization, abort signals, and server-sent events. ## Package overview @@ -84,9 +96,7 @@ createServer(async (req, res) => { ## Learn more -For the higher-level project overview, see the root [Standard Server README](../../README.md). - -For the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). ## Sponsors diff --git a/packages/peer/README.md b/packages/peer/README.md index 1f6592b..f0475b4 100644 --- a/packages/peer/README.md +++ b/packages/peer/README.md @@ -25,6 +25,18 @@ Standard Server provides a unified interface for client-server communication across HTTP and message-based transports. It lets you write handlers and clients against the same request, response, body, and streaming primitives whether the underlying transport is Fetch, Node.js HTTP, WebSocket, MessagePort, or another peer-style channel. +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | + This package is the peer adapter for that model. It converts between Standard Server requests and responses and a structured peer message protocol that can be sent through any transport capable of carrying strings or binary data. ## Package overview @@ -112,6 +124,10 @@ const payload = await response.resolveBody() > [!TIP] > When encoding or decoding peer messages, you can pass additional options, such as `prefix`, to prevent collisions when the same peer is used for multiple purposes. +## Body resolution + +Unlike the HTTP adapters, `resolveBody(hint?)` ignores the `hint` argument in this adapter. HTTP adapters receive the body as a raw byte stream and must decide how to parse it, so a hint can steer that decision. The peer protocol instead encodes the body in structured form at send time: JSON values travel as JSON, binary payloads travel as binary, event and octet streams flow as dedicated stream messages, and markers in the message distinguish the ambiguous cases such as `form-data` vs. `file`. By the time a message arrives, there are no raw bytes left to reinterpret β€” the body always resolves to exactly the representation the sender had, so a hint has nothing to override. + ## Codec helpers Use `encodePeerMessage()` and `decodePeerMessage()` to bridge between the peer protocol and your underlying transport. @@ -143,9 +159,7 @@ Encoding rules: ## Learn more -For the higher-level project overview, see the root [Standard Server README](../../README.md). - -For the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). ## Sponsors diff --git a/packages/shared/README.md b/packages/shared/README.md index 0724589..5001eaa 100644 --- a/packages/shared/README.md +++ b/packages/shared/README.md @@ -25,11 +25,21 @@ It has no runtime dependencies and works in any JavaScript environment. The package exists so the other `@standardserver` packages can share these building blocks without duplication; its API follows their needs and is not designed for direct use in applications. -## Learn more +Standard Server ships as a small ecosystem of packages: + +| Package | Description | +| ------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | -For the higher-level project overview, see the root [Standard Server README](../../README.md). +## Learn more -For the public contract of the ecosystem, see the [core documentation](../core/README.md). +For the project overview and the public contract of the ecosystem, see the [core documentation](../core/README.md). ## Sponsors From 53552b54d7c9d39c28d46f91d164f6c145767bc3 Mon Sep 17 00:00:00 2001 From: Dinh Le Date: Fri, 14 Aug 2026 08:00:04 +0700 Subject: [PATCH 2/2] docs: use absolute links and add license sections Cross-package links now use absolute GitHub URLs so they resolve from the symlinked root README and on npm. Every package README ends with a License section matching the oRPC style. --- packages/aws-lambda/README.md | 26 +++++++++++++++----------- packages/core/README.md | 26 +++++++++++++++----------- packages/fastify/README.md | 32 ++++++++++++++++++-------------- packages/fetch/README.md | 32 ++++++++++++++++++-------------- packages/node/README.md | 30 +++++++++++++++++------------- packages/peer/README.md | 24 ++++++++++++++---------- packages/shared/README.md | 24 ++++++++++++++---------- 7 files changed, 111 insertions(+), 83 deletions(-) diff --git a/packages/aws-lambda/README.md b/packages/aws-lambda/README.md index 0437dee..303694c 100644 --- a/packages/aws-lambda/README.md +++ b/packages/aws-lambda/README.md @@ -27,15 +27,15 @@ Standard Server provides a unified interface for client-server communication acr Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | This package is the AWS Lambda adapter for that model. It converts an API Gateway proxy event β€” payload format version 1.0 or 2.0, the latter also used by Lambda Function URLs β€” into a `StandardLazyRequest`, and writes a `StandardResponse` back through the stream provided by `awslambda.streamifyResponse`, so streaming bodies such as server-sent events flow to the client as they are produced instead of being buffered. @@ -93,7 +93,7 @@ export const handler = awslambda.streamifyResponse(async (event, responseStream, ## Resolving Body -The event carries the request body as a fully buffered, optionally base64-encoded string. `resolveBody(hint?)` decodes it and then follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](../core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](../core/README.md#how-body-parsing-works) in the core README for the full algorithm. +The event carries the request body as a fully buffered, optionally base64-encoded string. `resolveBody(hint?)` decodes it and then follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#how-body-parsing-works) in the core README for the full algorithm. > [!TIP] > For efficient communication, set the `standard-server` header to explicitly hint the body type, especially for file or binary streaming. For example, if you upload a file with a common `content-type` such as `application/json` but omit the `standard-server` header, the server may interpret it as JSON and parse it unexpectedly. @@ -108,7 +108,7 @@ The event carries the request body as a fully buffered, optionally base64-encode ## Learn more -For the project overview and the shared contract, see the [core documentation](../core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md). +For the project overview and the shared contract, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md). ## Sponsors @@ -193,3 +193,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/core/README.md b/packages/core/README.md index 820421f..a2e3a1b 100644 --- a/packages/core/README.md +++ b/packages/core/README.md @@ -25,15 +25,15 @@ Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | This package is the foundation of that model. It defines the request and response types every adapter converts to and from, the body parsing rules they all share, runtime validators, header and URL utilities, and event stream (SSE) helpers. @@ -213,7 +213,7 @@ When sending a binary streaming body, adapters automatically set the `content-ty ## How body parsing works > [!NOTE] -> This section applies to the HTTP adapters (Fetch, Node.js, Fastify, AWS Lambda). It does not apply to the [peer adapter](../peer/README.md#body-resolution), which identifies body types through its own message protocol β€” a different but fairly similar mechanism. +> This section applies to the HTTP adapters (Fetch, Node.js, Fastify, AWS Lambda). It does not apply to the [peer adapter](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md#body-resolution), which identifies body types through its own message protocol β€” a different but fairly similar mechanism. `resolveBody(hint?)` on `StandardLazyRequest` and `StandardLazyResponse` resolves the body lazily β€” the underlying stream is only consumed once you call it. The `StandardBodyHint` that decides how the raw body is parsed comes from three places: an explicit `hint` argument, the `standard-server` header, or inference from the content headers. @@ -462,7 +462,7 @@ error.data ## Learn more -For transport-specific quick-starts and options, see the adapter documentation: [Fetch](../fetch/README.md) Β· [Node.js](../node/README.md) Β· [Fastify](../fastify/README.md) Β· [AWS Lambda](../aws-lambda/README.md) Β· [Peer](../peer/README.md) +For transport-specific quick-starts and options, see the adapter documentation: [Fetch](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) Β· [Node.js](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) Β· [Fastify](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) Β· [AWS Lambda](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) Β· [Peer](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) ## Sponsors @@ -547,3 +547,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/fastify/README.md b/packages/fastify/README.md index 7bb4f2e..e8d9b54 100644 --- a/packages/fastify/README.md +++ b/packages/fastify/README.md @@ -27,17 +27,17 @@ Standard Server provides a unified interface for client-server communication acr Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | - -This package is the Fastify adapter for that model. It builds on [`@standardserver/node`](../node/README.md), reusing the same body, URL, and abort-signal primitives, while routing the response back through Fastify's reply lifecycle so hooks, plugins, and serializers keep working. Both `Fastify()` and `Fastify({ http2: true })` instances are supported. +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | + +This package is the Fastify adapter for that model. It builds on [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md), reusing the same body, URL, and abort-signal primitives, while routing the response back through Fastify's reply lifecycle so hooks, plugins, and serializers keep working. Both `Fastify()` and `Fastify({ http2: true })` instances are supported. `fastify` is a peer dependency, so the adapter always uses the Fastify version installed in your project. @@ -52,7 +52,7 @@ The package exposes two helpers and their option shapes: Both helpers accept `AnyFastifyRequest` and `AnyFastifyReply`, which are `FastifyRequest` and `FastifyReply` widened over every raw server. That is what lets the same call site work for `Fastify()`, `Fastify({ http2: true })`, typed route generics, hooks, and encapsulated plugins alike. -Lower-level helpers such as `toStandardBody()`, `toNodeHttpBody()`, and `toEventStream()` are not re-exported here β€” import them from [`@standardserver/node`](../node/README.md) when you need them. +Lower-level helpers such as `toStandardBody()`, `toNodeHttpBody()`, and `toEventStream()` are not re-exported here β€” import them from [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) when you need them. ## Server-side request handling @@ -97,7 +97,7 @@ await fastify.listen({ port: 3000 }) ## Resolving Body -`resolveBody(hint?)` returns the body Fastify already parsed with its own content type parsers, if there is one. Otherwise it falls back to `toStandardBody()` from `@standardserver/node`, which follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](../core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](../core/README.md#how-body-parsing-works) in the core README for the full algorithm. +`resolveBody(hint?)` returns the body Fastify already parsed with its own content type parsers, if there is one. Otherwise it falls back to `toStandardBody()` from `@standardserver/node`, which follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#how-body-parsing-works) in the core README for the full algorithm. Because Fastify's own parsers win, a `hint` only applies to bodies Fastify left unparsed. Fastify ships parsers for `application/json` and `text/plain`, and rejects every other content type with `415 Unsupported Media Type` unless you register one. To let the adapter own body parsing end to end, register a catch-all parser that leaves the body untouched: @@ -135,7 +135,7 @@ Fastify owns the reply lifecycle, so a few of its rules apply to the response th ## Learn more -For the project overview and the shared contract, see the [core documentation](../core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](../node/README.md). +For the project overview and the shared contract, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). For the Node.js primitives this adapter is built on, see the [Node.js adapter documentation](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md). ## Sponsors @@ -220,3 +220,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/fetch/README.md b/packages/fetch/README.md index 6cb4138..f51589f 100644 --- a/packages/fetch/README.md +++ b/packages/fetch/README.md @@ -27,17 +27,17 @@ Standard Server provides a unified interface for client-server communication acr Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | - -This package is the Fetch API adapter for that model. It converts between native `Request`, `Response`, `Headers`, and stream values and the corresponding Standard Server shapes from [`@standardserver/core`](../core/README.md). +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | + +This package is the Fetch API adapter for that model. It converts between native `Request`, `Response`, `Headers`, and stream values and the corresponding Standard Server shapes from [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). ## Package overview @@ -106,21 +106,21 @@ const standardResponse = toStandardLazyResponse(response) const payload = await standardResponse.resolveBody() ``` -`toFetchBody()` also prepares the content headers for the body it serializes β€” for example, a `Blob` or `File` body gains `standard-server: file`, `content-length`, and a generated `content-disposition`, so the receiver reconstructs the same body type. See [the `standard-server` header](../core/README.md#the-standard-server-header) in the core README for why. +`toFetchBody()` also prepares the content headers for the body it serializes β€” for example, a `Blob` or `File` body gains `standard-server: file`, `content-length`, and a generated `content-disposition`, so the receiver reconstructs the same body type. See [the `standard-server` header](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#the-standard-server-header) in the core README for why. > [!TIP] > When sending requests or responses, you can pass additional options such as event-stream keep-alive. ## Resolving Body -`resolveBody(hint?)` follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](../core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](../core/README.md#how-body-parsing-works) in the core README for the full algorithm. +`resolveBody(hint?)` follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#how-body-parsing-works) in the core README for the full algorithm. > [!TIP] > For efficient communication, set the `standard-server` header to explicitly hint the body type, especially for file or binary streaming. For example, if you upload a file with a common `content-type` such as `application/json` but omit the `standard-server` header, the server may interpret it as JSON and parse it unexpectedly. ## Learn more -For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). ## Sponsors @@ -205,3 +205,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/node/README.md b/packages/node/README.md index e317be7..0418c6a 100644 --- a/packages/node/README.md +++ b/packages/node/README.md @@ -27,17 +27,17 @@ Standard Server provides a unified interface for client-server communication acr Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | - -This package is the Node.js adapter for that model. It converts between native Node request and response objects and the corresponding Standard Server shapes from [`@standardserver/core`](../core/README.md), while also exposing lower-level utilities for body parsing, URL normalization, abort signals, and server-sent events. +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | + +This package is the Node.js adapter for that model. It converts between native Node request and response objects and the corresponding Standard Server shapes from [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md), while also exposing lower-level utilities for body parsing, URL normalization, abort signals, and server-sent events. ## Package overview @@ -89,14 +89,14 @@ createServer(async (req, res) => { ## Resolving Body -`resolveBody(hint?)` follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](../core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](../core/README.md#how-body-parsing-works) in the core README for the full algorithm. +`resolveBody(hint?)` follows the shared Standard Server resolution rules: an explicit `hint` wins, then the [`standard-server` header](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#the-standard-server-header), then inference from the content headers. See [how body parsing works](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md#how-body-parsing-works) in the core README for the full algorithm. > [!TIP] > For efficient communication, set the `standard-server` header to explicitly hint the body type, especially for file or binary streaming. For example, if you upload a file with a common `content-type` such as `application/json` but omit the `standard-server` header, the server may interpret it as JSON and parse it unexpectedly. ## Learn more -For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). ## Sponsors @@ -181,3 +181,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/peer/README.md b/packages/peer/README.md index f0475b4..c83a842 100644 --- a/packages/peer/README.md +++ b/packages/peer/README.md @@ -27,15 +27,15 @@ Standard Server provides a unified interface for client-server communication acr Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | This package is the peer adapter for that model. It converts between Standard Server requests and responses and a structured peer message protocol that can be sent through any transport capable of carrying strings or binary data. @@ -159,7 +159,7 @@ Encoding rules: ## Learn more -For the project overview and the shared contract this adapter implements, see the [core documentation](../core/README.md). +For the project overview and the shared contract this adapter implements, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). ## Sponsors @@ -244,3 +244,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information. diff --git a/packages/shared/README.md b/packages/shared/README.md index 5001eaa..b35feac 100644 --- a/packages/shared/README.md +++ b/packages/shared/README.md @@ -27,19 +27,19 @@ It has no runtime dependencies and works in any JavaScript environment. The pack Standard Server ships as a small ecosystem of packages: -| Package | Description | -| ------------------------------------------------------- | --------------------------------------------------------------------------- | -| [`@standardserver/core`](../core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | -| [`@standardserver/fetch`](../fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | -| [`@standardserver/node`](../node/README.md) | Node.js HTTP and HTTP/2 adapter | -| [`@standardserver/fastify`](../fastify/README.md) | Fastify adapter built on the Node.js adapter | -| [`@standardserver/aws-lambda`](../aws-lambda/README.md) | AWS Lambda adapter with response streaming | -| [`@standardserver/peer`](../peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | -| [`@standardserver/shared`](../shared/README.md) | Internal utilities shared across the ecosystem | +| Package | Description | +| ------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------- | +| [`@standardserver/core`](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md) | The shared contract: types, body parsing rules, validators, and SSE helpers | +| [`@standardserver/fetch`](https://github.com/middleapi/standardserver/blob/main/packages/fetch/README.md) | Fetch API adapter for browsers, workers, and other Fetch-based runtimes | +| [`@standardserver/node`](https://github.com/middleapi/standardserver/blob/main/packages/node/README.md) | Node.js HTTP and HTTP/2 adapter | +| [`@standardserver/fastify`](https://github.com/middleapi/standardserver/blob/main/packages/fastify/README.md) | Fastify adapter built on the Node.js adapter | +| [`@standardserver/aws-lambda`](https://github.com/middleapi/standardserver/blob/main/packages/aws-lambda/README.md) | AWS Lambda adapter with response streaming | +| [`@standardserver/peer`](https://github.com/middleapi/standardserver/blob/main/packages/peer/README.md) | Message-based adapter for WebSocket, MessagePort, and custom transports | +| [`@standardserver/shared`](https://github.com/middleapi/standardserver/blob/main/packages/shared/README.md) | Internal utilities shared across the ecosystem | ## Learn more -For the project overview and the public contract of the ecosystem, see the [core documentation](../core/README.md). +For the project overview and the public contract of the ecosystem, see the [core documentation](https://github.com/middleapi/standardserver/blob/main/packages/core/README.md). ## Sponsors @@ -124,3 +124,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he With thanks to 37 past sponsors who helped get us here. + +## License + +Distributed under the MIT License. See [LICENCE](https://github.com/middleapi/standardserver/blob/main/LICENCE) for more information.