@venok/http 1.1.0 → 2.0.1-next.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/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,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const chai_1 = require("chai");
|
|
13
|
-
const enums_1 = require("@venok/http/enums");
|
|
14
|
-
const decorators_1 = require("@venok/http/decorators");
|
|
15
|
-
describe("@RequestMapping", () => {
|
|
16
|
-
const requestProps = {
|
|
17
|
-
path: "test",
|
|
18
|
-
method: enums_1.RequestMethod.ALL,
|
|
19
|
-
};
|
|
20
|
-
const requestPropsUsingArray = {
|
|
21
|
-
path: ["foo", "bar"],
|
|
22
|
-
method: enums_1.RequestMethod.ALL,
|
|
23
|
-
};
|
|
24
|
-
it("should enhance class with expected request metadata", () => {
|
|
25
|
-
class Test {
|
|
26
|
-
static test() { }
|
|
27
|
-
static testUsingArray() { }
|
|
28
|
-
}
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, decorators_1.RequestMapping)(requestProps),
|
|
31
|
-
__metadata("design:type", Function),
|
|
32
|
-
__metadata("design:paramtypes", []),
|
|
33
|
-
__metadata("design:returntype", void 0)
|
|
34
|
-
], Test, "test", null);
|
|
35
|
-
__decorate([
|
|
36
|
-
(0, decorators_1.RequestMapping)(requestPropsUsingArray),
|
|
37
|
-
__metadata("design:type", Function),
|
|
38
|
-
__metadata("design:paramtypes", []),
|
|
39
|
-
__metadata("design:returntype", void 0)
|
|
40
|
-
], Test, "testUsingArray", null);
|
|
41
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
42
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
43
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
44
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
45
|
-
(0, chai_1.expect)(path).to.be.eql(requestProps.path);
|
|
46
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
47
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPropsUsingArray.path);
|
|
48
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
49
|
-
});
|
|
50
|
-
it("should set request method on GET by default", () => {
|
|
51
|
-
class Test {
|
|
52
|
-
static test() { }
|
|
53
|
-
}
|
|
54
|
-
__decorate([
|
|
55
|
-
(0, decorators_1.RequestMapping)({ path: "" }),
|
|
56
|
-
__metadata("design:type", Function),
|
|
57
|
-
__metadata("design:paramtypes", []),
|
|
58
|
-
__metadata("design:returntype", void 0)
|
|
59
|
-
], Test, "test", null);
|
|
60
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
61
|
-
(0, chai_1.expect)(method).to.be.eql(enums_1.RequestMethod.GET);
|
|
62
|
-
});
|
|
63
|
-
it('should set path on "/" by default', () => {
|
|
64
|
-
class Test {
|
|
65
|
-
static test() { }
|
|
66
|
-
static testUsingArray() { }
|
|
67
|
-
}
|
|
68
|
-
__decorate([
|
|
69
|
-
(0, decorators_1.RequestMapping)({}),
|
|
70
|
-
__metadata("design:type", Function),
|
|
71
|
-
__metadata("design:paramtypes", []),
|
|
72
|
-
__metadata("design:returntype", void 0)
|
|
73
|
-
], Test, "test", null);
|
|
74
|
-
__decorate([
|
|
75
|
-
(0, decorators_1.RequestMapping)({ path: [] }),
|
|
76
|
-
__metadata("design:type", Function),
|
|
77
|
-
__metadata("design:paramtypes", []),
|
|
78
|
-
__metadata("design:returntype", void 0)
|
|
79
|
-
], Test, "testUsingArray", null);
|
|
80
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
81
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
82
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
83
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
84
|
-
});
|
|
85
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,493 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
-
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
const chai_1 = require("chai");
|
|
16
|
-
const enums_1 = require("@venok/http/enums");
|
|
17
|
-
const decorators_1 = require("@venok/http/decorators");
|
|
18
|
-
describe("@Get", () => {
|
|
19
|
-
const requestPath = "test";
|
|
20
|
-
const requestProps = {
|
|
21
|
-
path: requestPath,
|
|
22
|
-
method: enums_1.RequestMethod.GET,
|
|
23
|
-
};
|
|
24
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
25
|
-
const requestPropsUsingArray = {
|
|
26
|
-
path: requestPathUsingArray,
|
|
27
|
-
method: enums_1.RequestMethod.GET,
|
|
28
|
-
};
|
|
29
|
-
it("should enhance class with expected request metadata", () => {
|
|
30
|
-
class Test {
|
|
31
|
-
static test(params) { }
|
|
32
|
-
static testUsingArray(params) { }
|
|
33
|
-
}
|
|
34
|
-
__decorate([
|
|
35
|
-
(0, decorators_1.Get)(requestPath),
|
|
36
|
-
__param(0, (0, decorators_1.Param)("id")),
|
|
37
|
-
__metadata("design:type", Function),
|
|
38
|
-
__metadata("design:paramtypes", [Object]),
|
|
39
|
-
__metadata("design:returntype", void 0)
|
|
40
|
-
], Test, "test", null);
|
|
41
|
-
__decorate([
|
|
42
|
-
(0, decorators_1.Get)(requestPathUsingArray),
|
|
43
|
-
__param(0, (0, decorators_1.Param)("id")),
|
|
44
|
-
__metadata("design:type", Function),
|
|
45
|
-
__metadata("design:paramtypes", [Object]),
|
|
46
|
-
__metadata("design:returntype", void 0)
|
|
47
|
-
], Test, "testUsingArray", null);
|
|
48
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
49
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
50
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
51
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
52
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
53
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
54
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
55
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
56
|
-
});
|
|
57
|
-
it('should set path on "/" by default', () => {
|
|
58
|
-
class Test {
|
|
59
|
-
static test() { }
|
|
60
|
-
static testUsingArray() { }
|
|
61
|
-
}
|
|
62
|
-
__decorate([
|
|
63
|
-
(0, decorators_1.Get)(),
|
|
64
|
-
__metadata("design:type", Function),
|
|
65
|
-
__metadata("design:paramtypes", []),
|
|
66
|
-
__metadata("design:returntype", void 0)
|
|
67
|
-
], Test, "test", null);
|
|
68
|
-
__decorate([
|
|
69
|
-
(0, decorators_1.Get)([]),
|
|
70
|
-
__metadata("design:type", Function),
|
|
71
|
-
__metadata("design:paramtypes", []),
|
|
72
|
-
__metadata("design:returntype", void 0)
|
|
73
|
-
], Test, "testUsingArray", null);
|
|
74
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
75
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
76
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
77
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
describe("@Post", () => {
|
|
81
|
-
const requestPath = "test";
|
|
82
|
-
const requestProps = {
|
|
83
|
-
path: requestPath,
|
|
84
|
-
method: enums_1.RequestMethod.POST,
|
|
85
|
-
};
|
|
86
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
87
|
-
const requestPropsUsingArray = {
|
|
88
|
-
path: requestPathUsingArray,
|
|
89
|
-
method: enums_1.RequestMethod.POST,
|
|
90
|
-
};
|
|
91
|
-
it("should enhance class with expected request metadata", () => {
|
|
92
|
-
class Test {
|
|
93
|
-
static test() { }
|
|
94
|
-
static testUsingArray() { }
|
|
95
|
-
}
|
|
96
|
-
__decorate([
|
|
97
|
-
(0, decorators_1.Post)(requestPath),
|
|
98
|
-
__metadata("design:type", Function),
|
|
99
|
-
__metadata("design:paramtypes", []),
|
|
100
|
-
__metadata("design:returntype", void 0)
|
|
101
|
-
], Test, "test", null);
|
|
102
|
-
__decorate([
|
|
103
|
-
(0, decorators_1.Post)(requestPathUsingArray),
|
|
104
|
-
__metadata("design:type", Function),
|
|
105
|
-
__metadata("design:paramtypes", []),
|
|
106
|
-
__metadata("design:returntype", void 0)
|
|
107
|
-
], Test, "testUsingArray", null);
|
|
108
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
109
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
110
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
111
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
112
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
113
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
114
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
115
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
116
|
-
});
|
|
117
|
-
it('should set path on "/" by default', () => {
|
|
118
|
-
class Test {
|
|
119
|
-
static test(query, params, hostParams) { }
|
|
120
|
-
static testUsingArray(query, params, hostParams) { }
|
|
121
|
-
}
|
|
122
|
-
__decorate([
|
|
123
|
-
(0, decorators_1.Post)(),
|
|
124
|
-
__param(0, (0, decorators_1.Query)()),
|
|
125
|
-
__param(1, (0, decorators_1.Param)()),
|
|
126
|
-
__param(2, (0, decorators_1.HostParam)()),
|
|
127
|
-
__metadata("design:type", Function),
|
|
128
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
129
|
-
__metadata("design:returntype", void 0)
|
|
130
|
-
], Test, "test", null);
|
|
131
|
-
__decorate([
|
|
132
|
-
(0, decorators_1.Post)([]),
|
|
133
|
-
__param(0, (0, decorators_1.Query)()),
|
|
134
|
-
__param(1, (0, decorators_1.Param)()),
|
|
135
|
-
__param(2, (0, decorators_1.HostParam)()),
|
|
136
|
-
__metadata("design:type", Function),
|
|
137
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
138
|
-
__metadata("design:returntype", void 0)
|
|
139
|
-
], Test, "testUsingArray", null);
|
|
140
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
141
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
142
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
143
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
describe("@Delete", () => {
|
|
147
|
-
const requestPath = "test";
|
|
148
|
-
const requestProps = {
|
|
149
|
-
path: requestPath,
|
|
150
|
-
method: enums_1.RequestMethod.DELETE,
|
|
151
|
-
};
|
|
152
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
153
|
-
const requestPropsUsingArray = {
|
|
154
|
-
path: requestPathUsingArray,
|
|
155
|
-
method: enums_1.RequestMethod.DELETE,
|
|
156
|
-
};
|
|
157
|
-
it("should enhance class with expected request metadata", () => {
|
|
158
|
-
class Test {
|
|
159
|
-
static test(body) { }
|
|
160
|
-
static testUsingArray(body) { }
|
|
161
|
-
}
|
|
162
|
-
__decorate([
|
|
163
|
-
(0, decorators_1.Delete)(requestPath),
|
|
164
|
-
__param(0, (0, decorators_1.Body)()),
|
|
165
|
-
__metadata("design:type", Function),
|
|
166
|
-
__metadata("design:paramtypes", [Object]),
|
|
167
|
-
__metadata("design:returntype", void 0)
|
|
168
|
-
], Test, "test", null);
|
|
169
|
-
__decorate([
|
|
170
|
-
(0, decorators_1.Delete)(requestPathUsingArray),
|
|
171
|
-
__param(0, (0, decorators_1.Body)()),
|
|
172
|
-
__metadata("design:type", Function),
|
|
173
|
-
__metadata("design:paramtypes", [Object]),
|
|
174
|
-
__metadata("design:returntype", void 0)
|
|
175
|
-
], Test, "testUsingArray", null);
|
|
176
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
177
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
178
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
179
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
180
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
181
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
182
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
183
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
184
|
-
});
|
|
185
|
-
it('should set path on "/" by default', () => {
|
|
186
|
-
class Test {
|
|
187
|
-
static test() { }
|
|
188
|
-
static testUsingArray() { }
|
|
189
|
-
}
|
|
190
|
-
__decorate([
|
|
191
|
-
(0, decorators_1.Delete)(),
|
|
192
|
-
__metadata("design:type", Function),
|
|
193
|
-
__metadata("design:paramtypes", []),
|
|
194
|
-
__metadata("design:returntype", void 0)
|
|
195
|
-
], Test, "test", null);
|
|
196
|
-
__decorate([
|
|
197
|
-
(0, decorators_1.Delete)([]),
|
|
198
|
-
__metadata("design:type", Function),
|
|
199
|
-
__metadata("design:paramtypes", []),
|
|
200
|
-
__metadata("design:returntype", void 0)
|
|
201
|
-
], Test, "testUsingArray", null);
|
|
202
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
203
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
204
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
205
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
206
|
-
});
|
|
207
|
-
});
|
|
208
|
-
describe("@All", () => {
|
|
209
|
-
const requestPath = "test";
|
|
210
|
-
const requestProps = {
|
|
211
|
-
path: requestPath,
|
|
212
|
-
method: enums_1.RequestMethod.ALL,
|
|
213
|
-
};
|
|
214
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
215
|
-
const requestPropsUsingArray = {
|
|
216
|
-
path: requestPathUsingArray,
|
|
217
|
-
method: enums_1.RequestMethod.ALL,
|
|
218
|
-
};
|
|
219
|
-
it("should enhance class with expected request metadata", () => {
|
|
220
|
-
class Test {
|
|
221
|
-
static test() { }
|
|
222
|
-
static testUsingArray() { }
|
|
223
|
-
}
|
|
224
|
-
__decorate([
|
|
225
|
-
(0, decorators_1.All)(requestPath),
|
|
226
|
-
__metadata("design:type", Function),
|
|
227
|
-
__metadata("design:paramtypes", []),
|
|
228
|
-
__metadata("design:returntype", void 0)
|
|
229
|
-
], Test, "test", null);
|
|
230
|
-
__decorate([
|
|
231
|
-
(0, decorators_1.All)(requestPathUsingArray),
|
|
232
|
-
__metadata("design:type", Function),
|
|
233
|
-
__metadata("design:paramtypes", []),
|
|
234
|
-
__metadata("design:returntype", void 0)
|
|
235
|
-
], Test, "testUsingArray", null);
|
|
236
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
237
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
238
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
239
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
240
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
241
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
242
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
243
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
244
|
-
});
|
|
245
|
-
it('should set path on "/" by default', () => {
|
|
246
|
-
class Test {
|
|
247
|
-
static test() { }
|
|
248
|
-
static testUsingArray() { }
|
|
249
|
-
}
|
|
250
|
-
__decorate([
|
|
251
|
-
(0, decorators_1.All)(),
|
|
252
|
-
__metadata("design:type", Function),
|
|
253
|
-
__metadata("design:paramtypes", []),
|
|
254
|
-
__metadata("design:returntype", void 0)
|
|
255
|
-
], Test, "test", null);
|
|
256
|
-
__decorate([
|
|
257
|
-
(0, decorators_1.All)([]),
|
|
258
|
-
__metadata("design:type", Function),
|
|
259
|
-
__metadata("design:paramtypes", []),
|
|
260
|
-
__metadata("design:returntype", void 0)
|
|
261
|
-
], Test, "testUsingArray", null);
|
|
262
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
263
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
264
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
265
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
266
|
-
});
|
|
267
|
-
});
|
|
268
|
-
describe("@Put", () => {
|
|
269
|
-
const requestPath = "test";
|
|
270
|
-
const requestProps = {
|
|
271
|
-
path: requestPath,
|
|
272
|
-
method: enums_1.RequestMethod.PUT,
|
|
273
|
-
};
|
|
274
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
275
|
-
const requestPropsUsingArray = {
|
|
276
|
-
path: requestPathUsingArray,
|
|
277
|
-
method: enums_1.RequestMethod.PUT,
|
|
278
|
-
};
|
|
279
|
-
it("should enhance class with expected request metadata", () => {
|
|
280
|
-
class Test {
|
|
281
|
-
static test() { }
|
|
282
|
-
static testUsingArray() { }
|
|
283
|
-
}
|
|
284
|
-
__decorate([
|
|
285
|
-
(0, decorators_1.Put)(requestPath),
|
|
286
|
-
__metadata("design:type", Function),
|
|
287
|
-
__metadata("design:paramtypes", []),
|
|
288
|
-
__metadata("design:returntype", void 0)
|
|
289
|
-
], Test, "test", null);
|
|
290
|
-
__decorate([
|
|
291
|
-
(0, decorators_1.Put)(requestPathUsingArray),
|
|
292
|
-
__metadata("design:type", Function),
|
|
293
|
-
__metadata("design:paramtypes", []),
|
|
294
|
-
__metadata("design:returntype", void 0)
|
|
295
|
-
], Test, "testUsingArray", null);
|
|
296
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
297
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
298
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
299
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
300
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
301
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
302
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
303
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
304
|
-
});
|
|
305
|
-
it('should set path on "/" by default', () => {
|
|
306
|
-
class Test {
|
|
307
|
-
static test() { }
|
|
308
|
-
static testUsingArray() { }
|
|
309
|
-
}
|
|
310
|
-
__decorate([
|
|
311
|
-
(0, decorators_1.Put)(),
|
|
312
|
-
__metadata("design:type", Function),
|
|
313
|
-
__metadata("design:paramtypes", []),
|
|
314
|
-
__metadata("design:returntype", void 0)
|
|
315
|
-
], Test, "test", null);
|
|
316
|
-
__decorate([
|
|
317
|
-
(0, decorators_1.Put)([]),
|
|
318
|
-
__metadata("design:type", Function),
|
|
319
|
-
__metadata("design:paramtypes", []),
|
|
320
|
-
__metadata("design:returntype", void 0)
|
|
321
|
-
], Test, "testUsingArray", null);
|
|
322
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
323
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
324
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
325
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
326
|
-
});
|
|
327
|
-
});
|
|
328
|
-
describe("@Patch", () => {
|
|
329
|
-
const requestPath = "test";
|
|
330
|
-
const requestProps = {
|
|
331
|
-
path: requestPath,
|
|
332
|
-
method: enums_1.RequestMethod.PATCH,
|
|
333
|
-
};
|
|
334
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
335
|
-
const requestPropsUsingArray = {
|
|
336
|
-
path: requestPathUsingArray,
|
|
337
|
-
method: enums_1.RequestMethod.PATCH,
|
|
338
|
-
};
|
|
339
|
-
it("should enhance class with expected request metadata", () => {
|
|
340
|
-
class Test {
|
|
341
|
-
static test() { }
|
|
342
|
-
static testUsingArray() { }
|
|
343
|
-
}
|
|
344
|
-
__decorate([
|
|
345
|
-
(0, decorators_1.Patch)(requestPath),
|
|
346
|
-
__metadata("design:type", Function),
|
|
347
|
-
__metadata("design:paramtypes", []),
|
|
348
|
-
__metadata("design:returntype", void 0)
|
|
349
|
-
], Test, "test", null);
|
|
350
|
-
__decorate([
|
|
351
|
-
(0, decorators_1.Patch)(requestPathUsingArray),
|
|
352
|
-
__metadata("design:type", Function),
|
|
353
|
-
__metadata("design:paramtypes", []),
|
|
354
|
-
__metadata("design:returntype", void 0)
|
|
355
|
-
], Test, "testUsingArray", null);
|
|
356
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
357
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
358
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
359
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
360
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
361
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
362
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
363
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
364
|
-
});
|
|
365
|
-
it('should set path on "/" by default', () => {
|
|
366
|
-
class Test {
|
|
367
|
-
static test() { }
|
|
368
|
-
static testUsingArray() { }
|
|
369
|
-
}
|
|
370
|
-
__decorate([
|
|
371
|
-
(0, decorators_1.Patch)(),
|
|
372
|
-
__metadata("design:type", Function),
|
|
373
|
-
__metadata("design:paramtypes", []),
|
|
374
|
-
__metadata("design:returntype", void 0)
|
|
375
|
-
], Test, "test", null);
|
|
376
|
-
__decorate([
|
|
377
|
-
(0, decorators_1.Patch)([]),
|
|
378
|
-
__metadata("design:type", Function),
|
|
379
|
-
__metadata("design:paramtypes", []),
|
|
380
|
-
__metadata("design:returntype", void 0)
|
|
381
|
-
], Test, "testUsingArray", null);
|
|
382
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
383
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
384
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
385
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
386
|
-
});
|
|
387
|
-
});
|
|
388
|
-
describe("@Search", () => {
|
|
389
|
-
const requestPath = "test";
|
|
390
|
-
const requestProps = {
|
|
391
|
-
path: requestPath,
|
|
392
|
-
method: enums_1.RequestMethod.SEARCH,
|
|
393
|
-
};
|
|
394
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
395
|
-
const requestPropsUsingArray = {
|
|
396
|
-
path: requestPathUsingArray,
|
|
397
|
-
method: enums_1.RequestMethod.SEARCH,
|
|
398
|
-
};
|
|
399
|
-
it("should enhance class with expected request metadata", () => {
|
|
400
|
-
class Test {
|
|
401
|
-
static test() { }
|
|
402
|
-
static testUsingArray() { }
|
|
403
|
-
}
|
|
404
|
-
__decorate([
|
|
405
|
-
(0, decorators_1.Search)(requestPath),
|
|
406
|
-
__metadata("design:type", Function),
|
|
407
|
-
__metadata("design:paramtypes", []),
|
|
408
|
-
__metadata("design:returntype", void 0)
|
|
409
|
-
], Test, "test", null);
|
|
410
|
-
__decorate([
|
|
411
|
-
(0, decorators_1.Search)(requestPathUsingArray),
|
|
412
|
-
__metadata("design:type", Function),
|
|
413
|
-
__metadata("design:paramtypes", []),
|
|
414
|
-
__metadata("design:returntype", void 0)
|
|
415
|
-
], Test, "testUsingArray", null);
|
|
416
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
417
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
418
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
419
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
420
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
421
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
422
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
423
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
424
|
-
});
|
|
425
|
-
it('should set path on "/" by default', () => {
|
|
426
|
-
class Test {
|
|
427
|
-
static test(query, params, hostParams) { }
|
|
428
|
-
static testUsingArray(query, params, hostParams) { }
|
|
429
|
-
}
|
|
430
|
-
__decorate([
|
|
431
|
-
(0, decorators_1.Search)(),
|
|
432
|
-
__param(0, (0, decorators_1.Query)()),
|
|
433
|
-
__param(1, (0, decorators_1.Param)()),
|
|
434
|
-
__param(2, (0, decorators_1.HostParam)()),
|
|
435
|
-
__metadata("design:type", Function),
|
|
436
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
437
|
-
__metadata("design:returntype", void 0)
|
|
438
|
-
], Test, "test", null);
|
|
439
|
-
__decorate([
|
|
440
|
-
(0, decorators_1.Search)([]),
|
|
441
|
-
__param(0, (0, decorators_1.Query)()),
|
|
442
|
-
__param(1, (0, decorators_1.Param)()),
|
|
443
|
-
__param(2, (0, decorators_1.HostParam)()),
|
|
444
|
-
__metadata("design:type", Function),
|
|
445
|
-
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
446
|
-
__metadata("design:returntype", void 0)
|
|
447
|
-
], Test, "testUsingArray", null);
|
|
448
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
449
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
450
|
-
(0, chai_1.expect)(path).to.be.eql("/");
|
|
451
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql("/");
|
|
452
|
-
});
|
|
453
|
-
});
|
|
454
|
-
describe("Inheritance", () => {
|
|
455
|
-
const requestPath = "test";
|
|
456
|
-
const requestProps = {
|
|
457
|
-
path: requestPath,
|
|
458
|
-
method: enums_1.RequestMethod.GET,
|
|
459
|
-
};
|
|
460
|
-
const requestPathUsingArray = ["foo", "bar"];
|
|
461
|
-
const requestPropsUsingArray = {
|
|
462
|
-
path: requestPathUsingArray,
|
|
463
|
-
method: enums_1.RequestMethod.GET,
|
|
464
|
-
};
|
|
465
|
-
it("should enhance subclass with expected request metadata", () => {
|
|
466
|
-
class Parent {
|
|
467
|
-
static test() { }
|
|
468
|
-
static testUsingArray() { }
|
|
469
|
-
}
|
|
470
|
-
__decorate([
|
|
471
|
-
(0, decorators_1.Get)(requestPath),
|
|
472
|
-
__metadata("design:type", Function),
|
|
473
|
-
__metadata("design:paramtypes", []),
|
|
474
|
-
__metadata("design:returntype", void 0)
|
|
475
|
-
], Parent, "test", null);
|
|
476
|
-
__decorate([
|
|
477
|
-
(0, decorators_1.Get)(requestPathUsingArray),
|
|
478
|
-
__metadata("design:type", Function),
|
|
479
|
-
__metadata("design:paramtypes", []),
|
|
480
|
-
__metadata("design:returntype", void 0)
|
|
481
|
-
], Parent, "testUsingArray", null);
|
|
482
|
-
class Test extends Parent {
|
|
483
|
-
}
|
|
484
|
-
const path = Reflect.getMetadata("path", Test.test);
|
|
485
|
-
const method = Reflect.getMetadata("method", Test.test);
|
|
486
|
-
const pathUsingArray = Reflect.getMetadata("path", Test.testUsingArray);
|
|
487
|
-
const methodUsingArray = Reflect.getMetadata("method", Test.testUsingArray);
|
|
488
|
-
(0, chai_1.expect)(path).to.be.eql(requestPath);
|
|
489
|
-
(0, chai_1.expect)(method).to.be.eql(requestProps.method);
|
|
490
|
-
(0, chai_1.expect)(pathUsingArray).to.be.eql(requestPathUsingArray);
|
|
491
|
-
(0, chai_1.expect)(methodUsingArray).to.be.eql(requestPropsUsingArray.method);
|
|
492
|
-
});
|
|
493
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const chai_1 = require("chai");
|
|
13
|
-
const constants_1 = require("@venok/http/constants");
|
|
14
|
-
const decorators_1 = require("@venok/http/decorators");
|
|
15
|
-
const enums_1 = require("@venok/http/enums");
|
|
16
|
-
describe("@Sse", () => {
|
|
17
|
-
const prefix = "/prefix";
|
|
18
|
-
class Test {
|
|
19
|
-
static test() { }
|
|
20
|
-
}
|
|
21
|
-
__decorate([
|
|
22
|
-
(0, decorators_1.Sse)(prefix),
|
|
23
|
-
__metadata("design:type", Function),
|
|
24
|
-
__metadata("design:paramtypes", []),
|
|
25
|
-
__metadata("design:returntype", void 0)
|
|
26
|
-
], Test, "test", null);
|
|
27
|
-
it("should enhance method with expected http status code", () => {
|
|
28
|
-
const path = Reflect.getMetadata(constants_1.PATH_METADATA, Test.test);
|
|
29
|
-
(0, chai_1.expect)(path).to.be.eql("/prefix");
|
|
30
|
-
const method = Reflect.getMetadata(constants_1.METHOD_METADATA, Test.test);
|
|
31
|
-
(0, chai_1.expect)(method).to.be.eql(enums_1.RequestMethod.GET);
|
|
32
|
-
const metadata = Reflect.getMetadata(constants_1.SSE_METADATA, Test.test);
|
|
33
|
-
(0, chai_1.expect)(metadata).to.be.eql(true);
|
|
34
|
-
});
|
|
35
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const chai_1 = require("chai");
|
|
13
|
-
const decorators_1 = require("@venok/http/decorators");
|
|
14
|
-
const constants_1 = require("@venok/http/constants");
|
|
15
|
-
describe("@Version", () => {
|
|
16
|
-
const version = "1";
|
|
17
|
-
const versions = ["1", "2", "2", "1", "2", "1"];
|
|
18
|
-
const versionsWithoutDuplicates = ["1", "2"];
|
|
19
|
-
class Test {
|
|
20
|
-
static oneVersion() { }
|
|
21
|
-
static multipleVersions() { }
|
|
22
|
-
}
|
|
23
|
-
__decorate([
|
|
24
|
-
(0, decorators_1.Version)(version),
|
|
25
|
-
__metadata("design:type", Function),
|
|
26
|
-
__metadata("design:paramtypes", []),
|
|
27
|
-
__metadata("design:returntype", void 0)
|
|
28
|
-
], Test, "oneVersion", null);
|
|
29
|
-
__decorate([
|
|
30
|
-
(0, decorators_1.Version)(versions),
|
|
31
|
-
__metadata("design:type", Function),
|
|
32
|
-
__metadata("design:paramtypes", []),
|
|
33
|
-
__metadata("design:returntype", void 0)
|
|
34
|
-
], Test, "multipleVersions", null);
|
|
35
|
-
it("should enhance method with expected version string", () => {
|
|
36
|
-
const metadata = Reflect.getMetadata(constants_1.VERSION_METADATA, Test.oneVersion);
|
|
37
|
-
(0, chai_1.expect)(metadata).to.be.eql(version);
|
|
38
|
-
});
|
|
39
|
-
it("should enhance method with expected version array", () => {
|
|
40
|
-
const metadata = Reflect.getMetadata(constants_1.VERSION_METADATA, Test.multipleVersions);
|
|
41
|
-
(0, chai_1.expect)(metadata).to.be.eql(versionsWithoutDuplicates);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|