You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -85,12 +85,12 @@ The handler ships a standard route pack — `GET / POST /`, `GET PUT PATCH DELET
85
85
86
86
The bundled `dynamodb-toolkit/handler` is a pure `node:http` handler. Framework-specific bindings live in separate packages so the core stays zero-dep — each adapter is a thin wrapper that translates its framework's request/response shape into the toolkit's `rest-core` parsers + standard route pack. The wire contract (routes, query parameters, envelope keys, error mapping) is identical across all four.
87
87
88
-
| Package | Runtime / framework | Notes |
89
-
| --- | --- | --- |
90
-
|[`dynamodb-toolkit-koa`](https://www.npmjs.com/package/dynamodb-toolkit-koa)|[Koa](https://koajs.com/) 2.x | Middleware; `koa` as peer dep |
91
-
|[`dynamodb-toolkit-express`](https://www.npmjs.com/package/dynamodb-toolkit-express)|[Express](https://expressjs.com/) 4.x / 5.x | Middleware / Router; `express` as peer dep |
92
-
|[`dynamodb-toolkit-fetch`](https://www.npmjs.com/package/dynamodb-toolkit-fetch)| Fetch API — `(Request) => Promise<Response>`| Zero-framework; runs on Cloudflare Workers, Deno Deploy, Bun.serve, Hono, Node native fetch server |
93
-
|[`dynamodb-toolkit-lambda`](https://www.npmjs.com/package/dynamodb-toolkit-lambda)| AWS Lambda handler | Four event shapes (API Gateway REST / HTTP, Function URL, ALB); ships local-debug bridges for running the handler on real HTTP without `sam local`|
|[`dynamodb-toolkit-fetch`](https://www.npmjs.com/package/dynamodb-toolkit-fetch)| Fetch API — `(Request) => Promise<Response>`| Zero-framework; runs on Cloudflare Workers, Deno Deploy, Bun.serve, Hono, Node native fetch server|
93
+
|[`dynamodb-toolkit-lambda`](https://www.npmjs.com/package/dynamodb-toolkit-lambda)| AWS Lambda handler| Four event shapes (API Gateway REST / HTTP, Function URL, ALB); ships local-debug bridges for running the handler on real HTTP without `sam local`|
- `resolveSort(query, sortableIndices?)` → `{index, descending}` — resolves `?sort=-name` to `{index: 'name-gsi', descending: true}` via the passed GSI mapping. Unmapped / missing fields → `{index: undefined, descending: false}`.
270
+
- `stripMount(pathname, mountPath?)` → `string | null` — returns the pathname tail when the request is under `mountPath`, else `null`. Normalizes trailing slash on `mountPath` so `'/planets/'` and `'/planets'` behave identically. Empty / missing `mountPath` means "mount at root."
271
+
- `validateWriteBody(body, {allowEmpty?, allowArray?}?)` → `body` — throws `{status: 400, code: 'BadBody'}` when `body` is non-object (or null/array without the matching option). Use on write-shaped routes where `{...body, ...key}` would silently accept `null` (writes key-only) or arrays (writes `{"0": …}`).
**HEAD → GET auto-promote.** `matchRoute` treats `HEAD` as `GET` for dispatch, annotates the result with `head: true`, and the bundled handler returns headers + `Content-Length` with an empty body. Consumers get the expected REST semantics on every resource endpoint without extra configuration.
313
+
314
+
**Body-always-parsed invariant.** For clone-all / move-all routes (`PUT /-clone`, `PUT /-move`), the parsed body flows into `exampleFromContext(query, body)` alongside the query — consumers can key their tenant/ownership scope on either. (Earlier versions passed `null` on these routes.)
315
+
316
+
**Body cap measures bytes, not UTF-16 code units.** As of 3.1.2, the built-in body reader accumulates `Buffer` chunks and enforces `maxBodyBytes` in bytes. Multi-byte payloads (CJK, emoji) are now bounded by the advertised cap; earlier versions let ~2-4× through because `String.length` counts code units.
317
+
318
+
**`readJsonBody(req, maxBodyBytes, {destroy?})`.** Exported helper for adapter-style code that needs the same Node-stream reader as the bundled handler. Pass `{destroy: false}` when the framework needs the socket alive to write the 413 response (Koa, Express — both hand body serialization to the framework response object).
0 commit comments