vite-plugin-mock-dev-server 0.3.11 → 0.3.13

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/index.cjs CHANGED
@@ -328,23 +328,26 @@ async function parseReqBody(req, options) {
328
328
  if (["GET", "DELETE", "HEAD"].includes(method))
329
329
  return void 0;
330
330
  const type = req.headers["content-type"];
331
- if (type === "application/json") {
332
- return await import_co_body.default.json(req);
333
- }
334
- if (type === "application/x-www-form-urlencoded") {
335
- return await import_co_body.default.form(req);
336
- }
337
- if (type === "text/plain") {
338
- return await import_co_body.default.text(req);
339
- }
340
- if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
341
- return await parseMultipart(req, options);
331
+ try {
332
+ if (type === "application/json") {
333
+ return await import_co_body.default.json(req);
334
+ }
335
+ if (type === "application/x-www-form-urlencoded") {
336
+ return await import_co_body.default.form(req);
337
+ }
338
+ if (type === "text/plain") {
339
+ return await import_co_body.default.text(req);
340
+ }
341
+ if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
342
+ return await parseMultipart(req, options);
343
+ }
344
+ } catch (e) {
345
+ console.error(e);
342
346
  }
343
347
  return void 0;
344
348
  }
345
349
  async function parseMultipart(req, options) {
346
350
  const form = (0, import_formidable.default)(options);
347
- debug("multiparty start");
348
351
  return new Promise((resolve, reject) => {
349
352
  form.parse(req, (error, fields, files) => {
350
353
  if (error) {
package/dist/index.js CHANGED
@@ -293,23 +293,26 @@ async function parseReqBody(req, options) {
293
293
  if (["GET", "DELETE", "HEAD"].includes(method))
294
294
  return void 0;
295
295
  const type = req.headers["content-type"];
296
- if (type === "application/json") {
297
- return await bodyParser.json(req);
298
- }
299
- if (type === "application/x-www-form-urlencoded") {
300
- return await bodyParser.form(req);
301
- }
302
- if (type === "text/plain") {
303
- return await bodyParser.text(req);
304
- }
305
- if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
306
- return await parseMultipart(req, options);
296
+ try {
297
+ if (type === "application/json") {
298
+ return await bodyParser.json(req);
299
+ }
300
+ if (type === "application/x-www-form-urlencoded") {
301
+ return await bodyParser.form(req);
302
+ }
303
+ if (type === "text/plain") {
304
+ return await bodyParser.text(req);
305
+ }
306
+ if (type == null ? void 0 : type.startsWith("multipart/form-data;")) {
307
+ return await parseMultipart(req, options);
308
+ }
309
+ } catch (e) {
310
+ console.error(e);
307
311
  }
308
312
  return void 0;
309
313
  }
310
314
  async function parseMultipart(req, options) {
311
315
  const form = formidable(options);
312
- debug("multiparty start");
313
316
  return new Promise((resolve, reject) => {
314
317
  form.parse(req, (error, fields, files) => {
315
318
  if (error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-mock-dev-server",
3
- "version": "0.3.11",
3
+ "version": "0.3.13",
4
4
  "keywords": [
5
5
  "vite",
6
6
  "plugin",
@@ -49,7 +49,7 @@
49
49
  "debug": "^4.3.4",
50
50
  "esbuild": "^0.16.9",
51
51
  "fast-glob": "^3.2.12",
52
- "formidable": "v3",
52
+ "formidable": "^2.1.1",
53
53
  "json5": "^2.2.2",
54
54
  "path-to-regexp": "^6.2.1"
55
55
  },