@jskit-ai/uploads-runtime 0.1.220 → 0.1.221

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.220",
3
+ "version": "0.1.221",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test --test-concurrency=1"
@@ -77,6 +77,6 @@
77
77
  }
78
78
  },
79
79
  "peerDependencies": {
80
- "@jskit-ai/kernel": "0.1.245"
80
+ "@jskit-ai/kernel": "0.1.246"
81
81
  }
82
82
  }
@@ -1,26 +1,21 @@
1
1
  import fastifyMultipart from "@fastify/multipart";
2
2
 
3
+ const MULTIPART_MARKER = "jskit.uploads-runtime.multipart.support";
4
+
3
5
  async function registerMultipartSupport(fastify) {
4
6
  if (!fastify || typeof fastify.register !== "function") {
5
7
  throw new Error("registerMultipartSupport requires Fastify.");
6
8
  }
7
9
 
8
- if (fastify["jskit.uploads-runtime.multipart.support"] === true) {
10
+ if (fastify[MULTIPART_MARKER] === true) {
9
11
  return;
10
12
  }
11
13
 
12
- if (typeof fastify.hasContentTypeParser === "function" && fastify.hasContentTypeParser("multipart")) {
13
- Object.defineProperty(fastify, "jskit.uploads-runtime.multipart.support", {
14
- value: true,
15
- configurable: false,
16
- enumerable: false,
17
- writable: false
18
- });
19
- return;
14
+ const hasMultipartParser = typeof fastify.hasContentTypeParser === "function" && fastify.hasContentTypeParser("multipart");
15
+ if (!hasMultipartParser) {
16
+ await fastify.register(fastifyMultipart);
20
17
  }
21
-
22
- await fastify.register(fastifyMultipart);
23
- Object.defineProperty(fastify, "jskit.uploads-runtime.multipart.support", {
18
+ Object.defineProperty(fastify, MULTIPART_MARKER, {
24
19
  value: true,
25
20
  configurable: false,
26
21
  enumerable: false,