@sigil-dev/grimoire 0.9.30 → 0.9.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -4
- package/src/server/coordinator.ts +3 -0
- package/src/server/index.ts +1181 -1179
- package/src/types.ts +642 -629
- package/test/server.test.ts +19 -0
package/test/server.test.ts
CHANGED
|
@@ -107,6 +107,25 @@ describe("Server — API routes (+server.ts)", () => {
|
|
|
107
107
|
server.stop();
|
|
108
108
|
});
|
|
109
109
|
|
|
110
|
+
test("maxRequestBodySize caps request bodies", async () => {
|
|
111
|
+
const server = await createServer({
|
|
112
|
+
port: 3004,
|
|
113
|
+
routes: tmpDir,
|
|
114
|
+
_skipBuild: true,
|
|
115
|
+
maxRequestBodySize: 1024,
|
|
116
|
+
});
|
|
117
|
+
const post = (size: number) =>
|
|
118
|
+
fetch("http://localhost:3004/api/items", {
|
|
119
|
+
method: "POST",
|
|
120
|
+
headers: { "Content-Type": "application/json" },
|
|
121
|
+
body: JSON.stringify({ name: "x".repeat(size) }),
|
|
122
|
+
}).catch(() => null);
|
|
123
|
+
expect((await post(100))?.status).toBe(201);
|
|
124
|
+
// Bun answers 413 or drops the connection, depending on how far it got
|
|
125
|
+
expect((await post(64 * 1024))?.status ?? 413).toBe(413);
|
|
126
|
+
server.stop();
|
|
127
|
+
});
|
|
128
|
+
|
|
110
129
|
test("unsupported method returns 405", async () => {
|
|
111
130
|
const server = await createServer({
|
|
112
131
|
port: 3004,
|