@midwayjs/core 3.0.0-beta.1 → 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 +138 -0
- package/README.md +1 -1
- package/dist/baseFramework.d.ts +13 -10
- package/dist/baseFramework.js +32 -23
- package/dist/common/applicationManager.d.ts +12 -0
- package/dist/common/applicationManager.js +66 -0
- package/dist/{util → common}/fileDetector.d.ts +0 -0
- package/dist/{util → common}/fileDetector.js +0 -0
- package/dist/common/filterManager.d.ts +19 -0
- package/dist/common/filterManager.js +85 -0
- package/dist/common/middlewareManager.d.ts +68 -0
- package/dist/common/middlewareManager.js +183 -0
- package/dist/{util → common}/serviceFactory.d.ts +0 -0
- package/dist/{util → common}/serviceFactory.js +0 -0
- package/dist/{util → common}/triggerCollector.d.ts +0 -0
- package/dist/{util → common}/triggerCollector.js +0 -0
- package/dist/common/webGenerator.d.ts +16 -0
- package/dist/{util → common}/webGenerator.js +36 -51
- package/dist/{util → common}/webRouterCollector.d.ts +9 -4
- package/dist/{util → common}/webRouterCollector.js +53 -29
- package/dist/config/config.default.d.ts +3 -17
- package/dist/context/container.js +13 -2
- package/dist/context/managedResolverFactory.js +5 -5
- package/dist/definitions/objectCreator.js +3 -2
- package/dist/error/base.d.ts +24 -3
- package/dist/error/base.js +34 -4
- package/dist/error/framework.d.ts +26 -2
- package/dist/error/framework.js +48 -10
- package/dist/error/http.d.ts +145 -38
- package/dist/error/http.js +162 -30
- package/dist/error/index.d.ts +1 -0
- package/dist/error/index.js +1 -0
- package/dist/index.d.ts +9 -9
- package/dist/index.js +13 -11
- package/dist/interface.d.ts +59 -30
- package/dist/service/configService.js +4 -5
- package/dist/service/decoratorService.js +33 -25
- package/dist/service/frameworkService.d.ts +6 -4
- package/dist/service/frameworkService.js +26 -11
- package/dist/service/lifeCycleService.js +7 -5
- package/dist/service/loggerService.d.ts +1 -2
- package/dist/service/loggerService.js +1 -10
- package/dist/service/middlewareService.d.ts +3 -4
- package/dist/service/middlewareService.js +28 -46
- package/dist/setup.js +10 -2
- package/dist/util/contextUtil.d.ts +1 -1
- package/dist/util/index.d.ts +46 -0
- package/dist/util/index.js +150 -1
- package/dist/util/webRouterParam.d.ts +2 -2
- package/dist/util/webRouterParam.js +41 -22
- package/package.json +7 -7
- package/dist/error/code.d.ts +0 -59
- package/dist/error/code.js +0 -64
- package/dist/util/exceptionFilterManager.d.ts +0 -13
- package/dist/util/exceptionFilterManager.js +0 -53
- package/dist/util/middlewareManager.d.ts +0 -11
- package/dist/util/middlewareManager.js +0 -48
- package/dist/util/webGenerator.d.ts +0 -30
|
@@ -56,14 +56,14 @@ class ManagedResolverFactory {
|
|
|
56
56
|
resolveManaged(managed, originPropertyName) {
|
|
57
57
|
const resolver = this.resolvers[managed.type];
|
|
58
58
|
if (!resolver || resolver.type !== managed.type) {
|
|
59
|
-
throw new
|
|
59
|
+
throw new error_1.MidwayResolverMissingError(managed.type);
|
|
60
60
|
}
|
|
61
61
|
return resolver.resolve(managed, originPropertyName);
|
|
62
62
|
}
|
|
63
63
|
async resolveManagedAsync(managed, originPropertyName) {
|
|
64
64
|
const resolver = this.resolvers[managed.type];
|
|
65
65
|
if (!resolver || resolver.type !== managed.type) {
|
|
66
|
-
throw new
|
|
66
|
+
throw new error_1.MidwayResolverMissingError(managed.type);
|
|
67
67
|
}
|
|
68
68
|
return resolver.resolveAsync(managed, originPropertyName);
|
|
69
69
|
}
|
|
@@ -89,7 +89,7 @@ class ManagedResolverFactory {
|
|
|
89
89
|
this.context.get(dep, args);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
debugLog(`[core
|
|
92
|
+
debugLog(`[core]: Create id = "${definition.name}" ${definition.id}.`);
|
|
93
93
|
const Clzz = definition.creator.load();
|
|
94
94
|
let constructorArgs = [];
|
|
95
95
|
if (args && Array.isArray(args) && args.length > 0) {
|
|
@@ -174,7 +174,7 @@ class ManagedResolverFactory {
|
|
|
174
174
|
await this.context.getAsync(dep, args);
|
|
175
175
|
}
|
|
176
176
|
}
|
|
177
|
-
debugLog(`[core
|
|
177
|
+
debugLog(`[core]: Create id = "${definition.name}" ${definition.id}.`);
|
|
178
178
|
const Clzz = definition.creator.load();
|
|
179
179
|
let constructorArgs = [];
|
|
180
180
|
if (args && Array.isArray(args) && args.length > 0) {
|
|
@@ -187,7 +187,7 @@ class ManagedResolverFactory {
|
|
|
187
187
|
inst = await definition.creator.doConstructAsync(Clzz, constructorArgs, this.context);
|
|
188
188
|
if (!inst) {
|
|
189
189
|
this.removeCreateStatus(definition, false);
|
|
190
|
-
throw new
|
|
190
|
+
throw new error_1.MidwayCommonError(`${definition.id} construct return undefined`);
|
|
191
191
|
}
|
|
192
192
|
// binding ctx object
|
|
193
193
|
if (definition.isRequestScope() &&
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ObjectCreator = void 0;
|
|
4
4
|
const decorator_1 = require("@midwayjs/decorator");
|
|
5
|
+
const error_1 = require("../error");
|
|
5
6
|
class ObjectCreator {
|
|
6
7
|
constructor(definition) {
|
|
7
8
|
this.definition = definition;
|
|
@@ -87,12 +88,12 @@ class ObjectCreator {
|
|
|
87
88
|
if (this.definition.initMethod && inst[this.definition.initMethod]) {
|
|
88
89
|
if ((0, decorator_1.isGeneratorFunction)(inst[this.definition.initMethod]) ||
|
|
89
90
|
(0, decorator_1.isAsyncFunction)(inst[this.definition.initMethod])) {
|
|
90
|
-
throw new
|
|
91
|
+
throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
|
|
91
92
|
}
|
|
92
93
|
else {
|
|
93
94
|
const rt = inst[this.definition.initMethod].call(inst);
|
|
94
95
|
if ((0, decorator_1.isPromise)(rt)) {
|
|
95
|
-
throw new
|
|
96
|
+
throw new error_1.MidwayUseWrongMethodError('context.get', 'context.getAsync', this.definition.id);
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
}
|
package/dist/error/base.d.ts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
interface ErrorOption {
|
|
2
|
-
cause
|
|
2
|
+
cause?: Error;
|
|
3
|
+
status?: number;
|
|
4
|
+
}
|
|
5
|
+
interface Convertable {
|
|
6
|
+
[key: string]: string | number;
|
|
3
7
|
}
|
|
8
|
+
declare type ConvertString<T extends Convertable, Group extends string> = {
|
|
9
|
+
[P in keyof T]: P extends string ? T[P] extends number ? `${Uppercase<Group>}_${T[P]}` : never : never;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Register error group and code, return the standard ErrorCode
|
|
13
|
+
* @param errorGroup
|
|
14
|
+
* @param errorCodeMapping
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerErrorCode<T extends Convertable, G extends string>(errorGroup: G, errorCodeMapping: T): ConvertString<T, G>;
|
|
4
17
|
export declare class MidwayError extends Error {
|
|
5
|
-
code: number;
|
|
18
|
+
code: number | string;
|
|
6
19
|
cause: Error;
|
|
7
20
|
constructor(message: string, options?: ErrorOption);
|
|
8
|
-
constructor(message: string, code:
|
|
21
|
+
constructor(message: string, code: string, options?: ErrorOption);
|
|
22
|
+
}
|
|
23
|
+
export declare type ResOrMessage = string | {
|
|
24
|
+
message: string;
|
|
25
|
+
};
|
|
26
|
+
export declare class MidwayHttpError extends MidwayError {
|
|
27
|
+
status: number;
|
|
28
|
+
constructor(resOrMessage: ResOrMessage, status: number);
|
|
29
|
+
constructor(resOrMessage: ResOrMessage, status: number, code: string, options?: ErrorOption);
|
|
9
30
|
}
|
|
10
31
|
export {};
|
|
11
32
|
//# sourceMappingURL=base.d.ts.map
|
package/dist/error/base.js
CHANGED
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MidwayError = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.MidwayHttpError = exports.MidwayError = exports.registerErrorCode = void 0;
|
|
4
|
+
const codeGroup = new Set();
|
|
5
|
+
/**
|
|
6
|
+
* Register error group and code, return the standard ErrorCode
|
|
7
|
+
* @param errorGroup
|
|
8
|
+
* @param errorCodeMapping
|
|
9
|
+
*/
|
|
10
|
+
function registerErrorCode(errorGroup, errorCodeMapping) {
|
|
11
|
+
if (codeGroup.has(errorGroup)) {
|
|
12
|
+
throw new MidwayError(`Error group ${errorGroup} is duplicated, please check before adding.`);
|
|
13
|
+
}
|
|
14
|
+
else {
|
|
15
|
+
codeGroup.add(errorGroup);
|
|
16
|
+
}
|
|
17
|
+
const newCodeEnum = {};
|
|
18
|
+
// ERROR => GROUP_10000
|
|
19
|
+
for (const errKey in errorCodeMapping) {
|
|
20
|
+
newCodeEnum[errKey] =
|
|
21
|
+
errorGroup.toUpperCase() +
|
|
22
|
+
'_' +
|
|
23
|
+
String(errorCodeMapping[errKey]).toUpperCase();
|
|
24
|
+
}
|
|
25
|
+
return newCodeEnum;
|
|
26
|
+
}
|
|
27
|
+
exports.registerErrorCode = registerErrorCode;
|
|
5
28
|
class MidwayError extends Error {
|
|
6
29
|
constructor(message, code, options) {
|
|
7
30
|
super(message);
|
|
8
|
-
if (typeof code
|
|
31
|
+
if (!code || typeof code === 'object') {
|
|
9
32
|
options = code;
|
|
10
|
-
code =
|
|
33
|
+
code = 'MIDWAY_10000';
|
|
11
34
|
}
|
|
12
35
|
this.name = this.constructor.name;
|
|
13
36
|
this.code = code;
|
|
@@ -15,4 +38,11 @@ class MidwayError extends Error {
|
|
|
15
38
|
}
|
|
16
39
|
}
|
|
17
40
|
exports.MidwayError = MidwayError;
|
|
41
|
+
class MidwayHttpError extends MidwayError {
|
|
42
|
+
constructor(resOrMessage, status, code, options) {
|
|
43
|
+
super(typeof resOrMessage === 'string' ? resOrMessage : resOrMessage.message, code !== null && code !== void 0 ? code : String(status), options);
|
|
44
|
+
this.status = status;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.MidwayHttpError = MidwayHttpError;
|
|
18
48
|
//# sourceMappingURL=base.js.map
|
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
import { MidwayError } from './base';
|
|
2
2
|
import { ObjectIdentifier } from '@midwayjs/decorator';
|
|
3
|
+
export declare const FrameworkErrorEnum: {
|
|
4
|
+
readonly UNKNOWN: "MIDWAY_10000";
|
|
5
|
+
readonly COMMON: "MIDWAY_10001";
|
|
6
|
+
readonly PARAM_TYPE: "MIDWAY_10002";
|
|
7
|
+
readonly DEFINITION_NOT_FOUND: "MIDWAY_10003";
|
|
8
|
+
readonly FEATURE_NO_LONGER_SUPPORTED: "MIDWAY_10004";
|
|
9
|
+
readonly FEATURE_NOT_IMPLEMENTED: "MIDWAY_10004";
|
|
10
|
+
readonly MISSING_CONFIG: "MIDWAY_10006";
|
|
11
|
+
readonly MISSING_RESOLVER: "MIDWAY_10007";
|
|
12
|
+
readonly DUPLICATE_ROUTER: "MIDWAY_10008";
|
|
13
|
+
readonly USE_WRONG_METHOD: "MIDWAY_10009";
|
|
14
|
+
};
|
|
3
15
|
export declare class MidwayCommonError extends MidwayError {
|
|
4
16
|
constructor(message: string);
|
|
5
17
|
}
|
|
@@ -15,7 +27,19 @@ export declare class MidwayDefinitionNotFoundError extends MidwayError {
|
|
|
15
27
|
export declare class MidwayFeatureNoLongerSupportedError extends MidwayError {
|
|
16
28
|
constructor(message?: string);
|
|
17
29
|
}
|
|
18
|
-
export declare class
|
|
19
|
-
constructor();
|
|
30
|
+
export declare class MidwayFeatureNotImplementedError extends MidwayError {
|
|
31
|
+
constructor(message?: string);
|
|
32
|
+
}
|
|
33
|
+
export declare class MidwayConfigMissingError extends MidwayError {
|
|
34
|
+
constructor(configKey: string);
|
|
35
|
+
}
|
|
36
|
+
export declare class MidwayResolverMissingError extends MidwayError {
|
|
37
|
+
constructor(type: string);
|
|
38
|
+
}
|
|
39
|
+
export declare class MidwayDuplicateRouteError extends MidwayError {
|
|
40
|
+
constructor(routerUrl: string, existPos: string, existPosOther: string);
|
|
41
|
+
}
|
|
42
|
+
export declare class MidwayUseWrongMethodError extends MidwayError {
|
|
43
|
+
constructor(wrongMethod: string, replacedMethod: string, describeKey?: string);
|
|
20
44
|
}
|
|
21
45
|
//# sourceMappingURL=framework.d.ts.map
|
package/dist/error/framework.js
CHANGED
|
@@ -1,23 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.MidwayUseWrongMethodError = exports.MidwayDuplicateRouteError = exports.MidwayResolverMissingError = exports.MidwayConfigMissingError = exports.MidwayFeatureNotImplementedError = exports.MidwayFeatureNoLongerSupportedError = exports.MidwayDefinitionNotFoundError = exports.MidwayParameterError = exports.MidwayCommonError = exports.FrameworkErrorEnum = void 0;
|
|
4
4
|
const base_1 = require("./base");
|
|
5
|
-
|
|
5
|
+
exports.FrameworkErrorEnum = (0, base_1.registerErrorCode)('midway', {
|
|
6
|
+
UNKNOWN: 10000,
|
|
7
|
+
COMMON: 10001,
|
|
8
|
+
PARAM_TYPE: 10002,
|
|
9
|
+
DEFINITION_NOT_FOUND: 10003,
|
|
10
|
+
FEATURE_NO_LONGER_SUPPORTED: 10004,
|
|
11
|
+
FEATURE_NOT_IMPLEMENTED: 10004,
|
|
12
|
+
MISSING_CONFIG: 10006,
|
|
13
|
+
MISSING_RESOLVER: 10007,
|
|
14
|
+
DUPLICATE_ROUTER: 10008,
|
|
15
|
+
USE_WRONG_METHOD: 10009,
|
|
16
|
+
});
|
|
6
17
|
class MidwayCommonError extends base_1.MidwayError {
|
|
7
18
|
constructor(message) {
|
|
8
|
-
super(message,
|
|
19
|
+
super(message, exports.FrameworkErrorEnum.COMMON);
|
|
9
20
|
}
|
|
10
21
|
}
|
|
11
22
|
exports.MidwayCommonError = MidwayCommonError;
|
|
12
23
|
class MidwayParameterError extends base_1.MidwayError {
|
|
13
24
|
constructor(message) {
|
|
14
|
-
super(message !== null && message !== void 0 ? message : 'Parameter type not match',
|
|
25
|
+
super(message !== null && message !== void 0 ? message : 'Parameter type not match', exports.FrameworkErrorEnum.PARAM_TYPE);
|
|
15
26
|
}
|
|
16
27
|
}
|
|
17
28
|
exports.MidwayParameterError = MidwayParameterError;
|
|
18
29
|
class MidwayDefinitionNotFoundError extends base_1.MidwayError {
|
|
19
30
|
constructor(identifier) {
|
|
20
|
-
super(`${identifier} is not valid in current context`,
|
|
31
|
+
super(`${identifier} is not valid in current context`, exports.FrameworkErrorEnum.DEFINITION_NOT_FOUND);
|
|
21
32
|
this[MidwayDefinitionNotFoundError.type] =
|
|
22
33
|
MidwayDefinitionNotFoundError.type;
|
|
23
34
|
}
|
|
@@ -36,14 +47,41 @@ exports.MidwayDefinitionNotFoundError = MidwayDefinitionNotFoundError;
|
|
|
36
47
|
MidwayDefinitionNotFoundError.type = Symbol.for('#NotFoundError');
|
|
37
48
|
class MidwayFeatureNoLongerSupportedError extends base_1.MidwayError {
|
|
38
49
|
constructor(message) {
|
|
39
|
-
super('This feature no longer supported \n' + message,
|
|
50
|
+
super('This feature no longer supported \n' + message, exports.FrameworkErrorEnum.FEATURE_NO_LONGER_SUPPORTED);
|
|
40
51
|
}
|
|
41
52
|
}
|
|
42
53
|
exports.MidwayFeatureNoLongerSupportedError = MidwayFeatureNoLongerSupportedError;
|
|
43
|
-
class
|
|
44
|
-
constructor() {
|
|
45
|
-
super('
|
|
54
|
+
class MidwayFeatureNotImplementedError extends base_1.MidwayError {
|
|
55
|
+
constructor(message) {
|
|
56
|
+
super('This feature not implemented \n' + message, exports.FrameworkErrorEnum.FEATURE_NOT_IMPLEMENTED);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.MidwayFeatureNotImplementedError = MidwayFeatureNotImplementedError;
|
|
60
|
+
class MidwayConfigMissingError extends base_1.MidwayError {
|
|
61
|
+
constructor(configKey) {
|
|
62
|
+
super(`Can't found config key "${configKey}" in your config, please set it first`, exports.FrameworkErrorEnum.MISSING_CONFIG);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.MidwayConfigMissingError = MidwayConfigMissingError;
|
|
66
|
+
class MidwayResolverMissingError extends base_1.MidwayError {
|
|
67
|
+
constructor(type) {
|
|
68
|
+
super(`${type} resolver is not exists!`, exports.FrameworkErrorEnum.MISSING_RESOLVER);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
exports.MidwayResolverMissingError = MidwayResolverMissingError;
|
|
72
|
+
class MidwayDuplicateRouteError extends base_1.MidwayError {
|
|
73
|
+
constructor(routerUrl, existPos, existPosOther) {
|
|
74
|
+
super(`Duplicate router "${routerUrl}" at "${existPos}" and "${existPosOther}"`, exports.FrameworkErrorEnum.DUPLICATE_ROUTER);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
exports.MidwayDuplicateRouteError = MidwayDuplicateRouteError;
|
|
78
|
+
class MidwayUseWrongMethodError extends base_1.MidwayError {
|
|
79
|
+
constructor(wrongMethod, replacedMethod, describeKey) {
|
|
80
|
+
const text = describeKey
|
|
81
|
+
? `${describeKey} not valid by ${wrongMethod}, Use ${replacedMethod} instead!`
|
|
82
|
+
: `You should not invoked by ${wrongMethod}, Use ${replacedMethod} instead!`;
|
|
83
|
+
super(text, exports.FrameworkErrorEnum.USE_WRONG_METHOD);
|
|
46
84
|
}
|
|
47
85
|
}
|
|
48
|
-
exports.
|
|
86
|
+
exports.MidwayUseWrongMethodError = MidwayUseWrongMethodError;
|
|
49
87
|
//# sourceMappingURL=framework.js.map
|
package/dist/error/http.d.ts
CHANGED
|
@@ -1,41 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
1
|
+
import { MidwayHttpError, ResOrMessage } from './base';
|
|
2
|
+
export declare enum HttpStatus {
|
|
3
|
+
CONTINUE = 100,
|
|
4
|
+
SWITCHING_PROTOCOLS = 101,
|
|
5
|
+
PROCESSING = 102,
|
|
6
|
+
EARLYHINTS = 103,
|
|
7
|
+
OK = 200,
|
|
8
|
+
CREATED = 201,
|
|
9
|
+
ACCEPTED = 202,
|
|
10
|
+
NON_AUTHORITATIVE_INFORMATION = 203,
|
|
11
|
+
NO_CONTENT = 204,
|
|
12
|
+
RESET_CONTENT = 205,
|
|
13
|
+
PARTIAL_CONTENT = 206,
|
|
14
|
+
AMBIGUOUS = 300,
|
|
15
|
+
MOVED_PERMANENTLY = 301,
|
|
16
|
+
FOUND = 302,
|
|
17
|
+
SEE_OTHER = 303,
|
|
18
|
+
NOT_MODIFIED = 304,
|
|
19
|
+
TEMPORARY_REDIRECT = 307,
|
|
20
|
+
PERMANENT_REDIRECT = 308,
|
|
21
|
+
BAD_REQUEST = 400,
|
|
22
|
+
UNAUTHORIZED = 401,
|
|
23
|
+
PAYMENT_REQUIRED = 402,
|
|
24
|
+
FORBIDDEN = 403,
|
|
25
|
+
NOT_FOUND = 404,
|
|
26
|
+
METHOD_NOT_ALLOWED = 405,
|
|
27
|
+
NOT_ACCEPTABLE = 406,
|
|
28
|
+
PROXY_AUTHENTICATION_REQUIRED = 407,
|
|
29
|
+
REQUEST_TIMEOUT = 408,
|
|
30
|
+
CONFLICT = 409,
|
|
31
|
+
GONE = 410,
|
|
32
|
+
LENGTH_REQUIRED = 411,
|
|
33
|
+
PRECONDITION_FAILED = 412,
|
|
34
|
+
PAYLOAD_TOO_LARGE = 413,
|
|
35
|
+
URI_TOO_LONG = 414,
|
|
36
|
+
UNSUPPORTED_MEDIA_TYPE = 415,
|
|
37
|
+
REQUESTED_RANGE_NOT_SATISFIABLE = 416,
|
|
38
|
+
EXPECTATION_FAILED = 417,
|
|
39
|
+
I_AM_A_TEAPOT = 418,
|
|
40
|
+
MISDIRECTED = 421,
|
|
41
|
+
UNPROCESSABLE_ENTITY = 422,
|
|
42
|
+
FAILED_DEPENDENCY = 424,
|
|
43
|
+
PRECONDITION_REQUIRED = 428,
|
|
44
|
+
TOO_MANY_REQUESTS = 429,
|
|
45
|
+
INTERNAL_SERVER_ERROR = 500,
|
|
46
|
+
NOT_IMPLEMENTED = 501,
|
|
47
|
+
BAD_GATEWAY = 502,
|
|
48
|
+
SERVICE_UNAVAILABLE = 503,
|
|
49
|
+
GATEWAY_TIMEOUT = 504,
|
|
50
|
+
HTTP_VERSION_NOT_SUPPORTED = 505
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* 400 http error, Means that the request can be fulfilled because of the bad syntax.
|
|
54
|
+
*/
|
|
55
|
+
export declare class BadRequestError extends MidwayHttpError {
|
|
56
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
61
|
+
export declare class UnauthorizedError extends MidwayHttpError {
|
|
62
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
67
|
+
export declare class NotFoundError extends MidwayHttpError {
|
|
68
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* 403 http error, Means that the request is legal, but the server is rejecting to answer it.
|
|
72
|
+
*/
|
|
73
|
+
export declare class ForbiddenError extends MidwayHttpError {
|
|
74
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* 406 http error, Means that the server can only generate an answer which the client doesn't accept.
|
|
78
|
+
*/
|
|
79
|
+
export declare class NotAcceptableError extends MidwayHttpError {
|
|
80
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* 408 http error, Means that the server timed out waiting for the request.
|
|
84
|
+
*/
|
|
85
|
+
export declare class RequestTimeoutError extends MidwayHttpError {
|
|
86
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 409 http error, Means that the request cannot be completed, because of a conflict in the request.
|
|
90
|
+
*/
|
|
91
|
+
export declare class ConflictError extends MidwayHttpError {
|
|
92
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* 410 http error, Means that the requested page is not available anymore.
|
|
96
|
+
*/
|
|
97
|
+
export declare class GoneError extends MidwayHttpError {
|
|
98
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
103
|
+
export declare class PayloadTooLargeError extends MidwayHttpError {
|
|
104
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
109
|
+
export declare class UnsupportedMediaTypeError extends MidwayHttpError {
|
|
110
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
111
|
+
}
|
|
112
|
+
export declare class UnprocessableError extends MidwayHttpError {
|
|
113
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
118
|
+
export declare class InternalServerErrorError extends MidwayHttpError {
|
|
119
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
124
|
+
declare class NotImplementedError extends MidwayHttpError {
|
|
125
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
130
|
+
export declare class BadGatewayError extends MidwayHttpError {
|
|
131
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* 503 http error, Means that the server is not available now (It may be overloaded or down).
|
|
135
|
+
*/
|
|
136
|
+
export declare class ServiceUnavailableError extends MidwayHttpError {
|
|
137
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
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
|
+
*/
|
|
142
|
+
export declare class GatewayTimeoutError extends MidwayHttpError {
|
|
143
|
+
constructor(resOrMessage?: ResOrMessage);
|
|
144
|
+
}
|
|
145
|
+
export declare const httpError: {
|
|
39
146
|
BadRequestError: typeof BadRequestError;
|
|
40
147
|
UnauthorizedError: typeof UnauthorizedError;
|
|
41
148
|
NotFoundError: typeof NotFoundError;
|