@shuvi/platform-web 1.0.50 → 1.0.52

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.
@@ -74,9 +74,7 @@ export class ReactServerView {
74
74
  }
75
75
  catch (error) {
76
76
  renderToStringTrace.setAttribute(SHUVI_SERVER_RENDER_TO_STRING.attrs.error.name, true);
77
- if (process.env.NODE_ENV === 'development') {
78
- logger.error(error.stack);
79
- }
77
+ logger.error(error.stack);
80
78
  setAppError(serializeServerError(error));
81
79
  htmlContent = renderToString(RootApp); // Consistency on both server and client side
82
80
  }
@@ -38,7 +38,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
38
38
  exports.ApiError = exports.sendJson = exports.sendData = exports.redirect = exports.sendStatusCode = exports.parseBody = exports.apiRouteHandler = void 0;
39
39
  const stream_1 = require("stream");
40
40
  const querystring = __importStar(require("querystring"));
41
- const getRawBody = require('raw-body');
41
+ const raw_body_1 = __importDefault(require("raw-body"));
42
42
  const contentType = __importStar(require("content-type"));
43
43
  const logger_1 = __importDefault(require("@shuvi/utils/logger"));
44
44
  function apiRouteHandler(req, res, resolver, apiRoutesConfig) {
@@ -47,7 +47,7 @@ function apiRouteHandler(req, res, resolver, apiRoutesConfig) {
47
47
  const { bodyParser } = apiRoutesConfig || {};
48
48
  const apiReq = {};
49
49
  // Parsing of body
50
- if (bodyParser && !apiReq.body) {
50
+ if (bodyParser && !req.body) {
51
51
  apiReq.body = yield parseBody(req, bodyParser && bodyParser.sizeLimit ? bodyParser.sizeLimit : '1mb');
52
52
  }
53
53
  const apiRes = {
@@ -92,7 +92,7 @@ function parseBody(req, limit) {
92
92
  const encoding = (parameters.charset && parameters.charset.toLowerCase()) || 'utf-8';
93
93
  let buffer;
94
94
  try {
95
- buffer = yield getRawBody(req, { encoding, limit });
95
+ buffer = yield (0, raw_body_1.default)(req, { encoding, limit });
96
96
  }
97
97
  catch (e) {
98
98
  if (e.type === 'entity.too.large') {
@@ -31,33 +31,32 @@ function middleware(_ctx) {
31
31
  break;
32
32
  }
33
33
  }
34
- if (tempApiModule) {
35
- const { serverRequestTrace } = req._traces;
36
- const runApiMiddlewareTrace = serverRequestTrace.traceChild(SHUVI_SERVER_RUN_API_MIDDLEWARE.name, {
37
- [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.requestId.name]: req._requestId
38
- });
39
- try {
40
- const { config, default: resolver } = tempApiModule;
41
- yield (0, apiRouteHandler_1.apiRouteHandler)(req, res, resolver, (config === null || config === void 0 ? void 0 : config.api) || { bodyParser: true });
42
- }
43
- catch (error) {
44
- runApiMiddlewareTrace.setAttributes({
45
- [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.error.name]: true,
46
- [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.statusCode.name]: 500
47
- });
48
- runApiMiddlewareTrace.stop();
49
- next(error);
50
- return;
51
- }
34
+ if (!tempApiModule) {
35
+ next();
36
+ return;
37
+ }
38
+ const { serverRequestTrace } = req._traces;
39
+ const runApiMiddlewareTrace = serverRequestTrace.traceChild(SHUVI_SERVER_RUN_API_MIDDLEWARE.name, {
40
+ [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.requestId.name]: req._requestId
41
+ });
42
+ try {
43
+ const { config, default: resolver } = tempApiModule;
44
+ yield (0, apiRouteHandler_1.apiRouteHandler)(req, res, resolver, (config === null || config === void 0 ? void 0 : config.api) || { bodyParser: true });
45
+ }
46
+ catch (error) {
52
47
  runApiMiddlewareTrace.setAttributes({
53
- [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.error.name]: false,
54
- [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.statusCode.name]: res.statusCode
48
+ [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.error.name]: true,
49
+ [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.statusCode.name]: 500
55
50
  });
56
51
  runApiMiddlewareTrace.stop();
52
+ next(error);
53
+ return;
57
54
  }
58
- else {
59
- next();
60
- }
55
+ runApiMiddlewareTrace.setAttributes({
56
+ [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.error.name]: false,
57
+ [SHUVI_SERVER_RUN_API_MIDDLEWARE.attrs.statusCode.name]: res.statusCode
58
+ });
59
+ runApiMiddlewareTrace.stop();
61
60
  });
62
61
  };
63
62
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/platform-web",
3
- "version": "1.0.50",
3
+ "version": "1.0.52",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -72,15 +72,15 @@
72
72
  },
73
73
  "dependencies": {
74
74
  "@next/react-refresh-utils": "12.1.6",
75
- "@shuvi/error-overlay": "1.0.50",
76
- "@shuvi/hook": "1.0.50",
77
- "@shuvi/platform-shared": "1.0.50",
78
- "@shuvi/router": "1.0.50",
79
- "@shuvi/router-react": "1.0.50",
80
- "@shuvi/runtime": "1.0.50",
81
- "@shuvi/shared": "1.0.50",
82
- "@shuvi/toolpack": "1.0.50",
83
- "@shuvi/utils": "1.0.50",
75
+ "@shuvi/error-overlay": "1.0.52",
76
+ "@shuvi/hook": "1.0.52",
77
+ "@shuvi/platform-shared": "1.0.52",
78
+ "@shuvi/router": "1.0.52",
79
+ "@shuvi/router-react": "1.0.52",
80
+ "@shuvi/runtime": "1.0.52",
81
+ "@shuvi/shared": "1.0.52",
82
+ "@shuvi/toolpack": "1.0.52",
83
+ "@shuvi/utils": "1.0.52",
84
84
  "content-type": "1.0.4",
85
85
  "core-js": "3.6.5",
86
86
  "doura": "0.0.13",
@@ -88,7 +88,7 @@
88
88
  "fs-extra": "9.0.1",
89
89
  "node-mocks-http": "1.11.0",
90
90
  "object-assign": "4.1.1",
91
- "raw-body": "2.4.1",
91
+ "raw-body": "2.5.2",
92
92
  "react": "18.2.0",
93
93
  "react-dom": "18.2.0",
94
94
  "react-doura": "0.0.13",
@@ -98,7 +98,7 @@
98
98
  "whatwg-fetch": "3.0.0"
99
99
  },
100
100
  "peerDependencies": {
101
- "@shuvi/service": "1.0.50"
101
+ "@shuvi/service": "1.0.52"
102
102
  },
103
103
  "devDependencies": {
104
104
  "@shuvi/service": "workspace:*",