@venok/http 1.1.0 → 2.0.0
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/dist/constants.js +33 -0
- package/dist/decorators/controller.decorator.js +45 -0
- package/dist/decorators/header.decorator.js +28 -0
- package/dist/decorators/http-code.decorator.js +22 -0
- package/dist/decorators/http-params.decorator.js +63 -0
- package/dist/decorators/method.decorator.js +57 -0
- package/dist/decorators/redirect.decorator.js +28 -0
- package/dist/decorators/version.decorator.js +31 -0
- package/dist/enums/method.enum.js +32 -0
- package/dist/enums/paramtypes.enum.js +33 -0
- package/dist/enums/status.enum.js +71 -0
- package/dist/enums/version-type.enum.js +27 -0
- package/dist/exceptions/bad-gateway.exception.js +29 -0
- package/dist/exceptions/bad-request.exception.js +29 -0
- package/dist/exceptions/conflict.exception.js +29 -0
- package/dist/exceptions/expectation-failed.exception.js +29 -0
- package/dist/exceptions/failed-dependency.exception.js +29 -0
- package/dist/exceptions/forbidden.exception.js +29 -0
- package/dist/exceptions/gateway-timeout.exception.js +29 -0
- package/dist/exceptions/gone.exception.js +29 -0
- package/dist/exceptions/http-version-not-supported.exception.js +29 -0
- package/dist/exceptions/http.exception.js +94 -0
- package/dist/exceptions/im-a-teapot.exception.js +29 -0
- package/dist/exceptions/internal-server-error.exception.js +29 -0
- package/dist/exceptions/length-required.exception.js +29 -0
- package/dist/exceptions/method-not-allowed.exception.js +29 -0
- package/dist/exceptions/misdirected.exception.js +29 -0
- package/dist/exceptions/not-acceptable.exception.js +29 -0
- package/dist/exceptions/not-found.exception.js +29 -0
- package/dist/exceptions/not-implemented.exception.js +29 -0
- package/dist/exceptions/payload-too-large.exception.js +29 -0
- package/dist/exceptions/payment-required.exception.js +29 -0
- package/dist/exceptions/precondition-failed.exception.js +29 -0
- package/dist/exceptions/precondition-required.exception.js +29 -0
- package/dist/exceptions/proxy-authentication-required.exception.js +29 -0
- package/dist/exceptions/request-timeout.exception.js +29 -0
- package/dist/exceptions/requested-range-not-satisfiable.exception.js +29 -0
- package/dist/exceptions/service-unavailable.exception.js +29 -0
- package/dist/exceptions/too-many-requests.exception.js +29 -0
- package/dist/exceptions/unauthorized.exception.js +29 -0
- package/dist/exceptions/unprocessable-entity.exception.js +29 -0
- package/dist/exceptions/unsupported-media-type.exception.js +29 -0
- package/dist/exceptions/uri-too-long.exception.js +29 -0
- package/dist/filters/context.js +28 -0
- package/dist/filters/filter.js +56 -0
- package/dist/helpers/discovery.helper.js +69 -0
- package/dist/helpers/messages.helper.js +41 -0
- package/dist/helpers/middleware.helper.js +69 -0
- package/dist/helpers/path.helper.js +53 -0
- package/dist/helpers/route.helper.js +54 -0
- package/dist/http/adapter.js +294 -0
- package/dist/http/config.js +67 -0
- package/dist/http/configurable-module.js +26 -0
- package/dist/http/context.js +117 -0
- package/dist/http/explorer.js +133 -0
- package/dist/http/module.js +35 -0
- package/dist/http/starter-module.js +85 -0
- package/dist/index.d.ts +2117 -0
- package/dist/index.js +82 -0
- package/dist/interfaces/adapter.interface.js +0 -0
- package/dist/interfaces/exception.interface.js +0 -0
- package/dist/interfaces/index.js +7 -0
- package/dist/interfaces/middleware/config-proxy.interface.js +0 -0
- package/dist/interfaces/middleware/consumer.interface.js +0 -0
- package/dist/interfaces/middleware/index.js +3 -0
- package/dist/interfaces/options.interface.js +0 -0
- package/dist/interfaces/prefix.interface.js +0 -0
- package/dist/interfaces/router/definition.interface.js +0 -0
- package/dist/interfaces/router/exclude-route.interface.js +0 -0
- package/dist/interfaces/router/index.js +7 -0
- package/dist/interfaces/router/info.interface.js +0 -0
- package/dist/interfaces/router/path-metadata.interface.js +0 -0
- package/dist/interfaces/router/tree.interface.js +0 -0
- package/dist/interfaces/router/version.interface.js +21 -0
- package/dist/middleware/builder.js +96 -0
- package/dist/middleware/module.js +22 -0
- package/dist/middleware/routes-mapper.js +107 -0
- package/dist/middleware/service.js +48 -0
- package/dist/middleware/tree.js +91 -0
- package/dist/router/finder.js +64 -0
- package/dist/router/module.js +89 -0
- package/dist/router/path-factory.js +110 -0
- package/dist/symbols.js +33 -0
- package/package.json +41 -46
- package/adapter/adapter.d.ts +0 -57
- package/adapter/adapter.js +0 -58
- package/adapter/host.d.ts +0 -27
- package/adapter/host.js +0 -33
- package/application/application.d.ts +0 -18
- package/application/application.js +0 -51
- package/application/config.d.ts +0 -16
- package/application/config.js +0 -47
- package/application/http.module-defenition.d.ts +0 -8
- package/application/http.module-defenition.js +0 -6
- package/application/http.module.d.ts +0 -3
- package/application/http.module.js +0 -21
- package/application/http.service.d.ts +0 -11
- package/application/http.service.js +0 -43
- package/application/starter.d.ts +0 -41
- package/application/starter.js +0 -140
- package/constants.d.ts +0 -12
- package/constants.js +0 -15
- package/context/context.d.ts +0 -56
- package/context/context.js +0 -102
- package/context/response.controller.d.ts +0 -30
- package/context/response.controller.js +0 -86
- package/decorators/controller.decorator.d.ts +0 -82
- package/decorators/controller.decorator.js +0 -53
- package/decorators/header.decorator.d.ts +0 -12
- package/decorators/header.decorator.js +0 -23
- package/decorators/http-code.decorator.d.ts +0 -9
- package/decorators/http-code.decorator.js +0 -19
- package/decorators/index.d.ts +0 -9
- package/decorators/index.js +0 -25
- package/decorators/redirect.decorator.d.ts +0 -6
- package/decorators/redirect.decorator.js +0 -16
- package/decorators/render.decorator.d.ts +0 -10
- package/decorators/render.decorator.js +0 -20
- package/decorators/request-mapping.decorator.d.ts +0 -78
- package/decorators/request-mapping.decorator.js +0 -98
- package/decorators/route-params.decorator.d.ts +0 -378
- package/decorators/route-params.decorator.js +0 -227
- package/decorators/sse.decorator.d.ts +0 -6
- package/decorators/sse.decorator.js +0 -20
- package/decorators/version.decorator.d.ts +0 -7
- package/decorators/version.decorator.js +0 -20
- package/enums/http-status.enum.d.ts +0 -53
- package/enums/http-status.enum.js +0 -57
- package/enums/index.d.ts +0 -4
- package/enums/index.js +0 -20
- package/enums/request-method.enum.d.ts +0 -11
- package/enums/request-method.enum.js +0 -15
- package/enums/route-paramtypes.enum.d.ts +0 -14
- package/enums/route-paramtypes.enum.js +0 -18
- package/enums/version-type.enum.d.ts +0 -9
- package/enums/version-type.enum.js +0 -13
- package/errors/bad-gateway.exception.d.ts +0 -33
- package/errors/bad-gateway.exception.js +0 -41
- package/errors/bad-request.exception.d.ts +0 -33
- package/errors/bad-request.exception.js +0 -41
- package/errors/conflict.exception.d.ts +0 -33
- package/errors/conflict.exception.js +0 -41
- package/errors/forbidden.exception.d.ts +0 -33
- package/errors/forbidden.exception.js +0 -41
- package/errors/gateway-timeout.exception.d.ts +0 -33
- package/errors/gateway-timeout.exception.js +0 -41
- package/errors/gone.exception.d.ts +0 -33
- package/errors/gone.exception.js +0 -41
- package/errors/http-version-not-supported.exception.d.ts +0 -33
- package/errors/http-version-not-supported.exception.js +0 -41
- package/errors/http.exception.d.ts +0 -79
- package/errors/http.exception.js +0 -123
- package/errors/im-a-teapot.exception.d.ts +0 -36
- package/errors/im-a-teapot.exception.js +0 -44
- package/errors/index.d.ts +0 -11
- package/errors/index.js +0 -27
- package/errors/internal-server-error.exception.d.ts +0 -33
- package/errors/internal-server-error.exception.js +0 -41
- package/errors/invalid-middleware-configuration.exception.d.ts +0 -4
- package/errors/invalid-middleware-configuration.exception.js +0 -11
- package/errors/invalid-middleware.exception.d.ts +0 -4
- package/errors/invalid-middleware.exception.js +0 -11
- package/errors/not-found.exception.d.ts +0 -33
- package/errors/not-found.exception.js +0 -41
- package/errors/unknown-request-mapping.exception.d.ts +0 -5
- package/errors/unknown-request-mapping.exception.js +0 -11
- package/exceptions/messages.d.ts +0 -4
- package/exceptions/messages.js +0 -13
- package/explorers/path.explorer.d.ts +0 -8
- package/explorers/path.explorer.js +0 -38
- package/explorers/router.explorer.d.ts +0 -51
- package/explorers/router.explorer.js +0 -195
- package/factory/context-id.factory.d.ts +0 -41
- package/factory/context-id.factory.js +0 -52
- package/factory/index.d.ts +0 -4
- package/factory/index.js +0 -20
- package/factory/method.factory.d.ts +0 -5
- package/factory/method.factory.js +0 -30
- package/factory/params.factory.d.ts +0 -5
- package/factory/params.factory.js +0 -39
- package/factory/path.factory.d.ts +0 -13
- package/factory/path.factory.js +0 -95
- package/filters/context.d.ts +0 -9
- package/filters/context.js +0 -15
- package/filters/filter.d.ts +0 -22
- package/filters/filter.js +0 -78
- package/helpers/adapter.helper.d.ts +0 -27
- package/helpers/adapter.helper.js +0 -37
- package/helpers/exclude-route.helper.d.ts +0 -4
- package/helpers/exclude-route.helper.js +0 -18
- package/helpers/flatten-routes.helper.d.ts +0 -5
- package/helpers/flatten-routes.helper.js +0 -27
- package/helpers/index.d.ts +0 -6
- package/helpers/index.js +0 -22
- package/helpers/messages.helper.d.ts +0 -6
- package/helpers/messages.helper.js +0 -25
- package/helpers/path.helper.d.ts +0 -3
- package/helpers/path.helper.js +0 -13
- package/helpers/sse.helper.d.ts +0 -45
- package/helpers/sse.helper.js +0 -83
- package/index.d.ts +0 -1
- package/index.js +0 -3
- package/interfaces/http/cors.interface.d.ts +0 -58
- package/interfaces/http/cors.interface.js +0 -2
- package/interfaces/http/exception.interface.d.ts +0 -6
- package/interfaces/http/exception.interface.js +0 -2
- package/interfaces/http/exclude-route.interface.d.ts +0 -15
- package/interfaces/http/exclude-route.interface.js +0 -2
- package/interfaces/http/index.d.ts +0 -10
- package/interfaces/http/index.js +0 -26
- package/interfaces/http/message-event.interface.d.ts +0 -6
- package/interfaces/http/message-event.interface.js +0 -2
- package/interfaces/http/module.inteface.d.ts +0 -5
- package/interfaces/http/module.inteface.js +0 -2
- package/interfaces/http/options.interface.d.ts +0 -127
- package/interfaces/http/options.interface.js +0 -2
- package/interfaces/http/path-metadata.interface.d.ts +0 -31
- package/interfaces/http/path-metadata.interface.js +0 -2
- package/interfaces/http/prefix-options.interface.d.ts +0 -7
- package/interfaces/http/prefix-options.interface.js +0 -2
- package/interfaces/http/raw-request.d.ts +0 -4
- package/interfaces/http/raw-request.js +0 -2
- package/interfaces/http/routes.interface.d.ts +0 -7
- package/interfaces/http/routes.interface.js +0 -2
- package/interfaces/http/server.interface.d.ts +0 -54
- package/interfaces/http/server.interface.js +0 -2
- package/interfaces/index.d.ts +0 -3
- package/interfaces/index.js +0 -19
- package/interfaces/middleware/config-proxy.interface.d.ts +0 -23
- package/interfaces/middleware/config-proxy.interface.js +0 -2
- package/interfaces/middleware/configuration.interface.d.ts +0 -12
- package/interfaces/middleware/configuration.interface.js +0 -2
- package/interfaces/middleware/consumer.interface.d.ts +0 -16
- package/interfaces/middleware/consumer.interface.js +0 -2
- package/interfaces/middleware/index.d.ts +0 -4
- package/interfaces/middleware/index.js +0 -20
- package/interfaces/middleware/middleware.interface.d.ts +0 -7
- package/interfaces/middleware/middleware.interface.js +0 -2
- package/interfaces/router/callback-paramtypes.interface.d.ts +0 -1
- package/interfaces/router/callback-paramtypes.interface.js +0 -2
- package/interfaces/router/definition.interface.d.ts +0 -10
- package/interfaces/router/definition.interface.js +0 -2
- package/interfaces/router/index.d.ts +0 -3
- package/interfaces/router/index.js +0 -19
- package/interfaces/router/version-options.interface.d.ts +0 -92
- package/interfaces/router/version-options.interface.js +0 -9
- package/middleware/builder.d.ts +0 -15
- package/middleware/builder.js +0 -78
- package/middleware/container.d.ts +0 -13
- package/middleware/container.js +0 -50
- package/middleware/extractor.d.ts +0 -15
- package/middleware/extractor.js +0 -50
- package/middleware/index.d.ts +0 -1
- package/middleware/index.js +0 -17
- package/middleware/module.d.ts +0 -33
- package/middleware/module.js +0 -180
- package/middleware/resolver.d.ts +0 -10
- package/middleware/resolver.js +0 -27
- package/middleware/routes-mapper.d.ts +0 -19
- package/middleware/routes-mapper.js +0 -111
- package/middleware/utils.d.ts +0 -8
- package/middleware/utils.js +0 -86
- package/router/module.d.ts +0 -18
- package/router/module.js +0 -88
- package/router/resolver.d.ts +0 -31
- package/router/resolver.js +0 -128
- package/storage/http-instance.storage.d.ts +0 -9
- package/storage/http-instance.storage.js +0 -19
- package/stream/index.d.ts +0 -1
- package/stream/index.js +0 -17
- package/stream/interfaces/index.d.ts +0 -2
- package/stream/interfaces/index.js +0 -18
- package/stream/interfaces/streamable-handler-response.interface.d.ts +0 -12
- package/stream/interfaces/streamable-handler-response.interface.js +0 -2
- package/stream/interfaces/streamable-options.interface.d.ts +0 -10
- package/stream/interfaces/streamable-options.interface.js +0 -2
- package/stream/streamable-file.d.ts +0 -22
- package/stream/streamable-file.js +0 -55
- package/test/context/response.controller.spec.d.ts +0 -1
- package/test/context/response.controller.spec.js +0 -328
- package/test/decorators/controller.decorator.spec.d.ts +0 -1
- package/test/decorators/controller.decorator.spec.js +0 -113
- package/test/decorators/header.decorator.spec.d.ts +0 -1
- package/test/decorators/header.decorator.spec.js +0 -33
- package/test/decorators/http-code.decorator.spec.d.ts +0 -1
- package/test/decorators/http-code.decorator.spec.js +0 -30
- package/test/decorators/redirect.decorator.spec.d.ts +0 -1
- package/test/decorators/redirect.decorator.spec.js +0 -36
- package/test/decorators/render.decorator.spec.d.ts +0 -1
- package/test/decorators/render.decorator.spec.js +0 -30
- package/test/decorators/request-mapping.decorator.spec.d.ts +0 -1
- package/test/decorators/request-mapping.decorator.spec.js +0 -85
- package/test/decorators/route-params.decorator.spec.d.ts +0 -1
- package/test/decorators/route-params.decorator.spec.js +0 -493
- package/test/decorators/sse.decorator.spec.d.ts +0 -1
- package/test/decorators/sse.decorator.spec.js +0 -35
- package/test/decorators/version.decorator.spec.d.ts +0 -1
- package/test/decorators/version.decorator.spec.js +0 -43
- package/test/exceptions/handler.spec.d.ts +0 -1
- package/test/exceptions/handler.spec.js +0 -145
- package/test/exceptions/proxy.spec.d.ts +0 -1
- package/test/exceptions/proxy.spec.js +0 -74
- package/test/explorers/path.explorer.spec.d.ts +0 -1
- package/test/explorers/path.explorer.spec.js +0 -190
- package/test/explorers/router.explorer.spec.d.ts +0 -1
- package/test/explorers/router.explorer.spec.js +0 -206
- package/test/factory/method.factory.spec.d.ts +0 -1
- package/test/factory/method.factory.spec.js +0 -33
- package/test/factory/params.factory.spec.d.ts +0 -1
- package/test/factory/params.factory.spec.js +0 -104
- package/test/factory/path.factory.spec.d.ts +0 -1
- package/test/factory/path.factory.spec.js +0 -260
- package/test/filters/context.spec.d.ts +0 -1
- package/test/filters/context.spec.js +0 -96
- package/test/filters/filter.spec.d.ts +0 -1
- package/test/filters/filter.spec.js +0 -96
- package/test/helpers/flatten-routes.helper.spec.d.ts +0 -1
- package/test/helpers/flatten-routes.helper.spec.js +0 -131
- package/test/helpers/sse.helper.spec.d.ts +0 -1
- package/test/helpers/sse.helper.spec.js +0 -132
- package/test/middleware/builder.spec.d.ts +0 -1
- package/test/middleware/builder.spec.js +0 -235
- package/test/middleware/container.spec.d.ts +0 -1
- package/test/middleware/container.spec.js +0 -81
- package/test/middleware/module.spec.d.ts +0 -1
- package/test/middleware/module.spec.js +0 -206
- package/test/middleware/route-info-path-extractor.spec.d.ts +0 -1
- package/test/middleware/route-info-path-extractor.spec.js +0 -123
- package/test/middleware/routes-mapper.spec.d.ts +0 -1
- package/test/middleware/routes-mapper.spec.js +0 -162
- package/test/middleware/utils.spec.d.ts +0 -1
- package/test/middleware/utils.spec.js +0 -132
- package/test/router/module.spec.d.ts +0 -1
- package/test/router/module.spec.js +0 -40
- package/test/router/resolver.spec.d.ts +0 -1
- package/test/router/resolver.spec.js +0 -326
- package/tsconfig.tsbuildinfo +0 -1
package/errors/gone.exception.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GoneException = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an HTTP exception for *Gone* type errors.
|
|
8
|
-
*
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
class GoneException extends http_exception_1.HttpException {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a `GoneException` Exception.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* `throw new GoneException()`
|
|
17
|
-
*
|
|
18
|
-
* @usageNotes
|
|
19
|
-
* The HTTP response status code will be 410.
|
|
20
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
21
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
22
|
-
*
|
|
23
|
-
* By default, the JSON response body contains two properties:
|
|
24
|
-
* - `statusCode`: this will be the value 410.
|
|
25
|
-
* - `message`: the string `'Gone'` by default; override this by supplying
|
|
26
|
-
* a string in the `objectOrError` parameter.
|
|
27
|
-
*
|
|
28
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
29
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
30
|
-
* entire JSON response body, pass an object instead. Nest will serialize the object
|
|
31
|
-
* and return it as the JSON response body.
|
|
32
|
-
*
|
|
33
|
-
* @param objectOrError string or object describing the error condition.
|
|
34
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
35
|
-
*/
|
|
36
|
-
constructor(objectOrError, descriptionOrOptions = "Gone") {
|
|
37
|
-
const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
38
|
-
super(http_exception_1.HttpException.createBody(objectOrError, description, enums_1.HttpStatus.GONE), enums_1.HttpStatus.GONE, httpExceptionOptions);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.GoneException = GoneException;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { HttpException, HttpExceptionOptions } from "./http.exception";
|
|
2
|
-
/**
|
|
3
|
-
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
|
4
|
-
*
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export declare class HttpVersionNotSupportedException extends HttpException {
|
|
8
|
-
/**
|
|
9
|
-
* Instantiate a `HttpVersionNotSupportedException` Exception.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* `throw new HttpVersionNotSupportedException()`
|
|
13
|
-
*
|
|
14
|
-
* @usageNotes
|
|
15
|
-
* The HTTP response status code will be 505.
|
|
16
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
17
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
18
|
-
*
|
|
19
|
-
* By default, the JSON response body contains two properties:
|
|
20
|
-
* - `statusCode`: this will be the value 505.
|
|
21
|
-
* - `message`: the string `'HTTP Version Not Supported'` by default; override this by supplying
|
|
22
|
-
* a string in the `objectOrError` parameter.
|
|
23
|
-
*
|
|
24
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
25
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
26
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
27
|
-
* and return it as the JSON response body.
|
|
28
|
-
*
|
|
29
|
-
* @param objectOrError string or object describing the error condition.
|
|
30
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
31
|
-
*/
|
|
32
|
-
constructor(objectOrError?: string | object | any, descriptionOrOptions?: string | HttpExceptionOptions);
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpVersionNotSupportedException = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an HTTP exception for *Http Version Not Supported* type errors.
|
|
8
|
-
*
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
class HttpVersionNotSupportedException extends http_exception_1.HttpException {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a `HttpVersionNotSupportedException` Exception.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* `throw new HttpVersionNotSupportedException()`
|
|
17
|
-
*
|
|
18
|
-
* @usageNotes
|
|
19
|
-
* The HTTP response status code will be 505.
|
|
20
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
21
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
22
|
-
*
|
|
23
|
-
* By default, the JSON response body contains two properties:
|
|
24
|
-
* - `statusCode`: this will be the value 505.
|
|
25
|
-
* - `message`: the string `'HTTP Version Not Supported'` by default; override this by supplying
|
|
26
|
-
* a string in the `objectOrError` parameter.
|
|
27
|
-
*
|
|
28
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
29
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
30
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
31
|
-
* and return it as the JSON response body.
|
|
32
|
-
*
|
|
33
|
-
* @param objectOrError string or object describing the error condition.
|
|
34
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
35
|
-
*/
|
|
36
|
-
constructor(objectOrError, descriptionOrOptions = "HTTP Version Not Supported") {
|
|
37
|
-
const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
38
|
-
super(http_exception_1.HttpException.createBody(objectOrError, description ?? "", enums_1.HttpStatus.HTTP_VERSION_NOT_SUPPORTED), enums_1.HttpStatus.HTTP_VERSION_NOT_SUPPORTED, httpExceptionOptions);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.HttpVersionNotSupportedException = HttpVersionNotSupportedException;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { HttpExceptionBody, HttpExceptionBodyMessage } from "@venok/http/interfaces/http/exception.interface";
|
|
2
|
-
export interface HttpExceptionOptions {
|
|
3
|
-
/** original cause of the error */
|
|
4
|
-
cause?: unknown;
|
|
5
|
-
description?: string;
|
|
6
|
-
}
|
|
7
|
-
export interface DescriptionAndOptions {
|
|
8
|
-
description?: string;
|
|
9
|
-
httpExceptionOptions?: HttpExceptionOptions;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Defines the base Venok HTTP exception, which is handled by the default
|
|
13
|
-
* Exceptions Handler.
|
|
14
|
-
*
|
|
15
|
-
* @publicApi
|
|
16
|
-
*/
|
|
17
|
-
export declare class HttpException extends Error {
|
|
18
|
-
private readonly response;
|
|
19
|
-
private readonly status;
|
|
20
|
-
private readonly options?;
|
|
21
|
-
/**
|
|
22
|
-
* Instantiate a plain HTTP Exception.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* throw new HttpException()
|
|
26
|
-
* throw new HttpException('message', HttpStatus.BAD_REQUEST)
|
|
27
|
-
* throw new HttpException('custom message', HttpStatus.BAD_REQUEST, {
|
|
28
|
-
* cause: new Error('Cause Error'),
|
|
29
|
-
* })
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* @usageNotes
|
|
33
|
-
* The constructor arguments define the response and the HTTP response status code.
|
|
34
|
-
* - The `response` argument (required) defines the JSON response body. alternatively, it can also be
|
|
35
|
-
* an error object that is used to define an error [cause](https://nodejs.org/en/blog/release/v16.9.0/#error-cause).
|
|
36
|
-
* - The `status` argument (required) defines the HTTP Status Code.
|
|
37
|
-
* - The `options` argument (optional) defines additional error options. Currently, it supports the `cause` attribute,
|
|
38
|
-
* and can be used as an alternative way to specify the error cause: `const error = new HttpException('description', 400, { cause: new Error() });`
|
|
39
|
-
*
|
|
40
|
-
* By default, the JSON response body contains two properties:
|
|
41
|
-
* - `statusCode`: the Http Status Code.
|
|
42
|
-
* - `message`: a short description of the HTTP error by default; override this
|
|
43
|
-
* by supplying a string in the `response` parameter.
|
|
44
|
-
*
|
|
45
|
-
* To override the entire JSON response body, pass an object to the `createBody`
|
|
46
|
-
* method. Venok will serialize the object and return it as the JSON response body.
|
|
47
|
-
*
|
|
48
|
-
* The `status` argument is required, and should be a valid HTTP status code.
|
|
49
|
-
* Best practice is to use the `HttpStatus` enum.
|
|
50
|
-
*
|
|
51
|
-
* @param response string, object describing the error condition or the error cause.
|
|
52
|
-
* @param status HTTP response status code.
|
|
53
|
-
* @param options An object used to add an error cause.
|
|
54
|
-
*/
|
|
55
|
-
constructor(response: string | Record<string, any>, status: number, options?: HttpExceptionOptions | undefined);
|
|
56
|
-
cause: unknown;
|
|
57
|
-
/**
|
|
58
|
-
* Configures error chaining support
|
|
59
|
-
*
|
|
60
|
-
* @see https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
61
|
-
* @see https://github.com/microsoft/TypeScript/issues/45167
|
|
62
|
-
*/
|
|
63
|
-
initCause(): void;
|
|
64
|
-
initMessage(): void;
|
|
65
|
-
initName(): void;
|
|
66
|
-
getResponse(): string | object;
|
|
67
|
-
getStatus(): number;
|
|
68
|
-
static createBody(nil: null | "", message: HttpExceptionBodyMessage, statusCode: number): HttpExceptionBody;
|
|
69
|
-
static createBody(message: HttpExceptionBodyMessage, error: string, statusCode: number): HttpExceptionBody;
|
|
70
|
-
static createBody<Body extends Record<string, unknown>>(custom: Body): Body;
|
|
71
|
-
static getDescriptionFrom(descriptionOrOptions: string | HttpExceptionOptions): string;
|
|
72
|
-
static getHttpExceptionOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): HttpExceptionOptions;
|
|
73
|
-
/**
|
|
74
|
-
* Utility method used to extract the error description and httpExceptionOptions from the given argument.
|
|
75
|
-
* This is used by inheriting classes to correctly parse both options.
|
|
76
|
-
* @returns the error description and the httpExceptionOptions as an object.
|
|
77
|
-
*/
|
|
78
|
-
static extractDescriptionAndOptionsFrom(descriptionOrOptions: string | HttpExceptionOptions): DescriptionAndOptions;
|
|
79
|
-
}
|
package/errors/http.exception.js
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpException = void 0;
|
|
4
|
-
const shared_helper_1 = require("../../core/helpers/shared.helper");
|
|
5
|
-
/**
|
|
6
|
-
* Defines the base Venok HTTP exception, which is handled by the default
|
|
7
|
-
* Exceptions Handler.
|
|
8
|
-
*
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
class HttpException extends Error {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a plain HTTP Exception.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* throw new HttpException()
|
|
17
|
-
* throw new HttpException('message', HttpStatus.BAD_REQUEST)
|
|
18
|
-
* throw new HttpException('custom message', HttpStatus.BAD_REQUEST, {
|
|
19
|
-
* cause: new Error('Cause Error'),
|
|
20
|
-
* })
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* @usageNotes
|
|
24
|
-
* The constructor arguments define the response and the HTTP response status code.
|
|
25
|
-
* - The `response` argument (required) defines the JSON response body. alternatively, it can also be
|
|
26
|
-
* an error object that is used to define an error [cause](https://nodejs.org/en/blog/release/v16.9.0/#error-cause).
|
|
27
|
-
* - The `status` argument (required) defines the HTTP Status Code.
|
|
28
|
-
* - The `options` argument (optional) defines additional error options. Currently, it supports the `cause` attribute,
|
|
29
|
-
* and can be used as an alternative way to specify the error cause: `const error = new HttpException('description', 400, { cause: new Error() });`
|
|
30
|
-
*
|
|
31
|
-
* By default, the JSON response body contains two properties:
|
|
32
|
-
* - `statusCode`: the Http Status Code.
|
|
33
|
-
* - `message`: a short description of the HTTP error by default; override this
|
|
34
|
-
* by supplying a string in the `response` parameter.
|
|
35
|
-
*
|
|
36
|
-
* To override the entire JSON response body, pass an object to the `createBody`
|
|
37
|
-
* method. Venok will serialize the object and return it as the JSON response body.
|
|
38
|
-
*
|
|
39
|
-
* The `status` argument is required, and should be a valid HTTP status code.
|
|
40
|
-
* Best practice is to use the `HttpStatus` enum.
|
|
41
|
-
*
|
|
42
|
-
* @param response string, object describing the error condition or the error cause.
|
|
43
|
-
* @param status HTTP response status code.
|
|
44
|
-
* @param options An object used to add an error cause.
|
|
45
|
-
*/
|
|
46
|
-
constructor(response, status, options) {
|
|
47
|
-
super();
|
|
48
|
-
this.response = response;
|
|
49
|
-
this.status = status;
|
|
50
|
-
this.options = options;
|
|
51
|
-
this.initMessage();
|
|
52
|
-
this.initName();
|
|
53
|
-
this.initCause();
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Configures error chaining support
|
|
57
|
-
*
|
|
58
|
-
* @see https://nodejs.org/en/blog/release/v16.9.0/#error-cause
|
|
59
|
-
* @see https://github.com/microsoft/TypeScript/issues/45167
|
|
60
|
-
*/
|
|
61
|
-
initCause() {
|
|
62
|
-
if (this.options?.cause) {
|
|
63
|
-
this.cause = this.options.cause;
|
|
64
|
-
return;
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
initMessage() {
|
|
68
|
-
if ((0, shared_helper_1.isString)(this.response)) {
|
|
69
|
-
this.message = this.response;
|
|
70
|
-
}
|
|
71
|
-
else if ((0, shared_helper_1.isObject)(this.response) && (0, shared_helper_1.isString)(this.response.message)) {
|
|
72
|
-
this.message = this.response.message;
|
|
73
|
-
}
|
|
74
|
-
else if (this.constructor) {
|
|
75
|
-
this.message = this.constructor.name.match(/[A-Z][a-z]+|[0-9]+/g)?.join(" ") ?? "Error";
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
initName() {
|
|
79
|
-
this.name = this.constructor.name;
|
|
80
|
-
}
|
|
81
|
-
getResponse() {
|
|
82
|
-
return this.response;
|
|
83
|
-
}
|
|
84
|
-
getStatus() {
|
|
85
|
-
return this.status;
|
|
86
|
-
}
|
|
87
|
-
static createBody(arg0, arg1, statusCode) {
|
|
88
|
-
if (!arg0) {
|
|
89
|
-
return {
|
|
90
|
-
message: arg1,
|
|
91
|
-
statusCode: statusCode,
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
if ((0, shared_helper_1.isString)(arg0) || Array.isArray(arg0)) {
|
|
95
|
-
return {
|
|
96
|
-
message: arg0,
|
|
97
|
-
error: arg1,
|
|
98
|
-
statusCode: statusCode,
|
|
99
|
-
};
|
|
100
|
-
}
|
|
101
|
-
return arg0;
|
|
102
|
-
}
|
|
103
|
-
static getDescriptionFrom(descriptionOrOptions) {
|
|
104
|
-
return (0, shared_helper_1.isString)(descriptionOrOptions) ? descriptionOrOptions : descriptionOrOptions.description;
|
|
105
|
-
}
|
|
106
|
-
static getHttpExceptionOptionsFrom(descriptionOrOptions) {
|
|
107
|
-
return (0, shared_helper_1.isString)(descriptionOrOptions) ? {} : descriptionOrOptions;
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Utility method used to extract the error description and httpExceptionOptions from the given argument.
|
|
111
|
-
* This is used by inheriting classes to correctly parse both options.
|
|
112
|
-
* @returns the error description and the httpExceptionOptions as an object.
|
|
113
|
-
*/
|
|
114
|
-
static extractDescriptionAndOptionsFrom(descriptionOrOptions) {
|
|
115
|
-
const description = (0, shared_helper_1.isString)(descriptionOrOptions) ? descriptionOrOptions : descriptionOrOptions?.description;
|
|
116
|
-
const httpExceptionOptions = (0, shared_helper_1.isString)(descriptionOrOptions) ? {} : descriptionOrOptions;
|
|
117
|
-
return {
|
|
118
|
-
description,
|
|
119
|
-
httpExceptionOptions,
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.HttpException = HttpException;
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { HttpException, HttpExceptionOptions } from "./http.exception";
|
|
2
|
-
/**
|
|
3
|
-
* Defines an HTTP exception for *ImATeapotException* type errors.
|
|
4
|
-
*
|
|
5
|
-
* Any attempt to brew coffee with a teapot should result in the error code
|
|
6
|
-
* "418 I'm a teapot". The resulting entity body MAY be short and stout.
|
|
7
|
-
*
|
|
8
|
-
* @publicApi
|
|
9
|
-
*/
|
|
10
|
-
export declare class ImATeapotException extends HttpException {
|
|
11
|
-
/**
|
|
12
|
-
* Instantiate an `ImATeapotException` Exception.
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* `throw new ImATeapotException()`
|
|
16
|
-
*
|
|
17
|
-
* @usageNotes
|
|
18
|
-
* The HTTP response status code will be 418.
|
|
19
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
20
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
21
|
-
*
|
|
22
|
-
* By default, the JSON response body contains two properties:
|
|
23
|
-
* - `statusCode`: this will be the value 418.
|
|
24
|
-
* - `message`: the string `"I'm a Teapot"` by default; override this by supplying
|
|
25
|
-
* a string in the `objectOrError` parameter.
|
|
26
|
-
*
|
|
27
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
28
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
29
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
30
|
-
* and return it as the JSON response body.
|
|
31
|
-
*
|
|
32
|
-
* @param objectOrError string or object describing the error condition.
|
|
33
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
34
|
-
*/
|
|
35
|
-
constructor(objectOrError?: string | object | any, descriptionOrOptions?: string | HttpExceptionOptions);
|
|
36
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ImATeapotException = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an HTTP exception for *ImATeapotException* type errors.
|
|
8
|
-
*
|
|
9
|
-
* Any attempt to brew coffee with a teapot should result in the error code
|
|
10
|
-
* "418 I'm a teapot". The resulting entity body MAY be short and stout.
|
|
11
|
-
*
|
|
12
|
-
* @publicApi
|
|
13
|
-
*/
|
|
14
|
-
class ImATeapotException extends http_exception_1.HttpException {
|
|
15
|
-
/**
|
|
16
|
-
* Instantiate an `ImATeapotException` Exception.
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* `throw new ImATeapotException()`
|
|
20
|
-
*
|
|
21
|
-
* @usageNotes
|
|
22
|
-
* The HTTP response status code will be 418.
|
|
23
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
24
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
25
|
-
*
|
|
26
|
-
* By default, the JSON response body contains two properties:
|
|
27
|
-
* - `statusCode`: this will be the value 418.
|
|
28
|
-
* - `message`: the string `"I'm a Teapot"` by default; override this by supplying
|
|
29
|
-
* a string in the `objectOrError` parameter.
|
|
30
|
-
*
|
|
31
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
32
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
33
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
34
|
-
* and return it as the JSON response body.
|
|
35
|
-
*
|
|
36
|
-
* @param objectOrError string or object describing the error condition.
|
|
37
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
38
|
-
*/
|
|
39
|
-
constructor(objectOrError, descriptionOrOptions = `I'm a teapot`) {
|
|
40
|
-
const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
41
|
-
super(http_exception_1.HttpException.createBody(objectOrError, description ?? "", enums_1.HttpStatus.I_AM_A_TEAPOT), enums_1.HttpStatus.I_AM_A_TEAPOT, httpExceptionOptions);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
exports.ImATeapotException = ImATeapotException;
|
package/errors/index.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export * from "./bad-request.exception";
|
|
2
|
-
export * from "./http.exception";
|
|
3
|
-
export * from "./forbidden.exception";
|
|
4
|
-
export * from "./conflict.exception";
|
|
5
|
-
export * from "./gone.exception";
|
|
6
|
-
export * from "./internal-server-error.exception";
|
|
7
|
-
export * from "./http-version-not-supported.exception";
|
|
8
|
-
export * from "./bad-gateway.exception";
|
|
9
|
-
export * from "./gateway-timeout.exception";
|
|
10
|
-
export * from "./im-a-teapot.exception";
|
|
11
|
-
export * from "./not-found.exception";
|
package/errors/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./bad-request.exception"), exports);
|
|
18
|
-
__exportStar(require("./http.exception"), exports);
|
|
19
|
-
__exportStar(require("./forbidden.exception"), exports);
|
|
20
|
-
__exportStar(require("./conflict.exception"), exports);
|
|
21
|
-
__exportStar(require("./gone.exception"), exports);
|
|
22
|
-
__exportStar(require("./internal-server-error.exception"), exports);
|
|
23
|
-
__exportStar(require("./http-version-not-supported.exception"), exports);
|
|
24
|
-
__exportStar(require("./bad-gateway.exception"), exports);
|
|
25
|
-
__exportStar(require("./gateway-timeout.exception"), exports);
|
|
26
|
-
__exportStar(require("./im-a-teapot.exception"), exports);
|
|
27
|
-
__exportStar(require("./not-found.exception"), exports);
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { HttpException, HttpExceptionOptions } from "./http.exception";
|
|
2
|
-
/**
|
|
3
|
-
* Defines an HTTP exception for *Internal Server Error* type errors.
|
|
4
|
-
*
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export declare class InternalServerErrorException extends HttpException {
|
|
8
|
-
/**
|
|
9
|
-
* Instantiate an `InternalServerErrorException` Exception.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* `throw new InternalServerErrorException()`
|
|
13
|
-
*
|
|
14
|
-
* @usageNotes
|
|
15
|
-
* The HTTP response status code will be 500.
|
|
16
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
17
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
18
|
-
*
|
|
19
|
-
* By default, the JSON response body contains two properties:
|
|
20
|
-
* - `statusCode`: this will be the value 500.
|
|
21
|
-
* - `message`: the string `'Internal Server Error'` by default; override this by supplying
|
|
22
|
-
* a string in the `objectOrError` parameter.
|
|
23
|
-
*
|
|
24
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
25
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
26
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
27
|
-
* and return it as the JSON response body.
|
|
28
|
-
*
|
|
29
|
-
* @param objectOrError string or object describing the error condition.
|
|
30
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
31
|
-
*/
|
|
32
|
-
constructor(objectOrError?: string | object | any, descriptionOrOptions?: string | HttpExceptionOptions);
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InternalServerErrorException = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an HTTP exception for *Internal Server Error* type errors.
|
|
8
|
-
*
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
class InternalServerErrorException extends http_exception_1.HttpException {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate an `InternalServerErrorException` Exception.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* `throw new InternalServerErrorException()`
|
|
17
|
-
*
|
|
18
|
-
* @usageNotes
|
|
19
|
-
* The HTTP response status code will be 500.
|
|
20
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
21
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
22
|
-
*
|
|
23
|
-
* By default, the JSON response body contains two properties:
|
|
24
|
-
* - `statusCode`: this will be the value 500.
|
|
25
|
-
* - `message`: the string `'Internal Server Error'` by default; override this by supplying
|
|
26
|
-
* a string in the `objectOrError` parameter.
|
|
27
|
-
*
|
|
28
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
29
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
30
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
31
|
-
* and return it as the JSON response body.
|
|
32
|
-
*
|
|
33
|
-
* @param objectOrError string or object describing the error condition.
|
|
34
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
35
|
-
*/
|
|
36
|
-
constructor(objectOrError, descriptionOrOptions = "Internal Server Error") {
|
|
37
|
-
const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
38
|
-
super(http_exception_1.HttpException.createBody(objectOrError, description, enums_1.HttpStatus.INTERNAL_SERVER_ERROR), enums_1.HttpStatus.INTERNAL_SERVER_ERROR, httpExceptionOptions);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.InternalServerErrorException = InternalServerErrorException;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidMiddlewareConfigurationException = void 0;
|
|
4
|
-
const exceptions_1 = require("../../core/errors/exceptions");
|
|
5
|
-
const messages_1 = require("../exceptions/messages");
|
|
6
|
-
class InvalidMiddlewareConfigurationException extends exceptions_1.RuntimeException {
|
|
7
|
-
constructor() {
|
|
8
|
-
super(messages_1.INVALID_MIDDLEWARE_CONFIGURATION);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.InvalidMiddlewareConfigurationException = InvalidMiddlewareConfigurationException;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.InvalidMiddlewareException = void 0;
|
|
4
|
-
const exceptions_1 = require("../../core/errors/exceptions");
|
|
5
|
-
const messages_1 = require("../exceptions/messages");
|
|
6
|
-
class InvalidMiddlewareException extends exceptions_1.RuntimeException {
|
|
7
|
-
constructor(name) {
|
|
8
|
-
super((0, messages_1.INVALID_MIDDLEWARE_MESSAGE) `${name}`);
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.InvalidMiddlewareException = InvalidMiddlewareException;
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { HttpException, HttpExceptionOptions } from "./http.exception";
|
|
2
|
-
/**
|
|
3
|
-
* Defines an HTTP exception for *Not Found* type errors.
|
|
4
|
-
*
|
|
5
|
-
* @publicApi
|
|
6
|
-
*/
|
|
7
|
-
export declare class NotFoundException extends HttpException {
|
|
8
|
-
/**
|
|
9
|
-
* Instantiate a `NotFoundException` Exception.
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* `throw new NotFoundException()`
|
|
13
|
-
*
|
|
14
|
-
* @usageNotes
|
|
15
|
-
* The HTTP response status code will be 404.
|
|
16
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
17
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
18
|
-
*
|
|
19
|
-
* By default, the JSON response body contains two properties:
|
|
20
|
-
* - `statusCode`: this will be the value 404.
|
|
21
|
-
* - `message`: the string `'Not Found'` by default; override this by supplying
|
|
22
|
-
* a string in the `objectOrError` parameter.
|
|
23
|
-
*
|
|
24
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
25
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
26
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
27
|
-
* and return it as the JSON response body.
|
|
28
|
-
*
|
|
29
|
-
* @param objectOrError string or object describing the error condition.
|
|
30
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
31
|
-
*/
|
|
32
|
-
constructor(objectOrError?: string | object | any, descriptionOrOptions?: string | HttpExceptionOptions);
|
|
33
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NotFoundException = void 0;
|
|
4
|
-
const enums_1 = require("../enums");
|
|
5
|
-
const http_exception_1 = require("./http.exception");
|
|
6
|
-
/**
|
|
7
|
-
* Defines an HTTP exception for *Not Found* type errors.
|
|
8
|
-
*
|
|
9
|
-
* @publicApi
|
|
10
|
-
*/
|
|
11
|
-
class NotFoundException extends http_exception_1.HttpException {
|
|
12
|
-
/**
|
|
13
|
-
* Instantiate a `NotFoundException` Exception.
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* `throw new NotFoundException()`
|
|
17
|
-
*
|
|
18
|
-
* @usageNotes
|
|
19
|
-
* The HTTP response status code will be 404.
|
|
20
|
-
* - The `objectOrError` argument defines the JSON response body or the message string.
|
|
21
|
-
* - The `descriptionOrOptions` argument contains either a short description of the HTTP error or an options object used to provide an underlying error cause.
|
|
22
|
-
*
|
|
23
|
-
* By default, the JSON response body contains two properties:
|
|
24
|
-
* - `statusCode`: this will be the value 404.
|
|
25
|
-
* - `message`: the string `'Not Found'` by default; override this by supplying
|
|
26
|
-
* a string in the `objectOrError` parameter.
|
|
27
|
-
*
|
|
28
|
-
* If the parameter `objectOrError` is a string, the response body will contain an
|
|
29
|
-
* additional property, `error`, with a short description of the HTTP error. To override the
|
|
30
|
-
* entire JSON response body, pass an object instead. Venok will serialize the object
|
|
31
|
-
* and return it as the JSON response body.
|
|
32
|
-
*
|
|
33
|
-
* @param objectOrError string or object describing the error condition.
|
|
34
|
-
* @param descriptionOrOptions either a short description of the HTTP error or an options object used to provide an underlying error cause
|
|
35
|
-
*/
|
|
36
|
-
constructor(objectOrError, descriptionOrOptions = "Not Found") {
|
|
37
|
-
const { description, httpExceptionOptions } = http_exception_1.HttpException.extractDescriptionAndOptionsFrom(descriptionOrOptions);
|
|
38
|
-
super(http_exception_1.HttpException.createBody(objectOrError, description, enums_1.HttpStatus.NOT_FOUND), enums_1.HttpStatus.NOT_FOUND, httpExceptionOptions);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
exports.NotFoundException = NotFoundException;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnknownRequestMappingException = void 0;
|
|
4
|
-
const exceptions_1 = require("../../core/errors/exceptions");
|
|
5
|
-
const messages_1 = require("../exceptions/messages");
|
|
6
|
-
class UnknownRequestMappingException extends exceptions_1.RuntimeException {
|
|
7
|
-
constructor(metatype) {
|
|
8
|
-
super((0, messages_1.UNKNOWN_REQUEST_MAPPING)(metatype));
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
exports.UnknownRequestMappingException = UnknownRequestMappingException;
|
package/exceptions/messages.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { Type } from "@venok/core";
|
|
2
|
-
export declare const UNKNOWN_REQUEST_MAPPING: (metatype: Type) => string;
|
|
3
|
-
export declare const INVALID_MIDDLEWARE_CONFIGURATION = "An invalid middleware configuration has been passed inside the module 'configure()' method.";
|
|
4
|
-
export declare const INVALID_MIDDLEWARE_MESSAGE: (text: TemplateStringsArray, name: string) => string;
|