@e22m4u/ts-rest-router 0.6.8 → 0.6.10
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/README.md +1 -1
- package/dist/cjs/index.cjs +12 -12
- package/dist/esm/controller-registry.js +3 -3
- package/dist/esm/data-schema-types.d.ts +2 -2
- package/dist/esm/decorators/request-context/request-context-decorator.js +2 -2
- package/dist/esm/decorators/request-context/request-context-decorator.spec.js +6 -6
- package/dist/esm/decorators/request-context/request-context-reflector.spec.js +6 -6
- package/dist/esm/decorators/request-data/request-data-decorator.js +1 -1
- package/dist/esm/decorators/request-data/request-data-decorator.spec.js +1 -1
- package/dist/esm/decorators/response-body/response-body-decorator.spec.js +1 -1
- package/package.json +10 -10
- package/src/controller-registry.spec.ts +1 -1
- package/src/controller-registry.ts +4 -4
- package/src/data-schema-types.ts +2 -2
- package/src/decorators/request-context/request-context-decorator.spec.ts +6 -6
- package/src/decorators/request-context/request-context-decorator.ts +2 -2
- package/src/decorators/request-context/request-context-reflector.spec.ts +6 -6
- package/src/decorators/request-data/request-data-decorator.spec.ts +1 -1
- package/src/decorators/request-data/request-data-decorator.ts +2 -2
- package/src/decorators/response-body/response-body-decorator.spec.ts +1 -1
package/README.md
CHANGED
|
@@ -407,7 +407,7 @@ class SystemController {
|
|
|
407
407
|
## Валидация данных
|
|
408
408
|
|
|
409
409
|
Модуль интегрирован с
|
|
410
|
-
[@e22m4u/
|
|
410
|
+
[@e22m4u/ts-data-schema](https://www.npmjs.com/package/@e22m4u/ts-data-schema)
|
|
411
411
|
для гибкой проверки данных. Это дает возможность определять типы данных
|
|
412
412
|
и сложные правила.
|
|
413
413
|
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -93,8 +93,8 @@ var import_js_trie_router3 = require("@e22m4u/js-trie-router");
|
|
|
93
93
|
// dist/esm/controller-registry.js
|
|
94
94
|
var import_js_format2 = require("@e22m4u/js-format");
|
|
95
95
|
var import_js_trie_router2 = require("@e22m4u/js-trie-router");
|
|
96
|
-
var
|
|
97
|
-
var
|
|
96
|
+
var import_ts_data_schema2 = require("@e22m4u/ts-data-schema");
|
|
97
|
+
var import_ts_data_schema3 = require("@e22m4u/ts-data-schema");
|
|
98
98
|
|
|
99
99
|
// dist/esm/errors/not-a-controller-error.js
|
|
100
100
|
var import_js_format = require("@e22m4u/js-format");
|
|
@@ -211,7 +211,7 @@ var RequestDataSource;
|
|
|
211
211
|
var REQUEST_DATA_METADATA_KEY = new import_ts_reflector5.MetadataKey("requestDataMetadataKey");
|
|
212
212
|
|
|
213
213
|
// dist/esm/decorators/request-data/request-data-decorator.js
|
|
214
|
-
var
|
|
214
|
+
var import_ts_data_schema = require("@e22m4u/ts-data-schema");
|
|
215
215
|
var import_ts_reflector7 = require("@e22m4u/ts-reflector");
|
|
216
216
|
var import_ts_reflector8 = require("@e22m4u/ts-reflector");
|
|
217
217
|
|
|
@@ -264,7 +264,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
|
264
264
|
} else if (typeof schemaInput === "string") {
|
|
265
265
|
schema = { type: schemaInput };
|
|
266
266
|
} else {
|
|
267
|
-
schema = { type:
|
|
267
|
+
schema = { type: import_ts_data_schema.DataType.ANY };
|
|
268
268
|
}
|
|
269
269
|
return requestData({ schema, source });
|
|
270
270
|
};
|
|
@@ -272,7 +272,7 @@ function createRequestDataDecoratorWithSource(source) {
|
|
|
272
272
|
__name(createRequestDataDecoratorWithSource, "createRequestDataDecoratorWithSource");
|
|
273
273
|
function createRequestDataPropertyDecoratorWithSource(source) {
|
|
274
274
|
return function(propertyKey, schemaInput) {
|
|
275
|
-
const rootSchema = { type:
|
|
275
|
+
const rootSchema = { type: import_ts_data_schema.DataType.OBJECT };
|
|
276
276
|
const properties = {};
|
|
277
277
|
let schemaOrFactory = rootSchema;
|
|
278
278
|
if (typeof schemaInput === "function") {
|
|
@@ -288,7 +288,7 @@ function createRequestDataPropertyDecoratorWithSource(source) {
|
|
|
288
288
|
properties[propertyKey] = { type: schemaInput };
|
|
289
289
|
rootSchema.properties = properties;
|
|
290
290
|
} else {
|
|
291
|
-
properties[propertyKey] = { type:
|
|
291
|
+
properties[propertyKey] = { type: import_ts_data_schema.DataType.ANY };
|
|
292
292
|
rootSchema.properties = properties;
|
|
293
293
|
}
|
|
294
294
|
return requestData({
|
|
@@ -566,11 +566,11 @@ function requestContext(propertyName) {
|
|
|
566
566
|
}
|
|
567
567
|
__name(requestContext, "requestContext");
|
|
568
568
|
function httpRequest() {
|
|
569
|
-
return requestContext("
|
|
569
|
+
return requestContext("request");
|
|
570
570
|
}
|
|
571
571
|
__name(httpRequest, "httpRequest");
|
|
572
572
|
function httpResponse() {
|
|
573
|
-
return requestContext("
|
|
573
|
+
return requestContext("response");
|
|
574
574
|
}
|
|
575
575
|
__name(httpResponse, "httpResponse");
|
|
576
576
|
function requestContainer() {
|
|
@@ -579,7 +579,7 @@ function requestContainer() {
|
|
|
579
579
|
__name(requestContainer, "requestContainer");
|
|
580
580
|
|
|
581
581
|
// dist/esm/controller-registry.js
|
|
582
|
-
var
|
|
582
|
+
var import_ts_data_schema4 = require("@e22m4u/ts-data-schema");
|
|
583
583
|
var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
584
584
|
/**
|
|
585
585
|
* Controller map.
|
|
@@ -860,9 +860,9 @@ var _ControllerRegistry = class _ControllerRegistry extends DebuggableService {
|
|
|
860
860
|
const requestContextMetadataMap = RequestContextReflector.getMetadata(controllerCtor, actionName);
|
|
861
861
|
const requestDataMetadataMap = RequestDataReflector.getMetadata(controllerCtor, actionName);
|
|
862
862
|
const argsNumber = controllerCtor.prototype[actionName].length;
|
|
863
|
-
const defaultsApplier = this.getService(
|
|
864
|
-
const dataTypeCaster = this.getService(
|
|
865
|
-
const dataValidator = this.getService(
|
|
863
|
+
const defaultsApplier = this.getService(import_ts_data_schema4.DefaultValuesApplier);
|
|
864
|
+
const dataTypeCaster = this.getService(import_ts_data_schema3.DataTypeCaster);
|
|
865
|
+
const dataValidator = this.getService(import_ts_data_schema2.DataValidator);
|
|
866
866
|
return (requestContext2) => {
|
|
867
867
|
debug("Executing route handler for %s.%s.", controllerCtor.name, actionName);
|
|
868
868
|
const args = Array(argsNumber).fill(void 0).map((_, index) => {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { Errorf } from '@e22m4u/js-format';
|
|
2
2
|
import { TrieRouter } from '@e22m4u/js-trie-router';
|
|
3
|
-
import { DataValidator } from '@e22m4u/
|
|
4
|
-
import { DataTypeCaster } from '@e22m4u/
|
|
3
|
+
import { DataValidator } from '@e22m4u/ts-data-schema';
|
|
4
|
+
import { DataTypeCaster } from '@e22m4u/ts-data-schema';
|
|
5
5
|
import { NotAControllerError } from './errors/index.js';
|
|
6
6
|
import { RequestDataSource } from './decorators/index.js';
|
|
7
7
|
import { DebuggableService } from './debuggable-service.js';
|
|
8
8
|
import { RestActionReflector } from './decorators/index.js';
|
|
9
9
|
import { RequestDataReflector } from './decorators/index.js';
|
|
10
10
|
import { AfterActionReflector } from './decorators/index.js';
|
|
11
|
-
import { DefaultValuesApplier } from '@e22m4u/
|
|
11
|
+
import { DefaultValuesApplier } from '@e22m4u/ts-data-schema';
|
|
12
12
|
import { BeforeActionReflector } from './decorators/index.js';
|
|
13
13
|
import { RestControllerReflector } from './decorators/index.js';
|
|
14
14
|
import { RequestContextReflector } from './decorators/index.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DataType } from '@e22m4u/
|
|
2
|
-
import { DataSchema } from '@e22m4u/
|
|
1
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
2
|
+
import { DataSchema } from '@e22m4u/ts-data-schema';
|
|
3
3
|
import { ServiceContainer } from '@e22m4u/js-service';
|
|
4
4
|
/**
|
|
5
5
|
* Data schema factory.
|
|
@@ -19,13 +19,13 @@ export function requestContext(propertyName) {
|
|
|
19
19
|
* HttpRequest decorator.
|
|
20
20
|
*/
|
|
21
21
|
export function httpRequest() {
|
|
22
|
-
return requestContext('
|
|
22
|
+
return requestContext('request');
|
|
23
23
|
}
|
|
24
24
|
/**
|
|
25
25
|
* HttpResponse decorator.
|
|
26
26
|
*/
|
|
27
27
|
export function httpResponse() {
|
|
28
|
-
return requestContext('
|
|
28
|
+
return requestContext('response');
|
|
29
29
|
}
|
|
30
30
|
/**
|
|
31
31
|
* RequestContainer decorator.
|
|
@@ -36,16 +36,16 @@ describe('requestContext', function () {
|
|
|
36
36
|
method(prop) { }
|
|
37
37
|
}
|
|
38
38
|
__decorate([
|
|
39
|
-
__param(0, requestContext('
|
|
39
|
+
__param(0, requestContext('response')),
|
|
40
40
|
__metadata("design:type", Function),
|
|
41
41
|
__metadata("design:paramtypes", [Object]),
|
|
42
42
|
__metadata("design:returntype", void 0)
|
|
43
43
|
], Target.prototype, "method", null);
|
|
44
44
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
45
|
-
expect(res.get(0)).to.be.eql({ property: '
|
|
45
|
+
expect(res.get(0)).to.be.eql({ property: 'response' });
|
|
46
46
|
});
|
|
47
47
|
describe('httpRequest', function () {
|
|
48
|
-
it('should set the "
|
|
48
|
+
it('should set the "request" property to target metadata', function () {
|
|
49
49
|
class Target {
|
|
50
50
|
method(prop) { }
|
|
51
51
|
}
|
|
@@ -56,11 +56,11 @@ describe('requestContext', function () {
|
|
|
56
56
|
__metadata("design:returntype", void 0)
|
|
57
57
|
], Target.prototype, "method", null);
|
|
58
58
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
59
|
-
expect(res.get(0)).to.be.eql({ property: '
|
|
59
|
+
expect(res.get(0)).to.be.eql({ property: 'request' });
|
|
60
60
|
});
|
|
61
61
|
});
|
|
62
62
|
describe('httpResponse', function () {
|
|
63
|
-
it('should set the "
|
|
63
|
+
it('should set the "response" property to target metadata', function () {
|
|
64
64
|
class Target {
|
|
65
65
|
method(prop) { }
|
|
66
66
|
}
|
|
@@ -71,7 +71,7 @@ describe('requestContext', function () {
|
|
|
71
71
|
__metadata("design:returntype", void 0)
|
|
72
72
|
], Target.prototype, "method", null);
|
|
73
73
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
74
|
-
expect(res.get(0)).to.be.eql({ property: '
|
|
74
|
+
expect(res.get(0)).to.be.eql({ property: 'response' });
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
describe('requestContainer', function () {
|
|
@@ -7,8 +7,8 @@ describe('RequestContextReflector', function () {
|
|
|
7
7
|
it('sets a given value as target metadata', function () {
|
|
8
8
|
class Target {
|
|
9
9
|
}
|
|
10
|
-
const md1 = { property: '
|
|
11
|
-
const md2 = { property: '
|
|
10
|
+
const md1 = { property: 'request' };
|
|
11
|
+
const md2 = { property: 'response' };
|
|
12
12
|
RequestContextReflector.setMetadata(md1, Target, 0, 'propertyKey');
|
|
13
13
|
RequestContextReflector.setMetadata(md2, Target, 1, 'propertyKey');
|
|
14
14
|
const res = Reflector.getOwnMetadata(REQUEST_CONTEXT_METADATA_KEY, Target, 'propertyKey');
|
|
@@ -19,8 +19,8 @@ describe('RequestContextReflector', function () {
|
|
|
19
19
|
it('overrides existing metadata', function () {
|
|
20
20
|
class Target {
|
|
21
21
|
}
|
|
22
|
-
const md1 = { property: '
|
|
23
|
-
const md2 = { property: '
|
|
22
|
+
const md1 = { property: 'request' };
|
|
23
|
+
const md2 = { property: 'response' };
|
|
24
24
|
RequestContextReflector.setMetadata(md1, Target, 0, 'propertyKey');
|
|
25
25
|
const res1 = Reflector.getOwnMetadata(REQUEST_CONTEXT_METADATA_KEY, Target, 'propertyKey');
|
|
26
26
|
expect(res1).to.be.instanceof(Map);
|
|
@@ -35,8 +35,8 @@ describe('RequestContextReflector', function () {
|
|
|
35
35
|
it('returns an existing metadata of the target', function () {
|
|
36
36
|
class Target {
|
|
37
37
|
}
|
|
38
|
-
const md1 = { property: '
|
|
39
|
-
const md2 = { property: '
|
|
38
|
+
const md1 = { property: 'request' };
|
|
39
|
+
const md2 = { property: 'response' };
|
|
40
40
|
const mdMap = new Map([
|
|
41
41
|
[0, md1],
|
|
42
42
|
[1, md2],
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DataType } from '@e22m4u/
|
|
1
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
2
2
|
import { DecoratorTargetType } from '@e22m4u/ts-reflector';
|
|
3
3
|
import { getDecoratorTargetType } from '@e22m4u/ts-reflector';
|
|
4
4
|
import { RequestDataSource } from './request-data-metadata.js';
|
|
@@ -12,7 +12,7 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
};
|
|
13
13
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14
14
|
import { expect } from 'chai';
|
|
15
|
-
import { DataType } from '@e22m4u/
|
|
15
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
16
16
|
import { requestData } from './request-data-decorator.js';
|
|
17
17
|
import { requestBody } from './request-data-decorator.js';
|
|
18
18
|
import { requestField } from './request-data-decorator.js';
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
import { expect } from 'chai';
|
|
11
|
-
import { DataType } from '@e22m4u/
|
|
11
|
+
import { DataType } from '@e22m4u/ts-data-schema';
|
|
12
12
|
import { responseBody } from './response-body-decorator.js';
|
|
13
13
|
import { ResponseBodyReflector } from './response-body-reflector.js';
|
|
14
14
|
describe('responseBody', function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e22m4u/ts-rest-router",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.10",
|
|
4
4
|
"description": "Декларативный REST-маршрутизатор на основе контроллеров для TypeScript",
|
|
5
5
|
"author": "Mikhail Evstropov <e22m4u@yandex.ru>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -41,11 +41,11 @@
|
|
|
41
41
|
"prepare": "husky"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@e22m4u/
|
|
45
|
-
"@e22m4u/js-debug": "~0.3.
|
|
46
|
-
"@e22m4u/js-format": "~0.2.
|
|
47
|
-
"@e22m4u/js-service": "~0.4.
|
|
48
|
-
"@e22m4u/js-trie-router": "~0.
|
|
44
|
+
"@e22m4u/ts-data-schema": "~0.4.9",
|
|
45
|
+
"@e22m4u/js-debug": "~0.3.3",
|
|
46
|
+
"@e22m4u/js-format": "~0.2.1",
|
|
47
|
+
"@e22m4u/js-service": "~0.4.6",
|
|
48
|
+
"@e22m4u/js-trie-router": "~0.4.1",
|
|
49
49
|
"@e22m4u/ts-reflector": "~0.1.8",
|
|
50
50
|
"http-errors": "~2.0.0"
|
|
51
51
|
},
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"@types/debug": "~4.1.12",
|
|
58
58
|
"@types/http-errors": "~2.0.5",
|
|
59
59
|
"@types/mocha": "~10.0.10",
|
|
60
|
-
"@types/node": "~24.10.
|
|
60
|
+
"@types/node": "~24.10.1",
|
|
61
61
|
"c8": "~10.1.3",
|
|
62
|
-
"chai": "~6.2.
|
|
63
|
-
"esbuild": "~0.
|
|
62
|
+
"chai": "~6.2.1",
|
|
63
|
+
"esbuild": "~0.27.0",
|
|
64
64
|
"eslint": "~9.39.1",
|
|
65
65
|
"eslint-config-prettier": "~10.1.8",
|
|
66
66
|
"eslint-plugin-chai-expect": "~3.1.0",
|
|
@@ -71,6 +71,6 @@
|
|
|
71
71
|
"rimraf": "~6.1.0",
|
|
72
72
|
"tsx": "~4.20.6",
|
|
73
73
|
"typescript": "~5.9.3",
|
|
74
|
-
"typescript-eslint": "~8.46.
|
|
74
|
+
"typescript-eslint": "~8.46.4"
|
|
75
75
|
}
|
|
76
76
|
}
|
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
|
|
35
35
|
import {expect} from 'chai';
|
|
36
36
|
import {Service} from '@e22m4u/js-service';
|
|
37
|
-
import {DataType} from '@e22m4u/
|
|
37
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
38
38
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
39
39
|
import {DataSchemaFactory} from './data-schema-types.js';
|
|
40
40
|
import {ControllerRegistry} from './controller-registry.js';
|
|
@@ -2,10 +2,10 @@ import {AnyObject} from './types.js';
|
|
|
2
2
|
import {Constructor} from './types.js';
|
|
3
3
|
import {Errorf} from '@e22m4u/js-format';
|
|
4
4
|
import {TrieRouter} from '@e22m4u/js-trie-router';
|
|
5
|
-
import {DataSchema} from '@e22m4u/
|
|
5
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
6
6
|
import {RouteHandler} from '@e22m4u/js-trie-router';
|
|
7
|
-
import {DataValidator} from '@e22m4u/
|
|
8
|
-
import {DataTypeCaster} from '@e22m4u/
|
|
7
|
+
import {DataValidator} from '@e22m4u/ts-data-schema';
|
|
8
|
+
import {DataTypeCaster} from '@e22m4u/ts-data-schema';
|
|
9
9
|
import {NotAControllerError} from './errors/index.js';
|
|
10
10
|
import {RequestContext} from '@e22m4u/js-trie-router';
|
|
11
11
|
import {RoutePreHandler} from '@e22m4u/js-trie-router';
|
|
@@ -15,7 +15,7 @@ import {DebuggableService} from './debuggable-service.js';
|
|
|
15
15
|
import {RestActionReflector} from './decorators/index.js';
|
|
16
16
|
import {RequestDataReflector} from './decorators/index.js';
|
|
17
17
|
import {AfterActionReflector} from './decorators/index.js';
|
|
18
|
-
import {DefaultValuesApplier} from '@e22m4u/
|
|
18
|
+
import {DefaultValuesApplier} from '@e22m4u/ts-data-schema';
|
|
19
19
|
import {BeforeActionReflector} from './decorators/index.js';
|
|
20
20
|
import {RestControllerReflector} from './decorators/index.js';
|
|
21
21
|
import {RequestContextReflector} from './decorators/index.js';
|
package/src/data-schema-types.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {DataType} from '@e22m4u/
|
|
2
|
-
import {DataSchema} from '@e22m4u/
|
|
1
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
2
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
3
3
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -21,16 +21,16 @@ describe('requestContext', function () {
|
|
|
21
21
|
it('should set the given property to target metadata', function () {
|
|
22
22
|
class Target {
|
|
23
23
|
method(
|
|
24
|
-
@requestContext('
|
|
24
|
+
@requestContext('response')
|
|
25
25
|
prop: unknown,
|
|
26
26
|
) {}
|
|
27
27
|
}
|
|
28
28
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
29
|
-
expect(res.get(0)).to.be.eql({property: '
|
|
29
|
+
expect(res.get(0)).to.be.eql({property: 'response'});
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
describe('httpRequest', function () {
|
|
33
|
-
it('should set the "
|
|
33
|
+
it('should set the "request" property to target metadata', function () {
|
|
34
34
|
class Target {
|
|
35
35
|
method(
|
|
36
36
|
@httpRequest()
|
|
@@ -38,12 +38,12 @@ describe('requestContext', function () {
|
|
|
38
38
|
) {}
|
|
39
39
|
}
|
|
40
40
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
41
|
-
expect(res.get(0)).to.be.eql({property: '
|
|
41
|
+
expect(res.get(0)).to.be.eql({property: 'request'});
|
|
42
42
|
});
|
|
43
43
|
});
|
|
44
44
|
|
|
45
45
|
describe('httpResponse', function () {
|
|
46
|
-
it('should set the "
|
|
46
|
+
it('should set the "response" property to target metadata', function () {
|
|
47
47
|
class Target {
|
|
48
48
|
method(
|
|
49
49
|
@httpResponse()
|
|
@@ -51,7 +51,7 @@ describe('requestContext', function () {
|
|
|
51
51
|
) {}
|
|
52
52
|
}
|
|
53
53
|
const res = RequestContextReflector.getMetadata(Target, 'method');
|
|
54
|
-
expect(res.get(0)).to.be.eql({property: '
|
|
54
|
+
expect(res.get(0)).to.be.eql({property: 'response'});
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
|
|
@@ -41,14 +41,14 @@ export function requestContext<T extends object>(
|
|
|
41
41
|
* HttpRequest decorator.
|
|
42
42
|
*/
|
|
43
43
|
export function httpRequest() {
|
|
44
|
-
return requestContext('
|
|
44
|
+
return requestContext('request');
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
48
|
* HttpResponse decorator.
|
|
49
49
|
*/
|
|
50
50
|
export function httpResponse() {
|
|
51
|
-
return requestContext('
|
|
51
|
+
return requestContext('response');
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
/**
|
|
@@ -8,8 +8,8 @@ describe('RequestContextReflector', function () {
|
|
|
8
8
|
describe('setMetadata', function () {
|
|
9
9
|
it('sets a given value as target metadata', function () {
|
|
10
10
|
class Target {}
|
|
11
|
-
const md1 = {property: '
|
|
12
|
-
const md2 = {property: '
|
|
11
|
+
const md1 = {property: 'request' as const};
|
|
12
|
+
const md2 = {property: 'response' as const};
|
|
13
13
|
RequestContextReflector.setMetadata(md1, Target, 0, 'propertyKey');
|
|
14
14
|
RequestContextReflector.setMetadata(md2, Target, 1, 'propertyKey');
|
|
15
15
|
const res = Reflector.getOwnMetadata(
|
|
@@ -24,8 +24,8 @@ describe('RequestContextReflector', function () {
|
|
|
24
24
|
|
|
25
25
|
it('overrides existing metadata', function () {
|
|
26
26
|
class Target {}
|
|
27
|
-
const md1 = {property: '
|
|
28
|
-
const md2 = {property: '
|
|
27
|
+
const md1 = {property: 'request' as const};
|
|
28
|
+
const md2 = {property: 'response' as const};
|
|
29
29
|
RequestContextReflector.setMetadata(md1, Target, 0, 'propertyKey');
|
|
30
30
|
const res1 = Reflector.getOwnMetadata(
|
|
31
31
|
REQUEST_CONTEXT_METADATA_KEY,
|
|
@@ -48,8 +48,8 @@ describe('RequestContextReflector', function () {
|
|
|
48
48
|
describe('getMetadata', function () {
|
|
49
49
|
it('returns an existing metadata of the target', function () {
|
|
50
50
|
class Target {}
|
|
51
|
-
const md1 = {property: '
|
|
52
|
-
const md2 = {property: '
|
|
51
|
+
const md1 = {property: 'request' as const};
|
|
52
|
+
const md2 = {property: 'response' as const};
|
|
53
53
|
const mdMap = new Map<number, RequestContextMetadata>([
|
|
54
54
|
[0, md1],
|
|
55
55
|
[1, md2],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import {expect} from 'chai';
|
|
3
|
-
import {DataType} from '@e22m4u/
|
|
3
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
4
4
|
import {ServiceContainer} from '@e22m4u/js-service';
|
|
5
5
|
import {requestData} from './request-data-decorator.js';
|
|
6
6
|
import {requestBody} from './request-data-decorator.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {NoUndef} from '../../types.js';
|
|
2
2
|
import {Prototype} from '../../types.js';
|
|
3
3
|
import {Constructor} from '../../types.js';
|
|
4
|
-
import {DataType} from '@e22m4u/
|
|
5
|
-
import {DataSchema} from '@e22m4u/
|
|
4
|
+
import {DataType} from '@e22m4u/ts-data-schema';
|
|
5
|
+
import {DataSchema} from '@e22m4u/ts-data-schema';
|
|
6
6
|
import {DecoratorTargetType} from '@e22m4u/ts-reflector';
|
|
7
7
|
import {getDecoratorTargetType} from '@e22m4u/ts-reflector';
|
|
8
8
|
import {RequestDataSource} from './request-data-metadata.js';
|