-
Notifications
You must be signed in to change notification settings - Fork 0
Compatibility
Peer dependency range: ^2.15.0 || ^3.0.0.
The adapter uses only stable surface area:
-
ctx.method,ctx.path,ctx.query,ctx.req,ctx.request.body,ctx.status,ctx.body,ctx.originalUrl. -
nextfrom the middleware signature(ctx, next) => Promise<void>.
Both Koa 2 (still the most widely deployed) and Koa 3 (current) are supported. Koa 3 dropped some deprecated shims but didn't change the middleware contract.
Same wire contract, different host — share one Adapter instance across any of them:
-
dynamodb-toolkit-express— Express 4 / 5 middleware. -
dynamodb-toolkit-fetch— Web Fetch(Request) => Promise<Response>for Cloudflare Workers, Deno Deploy, Bun.serve, Hono. -
dynamodb-toolkit-lambda— AWS Lambda (API Gateway v1 / v2, Function URL, ALB). -
dynamodb-toolkit/handler— the bundlednode:httphandler in the parent toolkit.
The unit test suite runs identically under:
| Runtime | Command | Notes |
|---|---|---|
| Node | npm test |
Node 20+ floor (see below) |
| Bun | npm run test:bun |
Current Bun releases |
| Deno | npm run test:deno |
--allow-* flags provided by tape-six's runner |
Cross-runtime support is inherited from:
-
dynamodb-toolkititself — which tests Node / Bun / Deno. -
Koa — Bun and Deno both ship compatible
node:http/node:streamshims. -
@aws-sdk/client-dynamodb/@aws-sdk/lib-dynamodb— runnable on Bun and Deno via their Node compat layers.
engines.node is >=20. Two sub-floors worth knowing:
-
require(esm)interop for CJS consumers — 20.19+ on the 20.x line, 22.12+ on 22.x, unflagged everywhere newer. The.cjssmoke test exercises this. -
Native TypeScript — Node 22.6+ (with
--experimental-strip-types) or 23.6+ (unflagged). Used bynpm run ts-test. Bun and Deno run.tsnatively without special setup, vianpm run ts-test:bunandnpm run ts-test:deno.
Both smoke-tests are included so you can verify your target runtime handles the adapter correctly.
require('dynamodb-toolkit-koa') works on Nodes that ship require(esm) (20.19+ / 22.12+ / anything newer). The .cjs smoke test demonstrates:
const {createKoaAdapter} = require('dynamodb-toolkit-koa');
const {readJsonBody} = require('dynamodb-toolkit-koa/read-body.js');Hand-written .d.ts sidecars ship next to each .js file. package.json declares main, module, and types for all resolution styles:
{
"main": "./src/index.js",
"module": "./src/index.js",
"types": "./src/index.d.ts",
"exports": {
".": "./src/index.js",
"./*": "./src/*"
}
}The factory is generic in TItem so typed Adapter<Item, Key> instances flow through without casts:
import {Adapter} from 'dynamodb-toolkit';
import {createKoaAdapter, type KoaAdapterOptions} from 'dynamodb-toolkit-koa';
interface Planet extends Record<string, unknown> {
name: string;
climate?: string;
}
type PlanetKey = Pick<Planet, 'name'>;
const adapter = new Adapter<Planet, PlanetKey>({client, table: 'planets', keyFields: ['name']});
const opts: KoaAdapterOptions<Planet> = {
keyFromPath: (raw, a) => ({[a.keyFields[0].name]: raw}),
policy: {defaultLimit: 25, maxLimit: 200}
};
const mw = createKoaAdapter(adapter, opts);See tests/test-typed.ts in the source tree for a runnable typed example.
-
ESM-only. The source is
.js+ hand-written.d.ts, no build step. -
Zero runtime dependencies.
dynamodb-toolkitandkoaarepeerDependencies. -
No
node:*imports at runtime. Type-only imports fromnode:httpin.d.tsfiles are fine; runtime code is framework-neutral where the framework isn't explicitly referenced.
The adapter's own test matrix exercises the full route pack:
- 43 tests, 98 assertions, via real Koa +
fetch. - 4 CJS smoke tests.
- 5 TypeScript smoke tests.
All identical across Node / Bun / Deno except the .cjs suite (Node-only by design).