@domain.js/main 1.1.2 → 1.1.3
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/dist/http/index.js +7 -1
- package/package.json +1 -1
package/dist/http/index.js
CHANGED
|
@@ -24,9 +24,15 @@ function Main(cnf, deps) {
|
|
|
24
24
|
// Send error response
|
|
25
25
|
reply.code(statusCode).send({ code, message, data });
|
|
26
26
|
});
|
|
27
|
+
const bodyLimit = cnf.bodyMaxBytes || 10 * 1024 * 1024;
|
|
28
|
+
// 仅注册 MIME,使 Fastify 接受 XML 类 Content-Type(否则会 FST_ERR_CTP_INVALID_MEDIA_TYPE)。
|
|
29
|
+
// parseAs: "string" 只是把请求体读成原始字符串,不做 XML 结构化解析;解析由业务层按需进行。
|
|
30
|
+
server.addContentTypeParser(["application/xml", "text/xml", "application/rss+xml", "application/atom+xml"], { parseAs: "string", bodyLimit }, (_req, body, done) => {
|
|
31
|
+
done(null, body);
|
|
32
|
+
});
|
|
27
33
|
server.register(multipart_1.default, {
|
|
28
34
|
limits: {
|
|
29
|
-
fileSize:
|
|
35
|
+
fileSize: bodyLimit, // 参数最大容量 10MB
|
|
30
36
|
},
|
|
31
37
|
});
|
|
32
38
|
server.register(formbody_1.default);
|