Organize src/ into concern folders (http, auth, admin, plugin-host, ui); co-locate tests, move plugin-api barrel into plugin-host, sync docs + AGENTS layout

This commit is contained in:
2026-06-24 00:23:55 +02:00
parent 6d316c4888
commit de22f51c12
113 changed files with 282 additions and 265 deletions
+17
View File
@@ -0,0 +1,17 @@
import assert from "node:assert/strict";
import type { IncomingMessage } from "node:http";
import { Readable } from "node:stream";
import { test } from "node:test";
import { readFormBody } from "./body.ts";
const reqOf = (body: string): IncomingMessage => Readable.from([Buffer.from(body)]) as unknown as IncomingMessage;
test("readFormBody parses urlencoded fields, handles an empty body, and caps the size", async () => {
const form = await readFormBody(reqOf("_csrf=abc.def&name=Sam+Rivers"));
assert.equal(form.get("_csrf"), "abc.def");
assert.equal(form.get("name"), "Sam Rivers");
assert.equal([...(await readFormBody(reqOf("")))].length, 0); // empty body ⇒ no fields, no throw
await assert.rejects(() => readFormBody(reqOf("x".repeat(50)), { limit: 10 }), /limit/);
});