@nestjs/common 11.1.16 → 12.0.0-alpha.1
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/constants.js +35 -38
- package/decorators/core/apply-decorators.js +1 -4
- package/decorators/core/bind.decorator.js +1 -4
- package/decorators/core/catch.decorator.d.ts +1 -1
- package/decorators/core/catch.decorator.js +4 -7
- package/decorators/core/controller.decorator.d.ts +1 -1
- package/decorators/core/controller.decorator.js +10 -13
- package/decorators/core/dependencies.decorator.js +4 -9
- package/decorators/core/exception-filters.decorator.d.ts +1 -1
- package/decorators/core/exception-filters.decorator.js +10 -14
- package/decorators/core/index.d.ts +14 -14
- package/decorators/core/index.js +14 -17
- package/decorators/core/inject.decorator.d.ts +1 -1
- package/decorators/core/inject.decorator.js +9 -12
- package/decorators/core/injectable.decorator.d.ts +2 -2
- package/decorators/core/injectable.decorator.js +7 -11
- package/decorators/core/optional.decorator.js +8 -11
- package/decorators/core/set-metadata.decorator.js +1 -5
- package/decorators/core/use-guards.decorator.d.ts +1 -1
- package/decorators/core/use-guards.decorator.js +10 -13
- package/decorators/core/use-interceptors.decorator.d.ts +1 -1
- package/decorators/core/use-interceptors.decorator.js +10 -13
- package/decorators/core/use-pipes.decorator.d.ts +1 -1
- package/decorators/core/use-pipes.decorator.js +9 -12
- package/decorators/core/version.decorator.d.ts +1 -1
- package/decorators/core/version.decorator.js +3 -6
- package/decorators/http/create-route-param-metadata.decorator.d.ts +6 -5
- package/decorators/http/create-route-param-metadata.decorator.js +48 -16
- package/decorators/http/header.decorator.js +4 -7
- package/decorators/http/http-code.decorator.js +3 -6
- package/decorators/http/index.d.ts +8 -8
- package/decorators/http/index.js +8 -11
- package/decorators/http/redirect.decorator.js +3 -6
- package/decorators/http/render.decorator.js +3 -6
- package/decorators/http/request-mapping.decorator.d.ts +1 -1
- package/decorators/http/request-mapping.decorator.js +28 -32
- package/decorators/http/route-params.decorator.d.ts +153 -3
- package/decorators/http/route-params.decorator.js +124 -49
- package/decorators/http/sse.decorator.d.ts +2 -2
- package/decorators/http/sse.decorator.js +7 -10
- package/decorators/index.d.ts +3 -3
- package/decorators/index.js +3 -6
- package/decorators/modules/global.decorator.js +3 -6
- package/decorators/modules/index.d.ts +2 -2
- package/decorators/modules/index.js +2 -5
- package/decorators/modules/module.decorator.d.ts +1 -1
- package/decorators/modules/module.decorator.js +3 -6
- package/enums/http-status.enum.js +2 -5
- package/enums/index.d.ts +4 -4
- package/enums/index.js +4 -7
- package/enums/request-method.enum.js +2 -5
- package/enums/route-paramtypes.enum.js +2 -5
- package/enums/shutdown-signal.enum.js +2 -5
- package/enums/version-type.enum.js +2 -5
- package/exceptions/bad-gateway.exception.d.ts +1 -1
- package/exceptions/bad-gateway.exception.js +5 -9
- package/exceptions/bad-request.exception.d.ts +1 -1
- package/exceptions/bad-request.exception.js +5 -9
- package/exceptions/conflict.exception.d.ts +1 -1
- package/exceptions/conflict.exception.js +5 -9
- package/exceptions/forbidden.exception.d.ts +1 -1
- package/exceptions/forbidden.exception.js +5 -9
- package/exceptions/gateway-timeout.exception.d.ts +1 -1
- package/exceptions/gateway-timeout.exception.js +5 -9
- package/exceptions/gone.exception.d.ts +1 -1
- package/exceptions/gone.exception.js +5 -9
- package/exceptions/http-version-not-supported.exception.d.ts +1 -1
- package/exceptions/http-version-not-supported.exception.js +5 -9
- package/exceptions/http.exception.d.ts +6 -2
- package/exceptions/http.exception.js +36 -17
- package/exceptions/im-a-teapot.exception.d.ts +1 -1
- package/exceptions/im-a-teapot.exception.js +5 -9
- package/exceptions/index.d.ts +23 -23
- package/exceptions/index.js +23 -26
- package/exceptions/internal-server-error.exception.d.ts +1 -1
- package/exceptions/internal-server-error.exception.js +5 -9
- package/exceptions/intrinsic.exception.js +1 -5
- package/exceptions/method-not-allowed.exception.d.ts +1 -1
- package/exceptions/method-not-allowed.exception.js +5 -9
- package/exceptions/misdirected.exception.d.ts +1 -1
- package/exceptions/misdirected.exception.js +5 -9
- package/exceptions/not-acceptable.exception.d.ts +1 -1
- package/exceptions/not-acceptable.exception.js +5 -9
- package/exceptions/not-found.exception.d.ts +1 -1
- package/exceptions/not-found.exception.js +5 -9
- package/exceptions/not-implemented.exception.d.ts +1 -1
- package/exceptions/not-implemented.exception.js +5 -9
- package/exceptions/payload-too-large.exception.d.ts +1 -1
- package/exceptions/payload-too-large.exception.js +5 -9
- package/exceptions/precondition-failed.exception.d.ts +1 -1
- package/exceptions/precondition-failed.exception.js +5 -9
- package/exceptions/request-timeout.exception.d.ts +1 -1
- package/exceptions/request-timeout.exception.js +5 -9
- package/exceptions/service-unavailable.exception.d.ts +1 -1
- package/exceptions/service-unavailable.exception.js +5 -9
- package/exceptions/unauthorized.exception.d.ts +1 -1
- package/exceptions/unauthorized.exception.js +5 -9
- package/exceptions/unprocessable-entity.exception.d.ts +1 -1
- package/exceptions/unprocessable-entity.exception.js +5 -9
- package/exceptions/unsupported-media-type.exception.d.ts +1 -1
- package/exceptions/unsupported-media-type.exception.js +5 -9
- package/file-stream/index.d.ts +1 -1
- package/file-stream/index.js +1 -4
- package/file-stream/interfaces/index.d.ts +2 -2
- package/file-stream/interfaces/index.js +2 -5
- package/file-stream/interfaces/streamable-handler-response.interface.js +1 -2
- package/file-stream/interfaces/streamable-options.interface.js +1 -2
- package/file-stream/streamable-file.d.ts +2 -2
- package/file-stream/streamable-file.js +26 -28
- package/index.d.ts +10 -10
- package/index.js +11 -17
- package/interfaces/abstract.interface.js +1 -2
- package/interfaces/controllers/controller-metadata.interface.js +1 -2
- package/interfaces/controllers/controller.interface.js +1 -2
- package/interfaces/controllers/index.d.ts +2 -2
- package/interfaces/controllers/index.js +2 -5
- package/interfaces/exceptions/exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/exception-filter.interface.js +1 -2
- package/interfaces/exceptions/index.d.ts +5 -5
- package/interfaces/exceptions/index.js +5 -8
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.d.ts +2 -2
- package/interfaces/exceptions/rpc-exception-filter-metadata.interface.js +1 -2
- package/interfaces/exceptions/rpc-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/rpc-exception-filter.interface.js +1 -2
- package/interfaces/exceptions/ws-exception-filter.interface.d.ts +1 -1
- package/interfaces/exceptions/ws-exception-filter.interface.js +1 -2
- package/interfaces/external/class-transform-options.interface.js +1 -2
- package/interfaces/external/cors-options.interface.js +1 -2
- package/interfaces/external/https-options.interface.js +1 -2
- package/interfaces/external/transformer-package.interface.d.ts +2 -2
- package/interfaces/external/transformer-package.interface.js +1 -2
- package/interfaces/external/validation-error.interface.js +1 -2
- package/interfaces/external/validator-options.interface.js +1 -2
- package/interfaces/external/validator-package.interface.d.ts +2 -2
- package/interfaces/external/validator-package.interface.js +1 -2
- package/interfaces/features/arguments-host.interface.js +1 -2
- package/interfaces/features/can-activate.interface.d.ts +1 -1
- package/interfaces/features/can-activate.interface.js +1 -2
- package/interfaces/features/custom-route-param-factory.interface.d.ts +1 -1
- package/interfaces/features/custom-route-param-factory.interface.js +1 -2
- package/interfaces/features/execution-context.interface.d.ts +2 -2
- package/interfaces/features/execution-context.interface.js +1 -2
- package/interfaces/features/nest-interceptor.interface.d.ts +1 -1
- package/interfaces/features/nest-interceptor.interface.js +1 -2
- package/interfaces/features/paramtype.interface.js +1 -2
- package/interfaces/features/pipe-transform.interface.d.ts +10 -4
- package/interfaces/features/pipe-transform.interface.js +1 -2
- package/interfaces/global-prefix-options.interface.d.ts +1 -1
- package/interfaces/global-prefix-options.interface.js +1 -2
- package/interfaces/hooks/before-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/index.d.ts +5 -5
- package/interfaces/hooks/index.js +5 -8
- package/interfaces/hooks/on-application-bootstrap.interface.js +1 -2
- package/interfaces/hooks/on-application-shutdown.interface.js +1 -2
- package/interfaces/hooks/on-destroy.interface.js +1 -2
- package/interfaces/hooks/on-init.interface.js +1 -2
- package/interfaces/http/http-exception-body.interface.d.ts +2 -1
- package/interfaces/http/http-exception-body.interface.js +1 -2
- package/interfaces/http/http-redirect-response.interface.d.ts +1 -1
- package/interfaces/http/http-redirect-response.interface.js +1 -2
- package/interfaces/http/http-server.interface.d.ts +4 -3
- package/interfaces/http/http-server.interface.js +1 -2
- package/interfaces/http/index.d.ts +5 -5
- package/interfaces/http/index.js +5 -8
- package/interfaces/http/message-event.interface.js +1 -2
- package/interfaces/http/raw-body-request.interface.js +1 -2
- package/interfaces/index.d.ts +31 -30
- package/interfaces/index.js +31 -33
- package/interfaces/injectable.interface.js +1 -2
- package/interfaces/microservices/nest-hybrid-application-options.interface.js +1 -2
- package/interfaces/microservices/nest-microservice-options.interface.d.ts +1 -1
- package/interfaces/microservices/nest-microservice-options.interface.js +1 -2
- package/interfaces/microservices/pre-request-hook.interface.d.ts +22 -0
- package/interfaces/microservices/pre-request-hook.interface.js +1 -0
- package/interfaces/middleware/index.d.ts +4 -4
- package/interfaces/middleware/index.js +4 -7
- package/interfaces/middleware/middleware-config-proxy.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-config-proxy.interface.js +1 -2
- package/interfaces/middleware/middleware-configuration.interface.d.ts +3 -3
- package/interfaces/middleware/middleware-configuration.interface.js +1 -2
- package/interfaces/middleware/middleware-consumer.interface.d.ts +2 -2
- package/interfaces/middleware/middleware-consumer.interface.js +1 -2
- package/interfaces/middleware/nest-middleware.interface.js +1 -2
- package/interfaces/modules/dynamic-module.interface.d.ts +2 -2
- package/interfaces/modules/dynamic-module.interface.js +1 -2
- package/interfaces/modules/forward-reference.interface.js +1 -2
- package/interfaces/modules/index.d.ts +8 -8
- package/interfaces/modules/index.js +8 -11
- package/interfaces/modules/injection-token.interface.d.ts +2 -2
- package/interfaces/modules/injection-token.interface.js +1 -2
- package/interfaces/modules/introspection-result.interface.d.ts +1 -1
- package/interfaces/modules/introspection-result.interface.js +1 -2
- package/interfaces/modules/module-metadata.interface.d.ts +5 -5
- package/interfaces/modules/module-metadata.interface.js +1 -2
- package/interfaces/modules/nest-module.interface.d.ts +1 -1
- package/interfaces/modules/nest-module.interface.js +1 -2
- package/interfaces/modules/optional-factory-dependency.interface.d.ts +1 -1
- package/interfaces/modules/optional-factory-dependency.interface.js +1 -2
- package/interfaces/modules/provider.interface.d.ts +4 -4
- package/interfaces/modules/provider.interface.js +1 -2
- package/interfaces/nest-application-context-options.interface.d.ts +1 -1
- package/interfaces/nest-application-context-options.interface.js +55 -5
- package/interfaces/nest-application-context.interface.d.ts +6 -6
- package/interfaces/nest-application-context.interface.js +1 -2
- package/interfaces/nest-application-options.interface.d.ts +9 -3
- package/interfaces/nest-application-options.interface.js +1 -2
- package/interfaces/nest-application.interface.d.ts +8 -8
- package/interfaces/nest-application.interface.js +1 -2
- package/interfaces/nest-microservice.interface.d.ts +15 -6
- package/interfaces/nest-microservice.interface.js +1 -2
- package/interfaces/scope-options.interface.js +2 -5
- package/interfaces/shutdown-hooks-options.interface.js +1 -2
- package/interfaces/type.interface.js +1 -2
- package/interfaces/version-options.interface.d.ts +1 -1
- package/interfaces/version-options.interface.js +1 -4
- package/interfaces/websockets/web-socket-adapter.interface.js +1 -2
- package/internal.d.ts +30 -0
- package/internal.js +19 -0
- package/module-utils/configurable-module.builder.d.ts +4 -4
- package/module-utils/configurable-module.builder.js +21 -20
- package/module-utils/constants.js +5 -8
- package/module-utils/index.d.ts +2 -2
- package/module-utils/index.js +2 -5
- package/module-utils/interfaces/configurable-module-async-options.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-async-options.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-cls.interface.d.ts +3 -3
- package/module-utils/interfaces/configurable-module-cls.interface.js +1 -2
- package/module-utils/interfaces/configurable-module-host.interface.d.ts +2 -2
- package/module-utils/interfaces/configurable-module-host.interface.js +1 -2
- package/module-utils/interfaces/index.d.ts +3 -3
- package/module-utils/interfaces/index.js +3 -6
- package/module-utils/utils/generate-options-injection-token.util.js +3 -6
- package/module-utils/utils/get-injection-providers.util.d.ts +1 -1
- package/module-utils/utils/get-injection-providers.util.js +4 -7
- package/module-utils/utils/index.d.ts +2 -2
- package/module-utils/utils/index.js +2 -5
- package/package.json +35 -2
- package/pipes/default-value.pipe.d.ts +1 -1
- package/pipes/default-value.pipe.js +10 -12
- package/pipes/file/file-type.validator.d.ts +3 -3
- package/pipes/file/file-type.validator.js +5 -19
- package/pipes/file/file-validator-context.interface.d.ts +1 -1
- package/pipes/file/file-validator-context.interface.js +1 -2
- package/pipes/file/file-validator.interface.d.ts +1 -1
- package/pipes/file/file-validator.interface.js +2 -5
- package/pipes/file/index.d.ts +6 -6
- package/pipes/file/index.js +6 -9
- package/pipes/file/interfaces/file.interface.js +1 -2
- package/pipes/file/interfaces/index.d.ts +1 -1
- package/pipes/file/interfaces/index.js +1 -4
- package/pipes/file/max-file-size.validator.d.ts +3 -3
- package/pipes/file/max-file-size.validator.js +2 -6
- package/pipes/file/parse-file-options.interface.d.ts +2 -2
- package/pipes/file/parse-file-options.interface.js +1 -2
- package/pipes/file/parse-file-pipe.builder.d.ts +5 -5
- package/pipes/file/parse-file-pipe.builder.js +8 -14
- package/pipes/file/parse-file.pipe.d.ts +7 -7
- package/pipes/file/parse-file.pipe.js +17 -18
- package/pipes/index.d.ts +11 -10
- package/pipes/index.js +11 -13
- package/pipes/parse-array.pipe.d.ts +4 -4
- package/pipes/parse-array.pipe.js +23 -23
- package/pipes/parse-bool.pipe.d.ts +6 -6
- package/pipes/parse-bool.pipe.js +16 -17
- package/pipes/parse-date.pipe.d.ts +4 -4
- package/pipes/parse-date.pipe.js +17 -16
- package/pipes/parse-enum.pipe.d.ts +5 -5
- package/pipes/parse-enum.pipe.js +16 -16
- package/pipes/parse-float.pipe.d.ts +6 -6
- package/pipes/parse-float.pipe.js +17 -18
- package/pipes/parse-int.pipe.d.ts +5 -5
- package/pipes/parse-int.pipe.js +18 -19
- package/pipes/parse-uuid.pipe.d.ts +4 -4
- package/pipes/parse-uuid.pipe.js +27 -26
- package/pipes/standard-schema-validation.pipe.d.ts +86 -0
- package/pipes/standard-schema-validation.pipe.js +120 -0
- package/pipes/validation.pipe.d.ts +32 -14
- package/pipes/validation.pipe.js +60 -30
- package/serializer/class-serializer.constants.js +1 -4
- package/serializer/class-serializer.interceptor.d.ts +5 -5
- package/serializer/class-serializer.interceptor.js +21 -24
- package/serializer/class-serializer.interfaces.d.ts +2 -2
- package/serializer/class-serializer.interfaces.js +1 -2
- package/serializer/decorators/index.d.ts +1 -1
- package/serializer/decorators/index.js +1 -4
- package/serializer/decorators/serialize-options.decorator.d.ts +3 -2
- package/serializer/decorators/serialize-options.decorator.js +3 -7
- package/serializer/index.d.ts +5 -3
- package/serializer/index.js +5 -6
- package/serializer/standard-schema-serializer.interceptor.d.ts +50 -0
- package/serializer/standard-schema-serializer.interceptor.js +75 -0
- package/serializer/standard-schema-serializer.interfaces.d.ts +18 -0
- package/serializer/standard-schema-serializer.interfaces.js +1 -0
- package/services/console-logger.service.d.ts +22 -3
- package/services/console-logger.service.js +132 -66
- package/services/index.d.ts +3 -3
- package/services/index.js +3 -6
- package/services/logger.service.js +86 -83
- package/services/utils/filter-log-levels.util.d.ts +1 -1
- package/services/utils/filter-log-levels.util.js +7 -10
- package/services/utils/index.d.ts +3 -3
- package/services/utils/index.js +3 -6
- package/services/utils/is-log-level-enabled.util.d.ts +1 -1
- package/services/utils/is-log-level-enabled.util.js +1 -4
- package/services/utils/is-log-level.util.d.ts +1 -1
- package/services/utils/is-log-level.util.js +3 -6
- package/tsconfig.build.json +1 -2
- package/utils/assign-custom-metadata.util.d.ts +5 -4
- package/utils/assign-custom-metadata.util.js +4 -6
- package/utils/cli-colors.util.js +4 -8
- package/utils/extend-metadata.util.js +1 -4
- package/utils/forward-ref.util.d.ts +1 -1
- package/utils/forward-ref.util.js +1 -5
- package/utils/http-error-by-code.util.d.ts +2 -2
- package/utils/http-error-by-code.util.js +22 -25
- package/utils/index.d.ts +1 -1
- package/utils/index.js +1 -4
- package/utils/load-package.util.d.ts +29 -1
- package/utils/load-package.util.js +84 -9
- package/utils/merge-with-values.util.js +1 -5
- package/utils/random-string-generator.util.js +2 -6
- package/utils/select-exception-filter-metadata.util.d.ts +1 -1
- package/utils/select-exception-filter-metadata.util.js +1 -5
- package/utils/shared.utils.d.ts +11 -10
- package/utils/shared.utils.js +28 -30
- package/utils/validate-each.util.js +3 -7
- package/utils/validate-module-keys.util.js +8 -13
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ForbiddenException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Forbidden* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class ForbiddenException extends
|
|
10
|
+
export class ForbiddenException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `ForbiddenException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class ForbiddenException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Forbidden') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Forbidden', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.FORBIDDEN), HttpStatus.FORBIDDEN, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.ForbiddenException = ForbiddenException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GatewayTimeoutException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Gateway Timeout* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class GatewayTimeoutException extends
|
|
10
|
+
export class GatewayTimeoutException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `GatewayTimeoutException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class GatewayTimeoutException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Gateway Timeout') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Gateway Timeout', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.GATEWAY_TIMEOUT), HttpStatus.GATEWAY_TIMEOUT, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.GatewayTimeoutException = GatewayTimeoutException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.GoneException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Gone* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class GoneException extends
|
|
10
|
+
export class GoneException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `GoneException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class GoneException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Gone') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Gone', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.GONE), HttpStatus.GONE, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.GoneException = GoneException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.HttpVersionNotSupportedException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class HttpVersionNotSupportedException extends
|
|
10
|
+
export class HttpVersionNotSupportedException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `HttpVersionNotSupportedException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class HttpVersionNotSupportedException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'HTTP Version Not Supported') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'HTTP Version Not Supported', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.HTTP_VERSION_NOT_SUPPORTED), HttpStatus.HTTP_VERSION_NOT_SUPPORTED, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.HttpVersionNotSupportedException = HttpVersionNotSupportedException;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { HttpExceptionBody, HttpExceptionBodyMessage } from '../interfaces/http/http-exception-body.interface';
|
|
2
|
-
import { IntrinsicException } from './intrinsic.exception';
|
|
1
|
+
import { HttpExceptionBody, HttpExceptionBodyMessage } from '../interfaces/http/http-exception-body.interface.js';
|
|
2
|
+
import { IntrinsicException } from './intrinsic.exception.js';
|
|
3
3
|
export interface HttpExceptionOptions {
|
|
4
4
|
/** original cause of the error */
|
|
5
5
|
cause?: unknown;
|
|
6
6
|
description?: string;
|
|
7
|
+
errorCode?: string;
|
|
7
8
|
}
|
|
8
9
|
export interface DescriptionAndOptions {
|
|
9
10
|
description?: string;
|
|
@@ -26,6 +27,7 @@ export declare class HttpException extends IntrinsicException {
|
|
|
26
27
|
* It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.
|
|
27
28
|
*/
|
|
28
29
|
cause: unknown;
|
|
30
|
+
errorCode?: string;
|
|
29
31
|
/**
|
|
30
32
|
* Instantiate a plain HTTP Exception.
|
|
31
33
|
*
|
|
@@ -67,12 +69,14 @@ export declare class HttpException extends IntrinsicException {
|
|
|
67
69
|
* @see https://github.com/microsoft/TypeScript/issues/45167
|
|
68
70
|
*/
|
|
69
71
|
initCause(): void;
|
|
72
|
+
initErrorCode(): void;
|
|
70
73
|
initMessage(): void;
|
|
71
74
|
initName(): void;
|
|
72
75
|
getResponse(): string | object;
|
|
73
76
|
getStatus(): number;
|
|
74
77
|
static createBody(nil: null | '', message: HttpExceptionBodyMessage, statusCode: number): HttpExceptionBody;
|
|
75
78
|
static createBody(message: HttpExceptionBodyMessage, error: string, statusCode: number): HttpExceptionBody;
|
|
79
|
+
static createBody(message: HttpExceptionBodyMessage, error: string, statusCode: number, errorCode?: string): HttpExceptionBody;
|
|
76
80
|
static createBody<Body extends Record<string, unknown>>(custom: Body): Body;
|
|
77
81
|
static getDescriptionFrom(descriptionOrOptions: string | HttpExceptionOptions): string;
|
|
78
82
|
static getHttpExceptionOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): HttpExceptionOptions;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.HttpException = void 0;
|
|
4
|
-
const shared_utils_1 = require("../utils/shared.utils");
|
|
5
|
-
const intrinsic_exception_1 = require("./intrinsic.exception");
|
|
1
|
+
import { isNumber, isObject, isString } from '../utils/shared.utils.js';
|
|
2
|
+
import { IntrinsicException } from './intrinsic.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines the base Nest HTTP exception, which is handled by the default
|
|
8
5
|
* Exceptions Handler.
|
|
@@ -11,7 +8,16 @@ const intrinsic_exception_1 = require("./intrinsic.exception");
|
|
|
11
8
|
*
|
|
12
9
|
* @publicApi
|
|
13
10
|
*/
|
|
14
|
-
class HttpException extends
|
|
11
|
+
export class HttpException extends IntrinsicException {
|
|
12
|
+
response;
|
|
13
|
+
status;
|
|
14
|
+
options;
|
|
15
|
+
/**
|
|
16
|
+
* Exception cause. Indicates the specific original cause of the error.
|
|
17
|
+
* It is used when catching and re-throwing an error with a more-specific or useful error message in order to still have access to the original error.
|
|
18
|
+
*/
|
|
19
|
+
cause;
|
|
20
|
+
errorCode;
|
|
15
21
|
/**
|
|
16
22
|
* Instantiate a plain HTTP Exception.
|
|
17
23
|
*
|
|
@@ -53,6 +59,7 @@ class HttpException extends intrinsic_exception_1.IntrinsicException {
|
|
|
53
59
|
this.initMessage();
|
|
54
60
|
this.initName();
|
|
55
61
|
this.initCause();
|
|
62
|
+
this.initErrorCode();
|
|
56
63
|
}
|
|
57
64
|
/**
|
|
58
65
|
* Configures error chaining support
|
|
@@ -66,11 +73,16 @@ class HttpException extends intrinsic_exception_1.IntrinsicException {
|
|
|
66
73
|
return;
|
|
67
74
|
}
|
|
68
75
|
}
|
|
76
|
+
initErrorCode() {
|
|
77
|
+
if (this.options?.errorCode) {
|
|
78
|
+
this.errorCode = this.options.errorCode;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
69
81
|
initMessage() {
|
|
70
|
-
if (
|
|
82
|
+
if (isString(this.response)) {
|
|
71
83
|
this.message = this.response;
|
|
72
84
|
}
|
|
73
|
-
else if (
|
|
85
|
+
else if (isObject(this.response) && isString(this.response.message)) {
|
|
74
86
|
this.message = this.response.message;
|
|
75
87
|
}
|
|
76
88
|
else if (this.constructor) {
|
|
@@ -88,29 +100,37 @@ class HttpException extends intrinsic_exception_1.IntrinsicException {
|
|
|
88
100
|
getStatus() {
|
|
89
101
|
return this.status;
|
|
90
102
|
}
|
|
91
|
-
static createBody(arg0, arg1, statusCode) {
|
|
103
|
+
static createBody(arg0, arg1, statusCode, errorCode) {
|
|
92
104
|
if (!arg0) {
|
|
93
|
-
|
|
105
|
+
const body = {
|
|
94
106
|
message: arg1,
|
|
95
107
|
statusCode: statusCode,
|
|
96
108
|
};
|
|
109
|
+
if (errorCode) {
|
|
110
|
+
body.errorCode = errorCode;
|
|
111
|
+
}
|
|
112
|
+
return body;
|
|
97
113
|
}
|
|
98
|
-
if (
|
|
99
|
-
|
|
114
|
+
if (isString(arg0) || Array.isArray(arg0) || isNumber(arg0)) {
|
|
115
|
+
const body = {
|
|
100
116
|
message: arg0,
|
|
101
117
|
error: arg1,
|
|
102
118
|
statusCode: statusCode,
|
|
103
119
|
};
|
|
120
|
+
if (errorCode) {
|
|
121
|
+
body.errorCode = errorCode;
|
|
122
|
+
}
|
|
123
|
+
return body;
|
|
104
124
|
}
|
|
105
125
|
return arg0;
|
|
106
126
|
}
|
|
107
127
|
static getDescriptionFrom(descriptionOrOptions) {
|
|
108
|
-
return
|
|
128
|
+
return isString(descriptionOrOptions)
|
|
109
129
|
? descriptionOrOptions
|
|
110
130
|
: descriptionOrOptions?.description;
|
|
111
131
|
}
|
|
112
132
|
static getHttpExceptionOptionsFrom(descriptionOrOptions) {
|
|
113
|
-
return
|
|
133
|
+
return isString(descriptionOrOptions) ? {} : descriptionOrOptions;
|
|
114
134
|
}
|
|
115
135
|
/**
|
|
116
136
|
* Utility method used to extract the error description and httpExceptionOptions from the given argument.
|
|
@@ -118,10 +138,10 @@ class HttpException extends intrinsic_exception_1.IntrinsicException {
|
|
|
118
138
|
* @returns the error description and the httpExceptionOptions as an object.
|
|
119
139
|
*/
|
|
120
140
|
static extractDescriptionAndOptionsFrom(descriptionOrOptions) {
|
|
121
|
-
const description =
|
|
141
|
+
const description = isString(descriptionOrOptions)
|
|
122
142
|
? descriptionOrOptions
|
|
123
143
|
: descriptionOrOptions?.description;
|
|
124
|
-
const httpExceptionOptions =
|
|
144
|
+
const httpExceptionOptions = isString(descriptionOrOptions)
|
|
125
145
|
? {}
|
|
126
146
|
: descriptionOrOptions;
|
|
127
147
|
return {
|
|
@@ -130,4 +150,3 @@ class HttpException extends intrinsic_exception_1.IntrinsicException {
|
|
|
130
150
|
};
|
|
131
151
|
}
|
|
132
152
|
}
|
|
133
|
-
exports.HttpException = HttpException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.ImATeapotException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *ImATeapotException* type errors.
|
|
8
5
|
*
|
|
@@ -13,7 +10,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
13
10
|
*
|
|
14
11
|
* @publicApi
|
|
15
12
|
*/
|
|
16
|
-
class ImATeapotException extends
|
|
13
|
+
export class ImATeapotException extends HttpException {
|
|
17
14
|
/**
|
|
18
15
|
* Instantiate an `ImATeapotException` Exception.
|
|
19
16
|
*
|
|
@@ -39,8 +36,7 @@ class ImATeapotException extends http_exception_1.HttpException {
|
|
|
39
36
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
40
37
|
*/
|
|
41
38
|
constructor(objectOrError, descriptionOrOptions = `I'm a teapot`) {
|
|
42
|
-
const { description
|
|
43
|
-
super(
|
|
39
|
+
const { description = `I'm a teapot`, httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
40
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.I_AM_A_TEAPOT), HttpStatus.I_AM_A_TEAPOT, httpExceptionOptions);
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
|
-
exports.ImATeapotException = ImATeapotException;
|
package/exceptions/index.d.ts
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
export * from './bad-gateway.exception';
|
|
2
|
-
export * from './bad-request.exception';
|
|
3
|
-
export * from './conflict.exception';
|
|
4
|
-
export * from './forbidden.exception';
|
|
5
|
-
export * from './gateway-timeout.exception';
|
|
6
|
-
export * from './gone.exception';
|
|
7
|
-
export * from './http-version-not-supported.exception';
|
|
8
|
-
export * from './http.exception';
|
|
9
|
-
export * from './im-a-teapot.exception';
|
|
10
|
-
export * from './internal-server-error.exception';
|
|
11
|
-
export * from './intrinsic.exception';
|
|
12
|
-
export * from './method-not-allowed.exception';
|
|
13
|
-
export * from './misdirected.exception';
|
|
14
|
-
export * from './not-acceptable.exception';
|
|
15
|
-
export * from './not-found.exception';
|
|
16
|
-
export * from './not-implemented.exception';
|
|
17
|
-
export * from './payload-too-large.exception';
|
|
18
|
-
export * from './precondition-failed.exception';
|
|
19
|
-
export * from './request-timeout.exception';
|
|
20
|
-
export * from './service-unavailable.exception';
|
|
21
|
-
export * from './unauthorized.exception';
|
|
22
|
-
export * from './unprocessable-entity.exception';
|
|
23
|
-
export * from './unsupported-media-type.exception';
|
|
1
|
+
export * from './bad-gateway.exception.js';
|
|
2
|
+
export * from './bad-request.exception.js';
|
|
3
|
+
export * from './conflict.exception.js';
|
|
4
|
+
export * from './forbidden.exception.js';
|
|
5
|
+
export * from './gateway-timeout.exception.js';
|
|
6
|
+
export * from './gone.exception.js';
|
|
7
|
+
export * from './http-version-not-supported.exception.js';
|
|
8
|
+
export * from './http.exception.js';
|
|
9
|
+
export * from './im-a-teapot.exception.js';
|
|
10
|
+
export * from './internal-server-error.exception.js';
|
|
11
|
+
export * from './intrinsic.exception.js';
|
|
12
|
+
export * from './method-not-allowed.exception.js';
|
|
13
|
+
export * from './misdirected.exception.js';
|
|
14
|
+
export * from './not-acceptable.exception.js';
|
|
15
|
+
export * from './not-found.exception.js';
|
|
16
|
+
export * from './not-implemented.exception.js';
|
|
17
|
+
export * from './payload-too-large.exception.js';
|
|
18
|
+
export * from './precondition-failed.exception.js';
|
|
19
|
+
export * from './request-timeout.exception.js';
|
|
20
|
+
export * from './service-unavailable.exception.js';
|
|
21
|
+
export * from './unauthorized.exception.js';
|
|
22
|
+
export * from './unprocessable-entity.exception.js';
|
|
23
|
+
export * from './unsupported-media-type.exception.js';
|
package/exceptions/index.js
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
tslib_1.__exportStar(require("./unauthorized.exception"), exports);
|
|
25
|
-
tslib_1.__exportStar(require("./unprocessable-entity.exception"), exports);
|
|
26
|
-
tslib_1.__exportStar(require("./unsupported-media-type.exception"), exports);
|
|
1
|
+
export * from './bad-gateway.exception.js';
|
|
2
|
+
export * from './bad-request.exception.js';
|
|
3
|
+
export * from './conflict.exception.js';
|
|
4
|
+
export * from './forbidden.exception.js';
|
|
5
|
+
export * from './gateway-timeout.exception.js';
|
|
6
|
+
export * from './gone.exception.js';
|
|
7
|
+
export * from './http-version-not-supported.exception.js';
|
|
8
|
+
export * from './http.exception.js';
|
|
9
|
+
export * from './im-a-teapot.exception.js';
|
|
10
|
+
export * from './internal-server-error.exception.js';
|
|
11
|
+
export * from './intrinsic.exception.js';
|
|
12
|
+
export * from './method-not-allowed.exception.js';
|
|
13
|
+
export * from './misdirected.exception.js';
|
|
14
|
+
export * from './not-acceptable.exception.js';
|
|
15
|
+
export * from './not-found.exception.js';
|
|
16
|
+
export * from './not-implemented.exception.js';
|
|
17
|
+
export * from './payload-too-large.exception.js';
|
|
18
|
+
export * from './precondition-failed.exception.js';
|
|
19
|
+
export * from './request-timeout.exception.js';
|
|
20
|
+
export * from './service-unavailable.exception.js';
|
|
21
|
+
export * from './unauthorized.exception.js';
|
|
22
|
+
export * from './unprocessable-entity.exception.js';
|
|
23
|
+
export * from './unsupported-media-type.exception.js';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.InternalServerErrorException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Internal Server Error* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class InternalServerErrorException extends
|
|
10
|
+
export class InternalServerErrorException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate an `InternalServerErrorException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class InternalServerErrorException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Internal Server Error') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Internal Server Error', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.INTERNAL_SERVER_ERROR), HttpStatus.INTERNAL_SERVER_ERROR, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.InternalServerErrorException = InternalServerErrorException;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.IntrinsicException = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Exception that represents an intrinsic error in the application.
|
|
6
3
|
* When thrown, the default exception filter will not log the error message.
|
|
7
4
|
*
|
|
8
5
|
* @publicApi
|
|
9
6
|
*/
|
|
10
|
-
class IntrinsicException extends Error {
|
|
7
|
+
export class IntrinsicException extends Error {
|
|
11
8
|
}
|
|
12
|
-
exports.IntrinsicException = IntrinsicException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MethodNotAllowedException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Method Not Allowed* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class MethodNotAllowedException extends
|
|
10
|
+
export class MethodNotAllowedException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `MethodNotAllowedException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class MethodNotAllowedException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Method Not Allowed') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Method Not Allowed', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.METHOD_NOT_ALLOWED), HttpStatus.METHOD_NOT_ALLOWED, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.MethodNotAllowedException = MethodNotAllowedException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.MisdirectedException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Misdirected* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class MisdirectedException extends
|
|
10
|
+
export class MisdirectedException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `MisdirectedException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class MisdirectedException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Misdirected') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Misdirected', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.MISDIRECTED), HttpStatus.MISDIRECTED, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.MisdirectedException = MisdirectedException;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.NotAcceptableException = void 0;
|
|
4
|
-
const http_status_enum_1 = require("../enums/http-status.enum");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
1
|
+
import { HttpStatus } from '../enums/http-status.enum.js';
|
|
2
|
+
import { HttpException } from './http.exception.js';
|
|
6
3
|
/**
|
|
7
4
|
* Defines an HTTP exception for *Not Acceptable* type errors.
|
|
8
5
|
*
|
|
@@ -10,7 +7,7 @@ const http_exception_1 = require("./http.exception");
|
|
|
10
7
|
*
|
|
11
8
|
* @publicApi
|
|
12
9
|
*/
|
|
13
|
-
class NotAcceptableException extends
|
|
10
|
+
export class NotAcceptableException extends HttpException {
|
|
14
11
|
/**
|
|
15
12
|
* Instantiate a `NotAcceptableException` Exception.
|
|
16
13
|
*
|
|
@@ -36,8 +33,7 @@ class NotAcceptableException extends http_exception_1.HttpException {
|
|
|
36
33
|
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
37
34
|
*/
|
|
38
35
|
constructor(objectOrError, descriptionOrOptions = 'Not Acceptable') {
|
|
39
|
-
const { description, httpExceptionOptions } =
|
|
40
|
-
super(
|
|
36
|
+
const { description = 'Not Acceptable', httpExceptionOptions } = HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
37
|
+
super(HttpException.createBody(objectOrError, description, HttpStatus.NOT_ACCEPTABLE), HttpStatus.NOT_ACCEPTABLE, httpExceptionOptions);
|
|
41
38
|
}
|
|
42
39
|
}
|
|
43
|
-
exports.NotAcceptableException = NotAcceptableException;
|