@domain.js/main 1.1.1 → 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.
@@ -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: cnf.bodyMaxBytes || 10 * 1024 * 1024, // 参数最大容量 10MB
35
+ fileSize: bodyLimit, // 参数最大容量 10MB
30
36
  },
31
37
  });
32
38
  server.register(formbody_1.default);
@@ -142,7 +142,6 @@ function Utils(cnf) {
142
142
  * 构造领域方法所需的 params 参数
143
143
  */
144
144
  async makeParams(req) {
145
- var _a;
146
145
  let params = { ...(req.query || {}), ...(req.params || {}) };
147
146
  if (lodash_1.default.isObject(req.body) && !Array.isArray(req.body)) {
148
147
  params = { ...(req.body || {}), ...params };
@@ -153,7 +152,7 @@ function Utils(cnf) {
153
152
  // 处理 multipart:同时解析字段与文件
154
153
  let files = {};
155
154
  try {
156
- if ((_a = req.headers["content-type"]) === null || _a === void 0 ? void 0 : _a.includes("multipart/form-data")) {
155
+ if (req.isMultipart()) {
157
156
  const fields = {};
158
157
  const parts = req.parts();
159
158
  for await (const part of parts) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {