@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
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Controller = void 0;
|
|
4
|
-
const constants_1 = require("../../core/constants");
|
|
5
|
-
const shared_helper_1 = require("../../core/helpers/shared.helper");
|
|
6
|
-
const constants_2 = require("@venok/http/constants");
|
|
7
|
-
/**
|
|
8
|
-
* Decorator that marks a class as a Venok controller that can receive inbound
|
|
9
|
-
* requests and produce responses.
|
|
10
|
-
*
|
|
11
|
-
* An HTTP Controller responds to inbound HTTP Requests and produces HTTP Responses.
|
|
12
|
-
* It defines a class that provides the context for one or more related route
|
|
13
|
-
* handlers that correspond to HTTP request methods and associated routes
|
|
14
|
-
* for example `GET /api/profile`, `POST /users/resume`
|
|
15
|
-
*
|
|
16
|
-
* A Microservice Controller responds to requests as well as events, running over
|
|
17
|
-
* a variety of transports. It defines a class that provides a context for
|
|
18
|
-
* one or more message or event handlers.
|
|
19
|
-
*
|
|
20
|
-
* @param prefixOrOptions a `route path prefix` or a `ControllerOptions` object.
|
|
21
|
-
* A `route path prefix` is pre-pended to the path specified in any request decorator
|
|
22
|
-
* in the class. `ControllerOptions` is an options configuration object specifying:
|
|
23
|
-
* - `scope` - symbol that determines the lifetime of a Controller instance.
|
|
24
|
-
* See Scope for more details.
|
|
25
|
-
* - `prefix` - string that defines a `route path prefix`. The prefix
|
|
26
|
-
* is pre-pended to the path specified in any request decorator in the class.
|
|
27
|
-
* - `version` - string, array of strings, or Symbol that defines the version
|
|
28
|
-
* of all routes in the class. See Versioning
|
|
29
|
-
* for more details.
|
|
30
|
-
*
|
|
31
|
-
* @publicApi
|
|
32
|
-
*/
|
|
33
|
-
function Controller(prefixOrOptions) {
|
|
34
|
-
const defaultPath = "/";
|
|
35
|
-
const [path, host, scopeOptions, versionOptions] = (0, shared_helper_1.isUndefined)(prefixOrOptions)
|
|
36
|
-
? [defaultPath, undefined, undefined, undefined]
|
|
37
|
-
: (0, shared_helper_1.isString)(prefixOrOptions) || Array.isArray(prefixOrOptions)
|
|
38
|
-
? [prefixOrOptions, undefined, undefined, undefined]
|
|
39
|
-
: [
|
|
40
|
-
prefixOrOptions.path || defaultPath,
|
|
41
|
-
prefixOrOptions.host,
|
|
42
|
-
{ scope: prefixOrOptions.scope, durable: prefixOrOptions.durable },
|
|
43
|
-
Array.isArray(prefixOrOptions.version) ? Array.from(new Set(prefixOrOptions.version)) : prefixOrOptions.version,
|
|
44
|
-
];
|
|
45
|
-
return (target) => {
|
|
46
|
-
Reflect.defineMetadata(constants_2.CONTROLLER_WATERMARK, true, target);
|
|
47
|
-
Reflect.defineMetadata(constants_2.PATH_METADATA, path, target);
|
|
48
|
-
Reflect.defineMetadata(constants_2.HOST_METADATA, host, target);
|
|
49
|
-
Reflect.defineMetadata(constants_1.SCOPE_OPTIONS_METADATA, scopeOptions, target);
|
|
50
|
-
Reflect.defineMetadata(constants_2.VERSION_METADATA, versionOptions, target);
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
exports.Controller = Controller;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request method Decorator. Sets a response header.
|
|
3
|
-
*
|
|
4
|
-
* For example:
|
|
5
|
-
* `@Header('Cache-Control', 'none')`
|
|
6
|
-
*
|
|
7
|
-
* @param name string to be used for header name
|
|
8
|
-
* @param value string to be used for header value
|
|
9
|
-
*
|
|
10
|
-
* @publicApi
|
|
11
|
-
*/
|
|
12
|
-
export declare function Header(name: string, value: string): MethodDecorator;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Header = void 0;
|
|
4
|
-
const extends_metadata_helper_1 = require("../../core/helpers/extends-metadata.helper");
|
|
5
|
-
const constants_1 = require("@venok/http/constants");
|
|
6
|
-
/**
|
|
7
|
-
* Request method Decorator. Sets a response header.
|
|
8
|
-
*
|
|
9
|
-
* For example:
|
|
10
|
-
* `@Header('Cache-Control', 'none')`
|
|
11
|
-
*
|
|
12
|
-
* @param name string to be used for header name
|
|
13
|
-
* @param value string to be used for header value
|
|
14
|
-
*
|
|
15
|
-
* @publicApi
|
|
16
|
-
*/
|
|
17
|
-
function Header(name, value) {
|
|
18
|
-
return (target, key, descriptor) => {
|
|
19
|
-
(0, extends_metadata_helper_1.extendArrayMetadata)(constants_1.HEADERS_METADATA, [{ name, value }], descriptor.value);
|
|
20
|
-
return descriptor;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
exports.Header = Header;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
3
|
-
* default status code for the decorated request method.
|
|
4
|
-
*
|
|
5
|
-
* @param statusCode HTTP response code to be returned by route handler.
|
|
6
|
-
*
|
|
7
|
-
* @publicApi
|
|
8
|
-
*/
|
|
9
|
-
export declare function HttpCode(statusCode: number): MethodDecorator;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.HttpCode = void 0;
|
|
4
|
-
const constants_1 = require("@venok/http/constants");
|
|
5
|
-
/**
|
|
6
|
-
* Request method Decorator. Defines the HTTP response status code. Overrides
|
|
7
|
-
* default status code for the decorated request method.
|
|
8
|
-
*
|
|
9
|
-
* @param statusCode HTTP response code to be returned by route handler.
|
|
10
|
-
*
|
|
11
|
-
* @publicApi
|
|
12
|
-
*/
|
|
13
|
-
function HttpCode(statusCode) {
|
|
14
|
-
return (target, key, descriptor) => {
|
|
15
|
-
Reflect.defineMetadata(constants_1.HTTP_CODE_METADATA, statusCode, descriptor.value);
|
|
16
|
-
return descriptor;
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
exports.HttpCode = HttpCode;
|
package/decorators/index.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export * from "./controller.decorator";
|
|
2
|
-
export * from "./header.decorator";
|
|
3
|
-
export * from "./http-code.decorator";
|
|
4
|
-
export * from "./redirect.decorator";
|
|
5
|
-
export * from "./render.decorator";
|
|
6
|
-
export * from "./request-mapping.decorator";
|
|
7
|
-
export * from "./route-params.decorator";
|
|
8
|
-
export * from "./sse.decorator";
|
|
9
|
-
export * from "./version.decorator";
|
package/decorators/index.js
DELETED
|
@@ -1,25 +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("./controller.decorator"), exports);
|
|
18
|
-
__exportStar(require("./header.decorator"), exports);
|
|
19
|
-
__exportStar(require("./http-code.decorator"), exports);
|
|
20
|
-
__exportStar(require("./redirect.decorator"), exports);
|
|
21
|
-
__exportStar(require("./render.decorator"), exports);
|
|
22
|
-
__exportStar(require("./request-mapping.decorator"), exports);
|
|
23
|
-
__exportStar(require("./route-params.decorator"), exports);
|
|
24
|
-
__exportStar(require("./sse.decorator"), exports);
|
|
25
|
-
__exportStar(require("./version.decorator"), exports);
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Redirect = void 0;
|
|
4
|
-
const constants_1 = require("@venok/http/constants");
|
|
5
|
-
/**
|
|
6
|
-
* Redirects request to the specified URL.
|
|
7
|
-
*
|
|
8
|
-
* @publicApi
|
|
9
|
-
*/
|
|
10
|
-
function Redirect(url = "", statusCode) {
|
|
11
|
-
return (target, key, descriptor) => {
|
|
12
|
-
Reflect.defineMetadata(constants_1.REDIRECT_METADATA, { statusCode, url }, descriptor.value);
|
|
13
|
-
return descriptor;
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
exports.Redirect = Redirect;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Route handler method Decorator. Defines a template to be rendered by the controller.
|
|
3
|
-
*
|
|
4
|
-
* For example: `@Render('index')`
|
|
5
|
-
*
|
|
6
|
-
* @param template name of the render engine template file
|
|
7
|
-
*
|
|
8
|
-
* @publicApi
|
|
9
|
-
*/
|
|
10
|
-
export declare function Render(template: string): MethodDecorator;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Render = void 0;
|
|
4
|
-
const constants_1 = require("@venok/http/constants");
|
|
5
|
-
/**
|
|
6
|
-
* Route handler method Decorator. Defines a template to be rendered by the controller.
|
|
7
|
-
*
|
|
8
|
-
* For example: `@Render('index')`
|
|
9
|
-
*
|
|
10
|
-
* @param template name of the render engine template file
|
|
11
|
-
*
|
|
12
|
-
* @publicApi
|
|
13
|
-
*/
|
|
14
|
-
function Render(template) {
|
|
15
|
-
return (target, key, descriptor) => {
|
|
16
|
-
Reflect.defineMetadata(constants_1.RENDER_METADATA, template, descriptor.value);
|
|
17
|
-
return descriptor;
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
exports.Render = Render;
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { RequestMethod } from "@venok/http/enums";
|
|
2
|
-
export interface RequestMappingMetadata {
|
|
3
|
-
path?: string | string[];
|
|
4
|
-
method?: RequestMethod;
|
|
5
|
-
}
|
|
6
|
-
export declare const RequestMapping: (metadata?: RequestMappingMetadata) => MethodDecorator;
|
|
7
|
-
/**
|
|
8
|
-
* Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
|
|
9
|
-
*
|
|
10
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
11
|
-
*
|
|
12
|
-
* @publicApi
|
|
13
|
-
*/
|
|
14
|
-
export declare const Post: (path?: string | string[]) => MethodDecorator;
|
|
15
|
-
/**
|
|
16
|
-
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
|
|
17
|
-
*
|
|
18
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
19
|
-
*
|
|
20
|
-
* @publicApi
|
|
21
|
-
*/
|
|
22
|
-
export declare const Get: (path?: string | string[]) => MethodDecorator;
|
|
23
|
-
/**
|
|
24
|
-
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
|
|
25
|
-
*
|
|
26
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
27
|
-
*
|
|
28
|
-
* @publicApi
|
|
29
|
-
*/
|
|
30
|
-
export declare const Delete: (path?: string | string[]) => MethodDecorator;
|
|
31
|
-
/**
|
|
32
|
-
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
|
|
33
|
-
*
|
|
34
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
35
|
-
*
|
|
36
|
-
* @publicApi
|
|
37
|
-
*/
|
|
38
|
-
export declare const Put: (path?: string | string[]) => MethodDecorator;
|
|
39
|
-
/**
|
|
40
|
-
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
|
|
41
|
-
*
|
|
42
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
43
|
-
*
|
|
44
|
-
* @publicApi
|
|
45
|
-
*/
|
|
46
|
-
export declare const Patch: (path?: string | string[]) => MethodDecorator;
|
|
47
|
-
/**
|
|
48
|
-
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
|
|
49
|
-
*
|
|
50
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
51
|
-
*
|
|
52
|
-
* @publicApi
|
|
53
|
-
*/
|
|
54
|
-
export declare const Options: (path?: string | string[]) => MethodDecorator;
|
|
55
|
-
/**
|
|
56
|
-
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
|
|
57
|
-
*
|
|
58
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
59
|
-
*
|
|
60
|
-
* @publicApi
|
|
61
|
-
*/
|
|
62
|
-
export declare const Head: (path?: string | string[]) => MethodDecorator;
|
|
63
|
-
/**
|
|
64
|
-
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
65
|
-
*
|
|
66
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
67
|
-
*
|
|
68
|
-
* @publicApi
|
|
69
|
-
*/
|
|
70
|
-
export declare const All: (path?: string | string[]) => MethodDecorator;
|
|
71
|
-
/**
|
|
72
|
-
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
73
|
-
*
|
|
74
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
75
|
-
*
|
|
76
|
-
* @publicApi
|
|
77
|
-
*/
|
|
78
|
-
export declare const Search: (path?: string | string[]) => MethodDecorator;
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Search = exports.All = exports.Head = exports.Options = exports.Patch = exports.Put = exports.Delete = exports.Get = exports.Post = exports.RequestMapping = void 0;
|
|
4
|
-
const constants_1 = require("@venok/http/constants");
|
|
5
|
-
const enums_1 = require("@venok/http/enums");
|
|
6
|
-
const defaultMetadata = {
|
|
7
|
-
[constants_1.PATH_METADATA]: "/",
|
|
8
|
-
[constants_1.METHOD_METADATA]: enums_1.RequestMethod.GET,
|
|
9
|
-
};
|
|
10
|
-
const RequestMapping = (metadata = defaultMetadata) => {
|
|
11
|
-
const pathMetadata = metadata[constants_1.PATH_METADATA];
|
|
12
|
-
const path = pathMetadata && pathMetadata.length ? pathMetadata : "/";
|
|
13
|
-
const requestMethod = metadata[constants_1.METHOD_METADATA] || enums_1.RequestMethod.GET;
|
|
14
|
-
return (target, key, descriptor) => {
|
|
15
|
-
Reflect.defineMetadata(constants_1.PATH_METADATA, path, descriptor.value);
|
|
16
|
-
Reflect.defineMetadata(constants_1.METHOD_METADATA, requestMethod, descriptor.value);
|
|
17
|
-
return descriptor;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
exports.RequestMapping = RequestMapping;
|
|
21
|
-
const createMappingDecorator = (method) => (path) => {
|
|
22
|
-
return (0, exports.RequestMapping)({
|
|
23
|
-
[constants_1.PATH_METADATA]: path,
|
|
24
|
-
[constants_1.METHOD_METADATA]: method,
|
|
25
|
-
});
|
|
26
|
-
};
|
|
27
|
-
/**
|
|
28
|
-
* Route handler (method) Decorator. Routes HTTP POST requests to the specified path.
|
|
29
|
-
*
|
|
30
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
31
|
-
*
|
|
32
|
-
* @publicApi
|
|
33
|
-
*/
|
|
34
|
-
exports.Post = createMappingDecorator(enums_1.RequestMethod.POST);
|
|
35
|
-
/**
|
|
36
|
-
* Route handler (method) Decorator. Routes HTTP GET requests to the specified path.
|
|
37
|
-
*
|
|
38
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
39
|
-
*
|
|
40
|
-
* @publicApi
|
|
41
|
-
*/
|
|
42
|
-
exports.Get = createMappingDecorator(enums_1.RequestMethod.GET);
|
|
43
|
-
/**
|
|
44
|
-
* Route handler (method) Decorator. Routes HTTP DELETE requests to the specified path.
|
|
45
|
-
*
|
|
46
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
47
|
-
*
|
|
48
|
-
* @publicApi
|
|
49
|
-
*/
|
|
50
|
-
exports.Delete = createMappingDecorator(enums_1.RequestMethod.DELETE);
|
|
51
|
-
/**
|
|
52
|
-
* Route handler (method) Decorator. Routes HTTP PUT requests to the specified path.
|
|
53
|
-
*
|
|
54
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
55
|
-
*
|
|
56
|
-
* @publicApi
|
|
57
|
-
*/
|
|
58
|
-
exports.Put = createMappingDecorator(enums_1.RequestMethod.PUT);
|
|
59
|
-
/**
|
|
60
|
-
* Route handler (method) Decorator. Routes HTTP PATCH requests to the specified path.
|
|
61
|
-
*
|
|
62
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
63
|
-
*
|
|
64
|
-
* @publicApi
|
|
65
|
-
*/
|
|
66
|
-
exports.Patch = createMappingDecorator(enums_1.RequestMethod.PATCH);
|
|
67
|
-
/**
|
|
68
|
-
* Route handler (method) Decorator. Routes HTTP OPTIONS requests to the specified path.
|
|
69
|
-
*
|
|
70
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
71
|
-
*
|
|
72
|
-
* @publicApi
|
|
73
|
-
*/
|
|
74
|
-
exports.Options = createMappingDecorator(enums_1.RequestMethod.OPTIONS);
|
|
75
|
-
/**
|
|
76
|
-
* Route handler (method) Decorator. Routes HTTP HEAD requests to the specified path.
|
|
77
|
-
*
|
|
78
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
79
|
-
*
|
|
80
|
-
* @publicApi
|
|
81
|
-
*/
|
|
82
|
-
exports.Head = createMappingDecorator(enums_1.RequestMethod.HEAD);
|
|
83
|
-
/**
|
|
84
|
-
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
85
|
-
*
|
|
86
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
87
|
-
*
|
|
88
|
-
* @publicApi
|
|
89
|
-
*/
|
|
90
|
-
exports.All = createMappingDecorator(enums_1.RequestMethod.ALL);
|
|
91
|
-
/**
|
|
92
|
-
* Route handler (method) Decorator. Routes all HTTP requests to the specified path.
|
|
93
|
-
*
|
|
94
|
-
* @see [Routing](https://docs.nestjs.com/controllers#routing)
|
|
95
|
-
*
|
|
96
|
-
* @publicApi
|
|
97
|
-
*/
|
|
98
|
-
exports.Search = createMappingDecorator(enums_1.RequestMethod.SEARCH);
|