@midwayjs/core 3.4.0-beta.10 → 3.4.0-beta.11

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.
@@ -238,7 +238,7 @@ class BaseFramework {
238
238
  const asyncContextManagerEnabled = this.configService.getConfiguration('asyncContextManager.enable') ||
239
239
  false;
240
240
  const contextManager = asyncContextManagerEnabled
241
- ? ((_a = this.bootstrapOptions) === null || _a === void 0 ? void 0 : _a.contextManager) || new asyncContextManager_1.NoopContextManager()
241
+ ? ((_a = this.bootstrapOptions) === null || _a === void 0 ? void 0 : _a.asyncContextManager) || new asyncContextManager_1.NoopContextManager()
242
242
  : new asyncContextManager_1.NoopContextManager();
243
243
  if (asyncContextManagerEnabled) {
244
244
  contextManager.enable();
@@ -22,7 +22,7 @@ export declare class MidwayError extends Error {
22
22
  }
23
23
  export declare type ResOrMessage = string | {
24
24
  message: string;
25
- };
25
+ } | undefined;
26
26
  export declare class MidwayHttpError extends MidwayError {
27
27
  status: number;
28
28
  constructor(resOrMessage: ResOrMessage, status: number);
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.MidwayHttpError = exports.MidwayError = exports.registerErrorCode = void 0;
4
+ const http_1 = require("http");
4
5
  const codeGroup = new Set();
5
6
  /**
6
7
  * Register error group and code, return the standard ErrorCode
@@ -40,7 +41,11 @@ class MidwayError extends Error {
40
41
  exports.MidwayError = MidwayError;
41
42
  class MidwayHttpError extends MidwayError {
42
43
  constructor(resOrMessage, status, code, options) {
43
- super(typeof resOrMessage === 'string' ? resOrMessage : resOrMessage.message, code !== null && code !== void 0 ? code : String(status), options);
44
+ super(resOrMessage
45
+ ? typeof resOrMessage === 'string'
46
+ ? resOrMessage
47
+ : resOrMessage.message
48
+ : http_1.STATUS_CODES[status], code !== null && code !== void 0 ? code : String(status), options);
44
49
  this.status = status;
45
50
  }
46
51
  }
@@ -57,7 +57,7 @@ var HttpStatus;
57
57
  * 400 http error, Means that the request can be fulfilled because of the bad syntax.
58
58
  */
59
59
  class BadRequestError extends base_1.MidwayHttpError {
60
- constructor(resOrMessage = 'Bad Request') {
60
+ constructor(resOrMessage) {
61
61
  super(resOrMessage, HttpStatus.BAD_REQUEST);
62
62
  }
63
63
  }
@@ -66,7 +66,7 @@ exports.BadRequestError = BadRequestError;
66
66
  * 401 http error, Means that the request was legal, but the server is rejecting to answer it. For the use when authentication is required and has failed or has not yet been provided.
67
67
  */
68
68
  class UnauthorizedError extends base_1.MidwayHttpError {
69
- constructor(resOrMessage = 'Unauthorized') {
69
+ constructor(resOrMessage) {
70
70
  super(resOrMessage, HttpStatus.UNAUTHORIZED);
71
71
  }
72
72
  }
@@ -75,7 +75,7 @@ exports.UnauthorizedError = UnauthorizedError;
75
75
  * 4o4 http error, Means that the requested page cannot be found at the moment, but it may be available again in the future.
76
76
  */
77
77
  class NotFoundError extends base_1.MidwayHttpError {
78
- constructor(resOrMessage = 'Not Found') {
78
+ constructor(resOrMessage) {
79
79
  super(resOrMessage, HttpStatus.NOT_FOUND);
80
80
  }
81
81
  }
@@ -84,7 +84,7 @@ exports.NotFoundError = NotFoundError;
84
84
  * 403 http error, Means that the request is legal, but the server is rejecting to answer it.
85
85
  */
86
86
  class ForbiddenError extends base_1.MidwayHttpError {
87
- constructor(resOrMessage = 'Forbidden') {
87
+ constructor(resOrMessage) {
88
88
  super(resOrMessage, HttpStatus.FORBIDDEN);
89
89
  }
90
90
  }
@@ -93,7 +93,7 @@ exports.ForbiddenError = ForbiddenError;
93
93
  * 406 http error, Means that the server can only generate an answer which the client doesn't accept.
94
94
  */
95
95
  class NotAcceptableError extends base_1.MidwayHttpError {
96
- constructor(resOrMessage = 'Not Acceptable') {
96
+ constructor(resOrMessage) {
97
97
  super(resOrMessage, HttpStatus.NOT_ACCEPTABLE);
98
98
  }
99
99
  }
@@ -102,7 +102,7 @@ exports.NotAcceptableError = NotAcceptableError;
102
102
  * 408 http error, Means that the server timed out waiting for the request.
103
103
  */
104
104
  class RequestTimeoutError extends base_1.MidwayHttpError {
105
- constructor(resOrMessage = 'Request Timeout') {
105
+ constructor(resOrMessage) {
106
106
  super(resOrMessage, HttpStatus.REQUEST_TIMEOUT);
107
107
  }
108
108
  }
@@ -111,7 +111,7 @@ exports.RequestTimeoutError = RequestTimeoutError;
111
111
  * 409 http error, Means that the request cannot be completed, because of a conflict in the request.
112
112
  */
113
113
  class ConflictError extends base_1.MidwayHttpError {
114
- constructor(resOrMessage = 'Conflict') {
114
+ constructor(resOrMessage) {
115
115
  super(resOrMessage, HttpStatus.CONFLICT);
116
116
  }
117
117
  }
@@ -120,7 +120,7 @@ exports.ConflictError = ConflictError;
120
120
  * 410 http error, Means that the requested page is not available anymore.
121
121
  */
122
122
  class GoneError extends base_1.MidwayHttpError {
123
- constructor(resOrMessage = 'Gone') {
123
+ constructor(resOrMessage) {
124
124
  super(resOrMessage, HttpStatus.GONE);
125
125
  }
126
126
  }
@@ -129,7 +129,7 @@ exports.GoneError = GoneError;
129
129
  * 413 http error, Means that the request entity is too large and that's why the server won't accept the request.
130
130
  */
131
131
  class PayloadTooLargeError extends base_1.MidwayHttpError {
132
- constructor(resOrMessage = 'Request Entity Too Large') {
132
+ constructor(resOrMessage) {
133
133
  super(resOrMessage, HttpStatus.PAYLOAD_TOO_LARGE);
134
134
  }
135
135
  }
@@ -138,13 +138,13 @@ exports.PayloadTooLargeError = PayloadTooLargeError;
138
138
  * 415 http error, Means that the media type is not supported and that's why the server won't accept the request.
139
139
  */
140
140
  class UnsupportedMediaTypeError extends base_1.MidwayHttpError {
141
- constructor(resOrMessage = 'Unsupported Media Type') {
141
+ constructor(resOrMessage) {
142
142
  super(resOrMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE);
143
143
  }
144
144
  }
145
145
  exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
146
146
  class UnprocessableEntityError extends base_1.MidwayHttpError {
147
- constructor(resOrMessage = 'Unprocessable Entity') {
147
+ constructor(resOrMessage) {
148
148
  super(resOrMessage, HttpStatus.UNPROCESSABLE_ENTITY);
149
149
  }
150
150
  }
@@ -153,7 +153,7 @@ exports.UnprocessableEntityError = UnprocessableEntityError;
153
153
  * 500 http error, Is a generic error and users receive this error message when there is no more suitable specific message.
154
154
  */
155
155
  class InternalServerErrorError extends base_1.MidwayHttpError {
156
- constructor(resOrMessage = 'Internal Server Error') {
156
+ constructor(resOrMessage) {
157
157
  super(resOrMessage, HttpStatus.INTERNAL_SERVER_ERROR);
158
158
  }
159
159
  }
@@ -162,7 +162,7 @@ exports.InternalServerErrorError = InternalServerErrorError;
162
162
  * 501 http error, Means that the server doesn't recognize the request method or it lacks the ability to fulfill the request.
163
163
  */
164
164
  class NotImplementedError extends base_1.MidwayHttpError {
165
- constructor(resOrMessage = 'Not Implemented') {
165
+ constructor(resOrMessage) {
166
166
  super(resOrMessage, HttpStatus.NOT_IMPLEMENTED);
167
167
  }
168
168
  }
@@ -171,7 +171,7 @@ exports.NotImplementedError = NotImplementedError;
171
171
  * 502 http error, Means that the server was acting as a gateway or proxy and it received an invalid answer from the upstream server.
172
172
  */
173
173
  class BadGatewayError extends base_1.MidwayHttpError {
174
- constructor(resOrMessage = 'Bad Gateway') {
174
+ constructor(resOrMessage) {
175
175
  super(resOrMessage, HttpStatus.BAD_GATEWAY);
176
176
  }
177
177
  }
@@ -180,7 +180,7 @@ exports.BadGatewayError = BadGatewayError;
180
180
  * 503 http error, Means that the server is not available now (It may be overloaded or down).
181
181
  */
182
182
  class ServiceUnavailableError extends base_1.MidwayHttpError {
183
- constructor(resOrMessage = 'Service Unavailable') {
183
+ constructor(resOrMessage) {
184
184
  super(resOrMessage, HttpStatus.SERVICE_UNAVAILABLE);
185
185
  }
186
186
  }
@@ -189,7 +189,7 @@ exports.ServiceUnavailableError = ServiceUnavailableError;
189
189
  * 504 http error, Means that the server was acting as a gateway or proxy and it didn't get answer on time from the upstream server.
190
190
  */
191
191
  class GatewayTimeoutError extends base_1.MidwayHttpError {
192
- constructor(resOrMessage = 'Gateway Timeout') {
192
+ constructor(resOrMessage) {
193
193
  super(resOrMessage, HttpStatus.GATEWAY_TIMEOUT);
194
194
  }
195
195
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.4.0-beta.10",
3
+ "version": "3.4.0-beta.11",
4
4
  "description": "midway core",
5
5
  "main": "dist/index",
6
6
  "typings": "dist/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  ],
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
- "@midwayjs/decorator": "^3.4.0-beta.10",
24
+ "@midwayjs/decorator": "^3.4.0-beta.11",
25
25
  "koa": "2.13.4",
26
26
  "midway-test-component": "*",
27
27
  "mm": "3.2.0",
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "560a5fa311605e4008c55f31c31bc4e12eeff2a5"
48
+ "gitHead": "b1c7a439b0df37d3e381cd182ea3b9e74323107b"
49
49
  }