@midwayjs/core 3.0.0-beta.12 → 3.0.0-beta.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/CHANGELOG.md CHANGED
@@ -3,6 +3,18 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [3.0.0-beta.13](https://github.com/midwayjs/midway/compare/v3.0.0-beta.12...v3.0.0-beta.13) (2021-12-30)
7
+
8
+
9
+ ### Features
10
+
11
+ * 404 error ([#1465](https://github.com/midwayjs/midway/issues/1465)) ([e7e8a9d](https://github.com/midwayjs/midway/commit/e7e8a9dedfa7198ac05b161b41024c2871f93965))
12
+ * add custom decorator filter ([#1477](https://github.com/midwayjs/midway/issues/1477)) ([97501a9](https://github.com/midwayjs/midway/commit/97501a989abc211b0c7400b1df45e050bb237c6a))
13
+
14
+
15
+
16
+
17
+
6
18
  # [3.0.0-beta.12](https://github.com/midwayjs/midway/compare/v3.0.0-beta.11...v3.0.0-beta.12) (2021-12-28)
7
19
 
8
20
 
@@ -49,53 +49,98 @@ export declare enum HttpStatus {
49
49
  GATEWAY_TIMEOUT = 504,
50
50
  HTTP_VERSION_NOT_SUPPORTED = 505
51
51
  }
52
+ /**
53
+ * 400 http error, Means that the request can be fulfilled because of the bad syntax.
54
+ */
52
55
  export declare class BadRequestError extends MidwayHttpError {
53
- constructor(resOrMessage: ResOrMessage);
56
+ constructor(resOrMessage?: ResOrMessage);
54
57
  }
58
+ /**
59
+ * 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.
60
+ */
55
61
  export declare class UnauthorizedError extends MidwayHttpError {
56
- constructor(resOrMessage: ResOrMessage);
62
+ constructor(resOrMessage?: ResOrMessage);
57
63
  }
64
+ /**
65
+ * 4o4 http error, Means that the requested page cannot be found at the moment, but it may be available again in the future.
66
+ */
58
67
  export declare class NotFoundError extends MidwayHttpError {
59
- constructor(resOrMessage: ResOrMessage);
68
+ constructor(resOrMessage?: ResOrMessage);
60
69
  }
70
+ /**
71
+ * 403 http error, Means that the request is legal, but the server is rejecting to answer it.
72
+ */
61
73
  export declare class ForbiddenError extends MidwayHttpError {
62
- constructor(resOrMessage: ResOrMessage);
74
+ constructor(resOrMessage?: ResOrMessage);
63
75
  }
76
+ /**
77
+ * 406 http error, Means that the server can only generate an answer which the client doesn't accept.
78
+ */
64
79
  export declare class NotAcceptableError extends MidwayHttpError {
65
- constructor(resOrMessage: ResOrMessage);
80
+ constructor(resOrMessage?: ResOrMessage);
66
81
  }
82
+ /**
83
+ * 408 http error, Means that the server timed out waiting for the request.
84
+ */
67
85
  export declare class RequestTimeoutError extends MidwayHttpError {
68
- constructor(resOrMessage: ResOrMessage);
86
+ constructor(resOrMessage?: ResOrMessage);
69
87
  }
88
+ /**
89
+ * 409 http error, Means that the request cannot be completed, because of a conflict in the request.
90
+ */
70
91
  export declare class ConflictError extends MidwayHttpError {
71
- constructor(resOrMessage: ResOrMessage);
92
+ constructor(resOrMessage?: ResOrMessage);
72
93
  }
94
+ /**
95
+ * 410 http error, Means that the requested page is not available anymore.
96
+ */
73
97
  export declare class GoneError extends MidwayHttpError {
74
- constructor(resOrMessage: ResOrMessage);
98
+ constructor(resOrMessage?: ResOrMessage);
75
99
  }
100
+ /**
101
+ * 413 http error, Means that the request entity is too large and that's why the server won't accept the request.
102
+ */
76
103
  export declare class PayloadTooLargeError extends MidwayHttpError {
77
- constructor(resOrMessage: ResOrMessage);
104
+ constructor(resOrMessage?: ResOrMessage);
78
105
  }
106
+ /**
107
+ * 415 http error, Means that the media type is not supported and that's why the server won't accept the request.
108
+ */
79
109
  export declare class UnsupportedMediaTypeError extends MidwayHttpError {
80
- constructor(resOrMessage: ResOrMessage);
110
+ constructor(resOrMessage?: ResOrMessage);
81
111
  }
82
112
  export declare class UnprocessableError extends MidwayHttpError {
83
- constructor(resOrMessage: ResOrMessage);
113
+ constructor(resOrMessage?: ResOrMessage);
84
114
  }
115
+ /**
116
+ * 500 http error, Is a generic error and users receive this error message when there is no more suitable specific message.
117
+ */
85
118
  export declare class InternalServerErrorError extends MidwayHttpError {
86
- constructor(resOrMessage: ResOrMessage);
119
+ constructor(resOrMessage?: ResOrMessage);
87
120
  }
121
+ /**
122
+ * 501 http error, Means that the server doesn't recognize the request method or it lacks the ability to fulfill the request.
123
+ */
88
124
  declare class NotImplementedError extends MidwayHttpError {
89
- constructor(resOrMessage: ResOrMessage);
125
+ constructor(resOrMessage?: ResOrMessage);
90
126
  }
127
+ /**
128
+ * 502 http error, Means that the server was acting as a gateway or proxy and it received an invalid answer from the upstream server.
129
+ */
91
130
  export declare class BadGatewayError extends MidwayHttpError {
92
- constructor(resOrMessage: ResOrMessage);
131
+ constructor(resOrMessage?: ResOrMessage);
93
132
  }
133
+ /**
134
+ * 503 http error, Means that the server is not available now (It may be overloaded or down).
135
+ */
94
136
  export declare class ServiceUnavailableError extends MidwayHttpError {
95
- constructor(resOrMessage: ResOrMessage);
137
+ constructor(resOrMessage?: ResOrMessage);
96
138
  }
139
+ /**
140
+ * 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.
141
+ */
97
142
  export declare class GatewayTimeoutError extends MidwayHttpError {
98
- constructor(resOrMessage: ResOrMessage);
143
+ constructor(resOrMessage?: ResOrMessage);
99
144
  }
100
145
  export declare const httpError: {
101
146
  BadRequestError: typeof BadRequestError;
@@ -53,97 +53,142 @@ var HttpStatus;
53
53
  HttpStatus[HttpStatus["GATEWAY_TIMEOUT"] = 504] = "GATEWAY_TIMEOUT";
54
54
  HttpStatus[HttpStatus["HTTP_VERSION_NOT_SUPPORTED"] = 505] = "HTTP_VERSION_NOT_SUPPORTED";
55
55
  })(HttpStatus = exports.HttpStatus || (exports.HttpStatus = {}));
56
+ /**
57
+ * 400 http error, Means that the request can be fulfilled because of the bad syntax.
58
+ */
56
59
  class BadRequestError extends base_1.MidwayHttpError {
57
- constructor(resOrMessage) {
60
+ constructor(resOrMessage = 'Bad Request') {
58
61
  super(resOrMessage, HttpStatus.BAD_REQUEST);
59
62
  }
60
63
  }
61
64
  exports.BadRequestError = BadRequestError;
65
+ /**
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
+ */
62
68
  class UnauthorizedError extends base_1.MidwayHttpError {
63
- constructor(resOrMessage) {
69
+ constructor(resOrMessage = 'Unauthorized') {
64
70
  super(resOrMessage, HttpStatus.UNAUTHORIZED);
65
71
  }
66
72
  }
67
73
  exports.UnauthorizedError = UnauthorizedError;
74
+ /**
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
+ */
68
77
  class NotFoundError extends base_1.MidwayHttpError {
69
- constructor(resOrMessage) {
78
+ constructor(resOrMessage = 'Not Found') {
70
79
  super(resOrMessage, HttpStatus.NOT_FOUND);
71
80
  }
72
81
  }
73
82
  exports.NotFoundError = NotFoundError;
83
+ /**
84
+ * 403 http error, Means that the request is legal, but the server is rejecting to answer it.
85
+ */
74
86
  class ForbiddenError extends base_1.MidwayHttpError {
75
- constructor(resOrMessage) {
87
+ constructor(resOrMessage = 'Forbidden') {
76
88
  super(resOrMessage, HttpStatus.FORBIDDEN);
77
89
  }
78
90
  }
79
91
  exports.ForbiddenError = ForbiddenError;
92
+ /**
93
+ * 406 http error, Means that the server can only generate an answer which the client doesn't accept.
94
+ */
80
95
  class NotAcceptableError extends base_1.MidwayHttpError {
81
- constructor(resOrMessage) {
96
+ constructor(resOrMessage = 'Not Acceptable') {
82
97
  super(resOrMessage, HttpStatus.NOT_ACCEPTABLE);
83
98
  }
84
99
  }
85
100
  exports.NotAcceptableError = NotAcceptableError;
101
+ /**
102
+ * 408 http error, Means that the server timed out waiting for the request.
103
+ */
86
104
  class RequestTimeoutError extends base_1.MidwayHttpError {
87
- constructor(resOrMessage) {
105
+ constructor(resOrMessage = 'Request Timeout') {
88
106
  super(resOrMessage, HttpStatus.REQUEST_TIMEOUT);
89
107
  }
90
108
  }
91
109
  exports.RequestTimeoutError = RequestTimeoutError;
110
+ /**
111
+ * 409 http error, Means that the request cannot be completed, because of a conflict in the request.
112
+ */
92
113
  class ConflictError extends base_1.MidwayHttpError {
93
- constructor(resOrMessage) {
114
+ constructor(resOrMessage = 'Conflict') {
94
115
  super(resOrMessage, HttpStatus.CONFLICT);
95
116
  }
96
117
  }
97
118
  exports.ConflictError = ConflictError;
119
+ /**
120
+ * 410 http error, Means that the requested page is not available anymore.
121
+ */
98
122
  class GoneError extends base_1.MidwayHttpError {
99
- constructor(resOrMessage) {
123
+ constructor(resOrMessage = 'Gone') {
100
124
  super(resOrMessage, HttpStatus.GONE);
101
125
  }
102
126
  }
103
127
  exports.GoneError = GoneError;
128
+ /**
129
+ * 413 http error, Means that the request entity is too large and that's why the server won't accept the request.
130
+ */
104
131
  class PayloadTooLargeError extends base_1.MidwayHttpError {
105
- constructor(resOrMessage) {
132
+ constructor(resOrMessage = 'Request Entity Too Large') {
106
133
  super(resOrMessage, HttpStatus.PAYLOAD_TOO_LARGE);
107
134
  }
108
135
  }
109
136
  exports.PayloadTooLargeError = PayloadTooLargeError;
137
+ /**
138
+ * 415 http error, Means that the media type is not supported and that's why the server won't accept the request.
139
+ */
110
140
  class UnsupportedMediaTypeError extends base_1.MidwayHttpError {
111
- constructor(resOrMessage) {
141
+ constructor(resOrMessage = 'Unsupported Media Type') {
112
142
  super(resOrMessage, HttpStatus.UNSUPPORTED_MEDIA_TYPE);
113
143
  }
114
144
  }
115
145
  exports.UnsupportedMediaTypeError = UnsupportedMediaTypeError;
116
146
  class UnprocessableError extends base_1.MidwayHttpError {
117
- constructor(resOrMessage) {
147
+ constructor(resOrMessage = 'Unprocessable Entity') {
118
148
  super(resOrMessage, HttpStatus.UNPROCESSABLE_ENTITY);
119
149
  }
120
150
  }
121
151
  exports.UnprocessableError = UnprocessableError;
152
+ /**
153
+ * 500 http error, Is a generic error and users receive this error message when there is no more suitable specific message.
154
+ */
122
155
  class InternalServerErrorError extends base_1.MidwayHttpError {
123
- constructor(resOrMessage) {
156
+ constructor(resOrMessage = 'Internal Server Error') {
124
157
  super(resOrMessage, HttpStatus.INTERNAL_SERVER_ERROR);
125
158
  }
126
159
  }
127
160
  exports.InternalServerErrorError = InternalServerErrorError;
161
+ /**
162
+ * 501 http error, Means that the server doesn't recognize the request method or it lacks the ability to fulfill the request.
163
+ */
128
164
  class NotImplementedError extends base_1.MidwayHttpError {
129
- constructor(resOrMessage) {
165
+ constructor(resOrMessage = 'Not Implemented') {
130
166
  super(resOrMessage, HttpStatus.NOT_IMPLEMENTED);
131
167
  }
132
168
  }
169
+ /**
170
+ * 502 http error, Means that the server was acting as a gateway or proxy and it received an invalid answer from the upstream server.
171
+ */
133
172
  class BadGatewayError extends base_1.MidwayHttpError {
134
- constructor(resOrMessage) {
173
+ constructor(resOrMessage = 'Bad Gateway') {
135
174
  super(resOrMessage, HttpStatus.BAD_GATEWAY);
136
175
  }
137
176
  }
138
177
  exports.BadGatewayError = BadGatewayError;
178
+ /**
179
+ * 503 http error, Means that the server is not available now (It may be overloaded or down).
180
+ */
139
181
  class ServiceUnavailableError extends base_1.MidwayHttpError {
140
- constructor(resOrMessage) {
182
+ constructor(resOrMessage = 'Service Unavailable') {
141
183
  super(resOrMessage, HttpStatus.SERVICE_UNAVAILABLE);
142
184
  }
143
185
  }
144
186
  exports.ServiceUnavailableError = ServiceUnavailableError;
187
+ /**
188
+ * 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.
189
+ */
145
190
  class GatewayTimeoutError extends base_1.MidwayHttpError {
146
- constructor(resOrMessage) {
191
+ constructor(resOrMessage = 'Gateway Timeout') {
147
192
  super(resOrMessage, HttpStatus.GATEWAY_TIMEOUT);
148
193
  }
149
194
  }
@@ -30,7 +30,10 @@ let MidwayDecoratorService = class MidwayDecoratorService {
30
30
  if (methodDecoratorMetadataList) {
31
31
  // loop it, save this order for decorator run
32
32
  for (const meta of methodDecoratorMetadataList) {
33
- const { propertyName, key, metadata } = meta;
33
+ const { propertyName, key, metadata, impl } = meta;
34
+ if (!impl) {
35
+ continue;
36
+ }
34
37
  // add aspect implementation first
35
38
  this.aspectService.interceptPrototypeMethod(Clzz, propertyName, () => {
36
39
  const methodDecoratorHandler = this.methodDecoratorMap.get(key);
@@ -57,7 +60,10 @@ let MidwayDecoratorService = class MidwayDecoratorService {
57
60
  // joinPoint.args
58
61
  const newArgs = [...joinPoint.args];
59
62
  for (const meta of parameterDecoratorMetadata[methodName]) {
60
- const { propertyName, key, metadata, parameterIndex } = meta;
63
+ const { propertyName, key, metadata, parameterIndex, impl } = meta;
64
+ if (!impl) {
65
+ continue;
66
+ }
61
67
  const parameterDecoratorHandler = this.parameterDecoratorMap.get(key);
62
68
  if (!parameterDecoratorHandler) {
63
69
  throw new error_1.MidwayCommonError(`Parameter Decorator "${key}" handler not found, please register first.`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midwayjs/core",
3
- "version": "3.0.0-beta.12",
3
+ "version": "3.0.0-beta.13",
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.0.0-beta.12",
24
+ "@midwayjs/decorator": "^3.0.0-beta.13",
25
25
  "koa": "^2.13.4",
26
26
  "midway-test-component": "*",
27
27
  "mm": "3",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@midwayjs/glob": "^1.0.2",
35
- "@midwayjs/logger": "^3.0.0-beta.12",
35
+ "@midwayjs/logger": "^3.0.0-beta.13",
36
36
  "class-transformer": "^0.5.1",
37
37
  "extend2": "^1.0.0",
38
38
  "picomatch": "^2.3.0"
@@ -45,5 +45,5 @@
45
45
  "engines": {
46
46
  "node": ">=12"
47
47
  },
48
- "gitHead": "1c46e53eb934248007eeb7fe3920f5ac24e272c6"
48
+ "gitHead": "d3c47770fee9dce33a8d148882173fd7782864ad"
49
49
  }