@jskit-ai/uploads-runtime 0.1.181 → 0.1.183

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/uploads-runtime",
3
- "version": "0.1.181",
3
+ "version": "0.1.183",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -15,7 +15,7 @@
15
15
  "./server/storage/createUploadStorageService": "./src/server/storage/createUploadStorageService.js"
16
16
  },
17
17
  "dependencies": {
18
- "@fastify/multipart": "^9.4.0"
18
+ "@fastify/multipart": "^10.1.1"
19
19
  },
20
20
  "description": "Reusable upload runtime primitives for multipart parsing, policy validation, and blob storage.",
21
21
  "jskit": {
@@ -77,6 +77,6 @@
77
77
  }
78
78
  },
79
79
  "peerDependencies": {
80
- "@jskit-ai/kernel": "0.1.206"
80
+ "@jskit-ai/kernel": "0.1.208"
81
81
  }
82
82
  }
@@ -1,7 +1,45 @@
1
1
  import test from "node:test";
2
2
  import assert from "node:assert/strict";
3
+ import Fastify from "fastify";
3
4
  import { registerMultipartSupport } from "../src/server/multipart/registerMultipartSupport.js";
4
5
 
6
+ test("registerMultipartSupport parses an upload through real Fastify", async (t) => {
7
+ const app = Fastify();
8
+ t.after(() => app.close());
9
+ await registerMultipartSupport(app);
10
+ await registerMultipartSupport(app);
11
+ app.post("/upload", async (request) => {
12
+ const file = await request.file();
13
+ return {
14
+ fieldname: file.fieldname,
15
+ filename: file.filename,
16
+ mimetype: file.mimetype,
17
+ contents: (await file.toBuffer()).toString("utf8")
18
+ };
19
+ });
20
+ const response = await app.inject({
21
+ method: "POST",
22
+ url: "/upload",
23
+ headers: { "content-type": "multipart/form-data; boundary=jskit-upload" },
24
+ payload: [
25
+ "--jskit-upload",
26
+ 'Content-Disposition: form-data; name="file"; filename="example.txt"',
27
+ "Content-Type: text/plain",
28
+ "",
29
+ "Uploaded through JSKIT",
30
+ "--jskit-upload--",
31
+ ""
32
+ ].join("\r\n")
33
+ });
34
+ assert.equal(response.statusCode, 200);
35
+ assert.deepEqual(response.json(), {
36
+ fieldname: "file",
37
+ filename: "example.txt",
38
+ mimetype: "text/plain",
39
+ contents: "Uploaded through JSKIT"
40
+ });
41
+ });
42
+
5
43
  test("registerMultipartSupport requires the explicit Fastify dependency", async () => {
6
44
  await assert.rejects(registerMultipartSupport(null), /requires Fastify/u);
7
45
  });