@e22m4u/ts-rest-router 0.6.2 → 0.6.3

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.
@@ -16,7 +16,6 @@ var __copyProps = (to, from, except, desc) => {
16
16
  }
17
17
  return to;
18
18
  };
19
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
20
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
21
20
 
22
21
  // dist/esm/index.js
@@ -33,6 +32,7 @@ __export(index_exports, {
33
32
  RESPONSE_BODY_METADATA_KEY: () => RESPONSE_BODY_METADATA_KEY,
34
33
  REST_ACTIONS_METADATA_KEY: () => REST_ACTIONS_METADATA_KEY,
35
34
  REST_CONTROLLER_METADATA_KEY: () => REST_CONTROLLER_METADATA_KEY,
35
+ RequestContext: () => import_js_trie_router4.RequestContext,
36
36
  RequestContextReflector: () => RequestContextReflector,
37
37
  RequestDataReflector: () => RequestDataReflector,
38
38
  RequestDataSource: () => RequestDataSource,
@@ -67,7 +67,6 @@ __export(index_exports, {
67
67
  restController: () => restController
68
68
  });
69
69
  module.exports = __toCommonJS(index_exports);
70
- __reExport(index_exports, require("@e22m4u/js-trie-router"), module.exports);
71
70
 
72
71
  // dist/esm/rest-router.js
73
72
  var import_js_trie_router3 = require("@e22m4u/js-trie-router");
@@ -978,6 +977,9 @@ var _RestRouter = class _RestRouter extends DebuggableService {
978
977
  };
979
978
  __name(_RestRouter, "RestRouter");
980
979
  var RestRouter = _RestRouter;
980
+
981
+ // dist/esm/index.js
982
+ var import_js_trie_router4 = require("@e22m4u/js-trie-router");
981
983
  // Annotate the CommonJS export names for ESM import in node:
982
984
  0 && (module.exports = {
983
985
  AFTER_ACTION_METADATA_KEY,
@@ -991,6 +993,7 @@ var RestRouter = _RestRouter;
991
993
  RESPONSE_BODY_METADATA_KEY,
992
994
  REST_ACTIONS_METADATA_KEY,
993
995
  REST_CONTROLLER_METADATA_KEY,
996
+ RequestContext,
994
997
  RequestContextReflector,
995
998
  RequestDataReflector,
996
999
  RequestDataSource,
@@ -1022,6 +1025,5 @@ var RestRouter = _RestRouter;
1022
1025
  requestQuery,
1023
1026
  responseBody,
1024
1027
  restAction,
1025
- restController,
1026
- ...require("@e22m4u/js-trie-router")
1028
+ restController
1027
1029
  });
@@ -10,6 +10,6 @@ export type DataSchemaFactory = (container: ServiceContainer) => DataSchema;
10
10
  */
11
11
  export type DataSchemaOrFactory = DataSchema | DataSchemaFactory;
12
12
  /**
13
- * Data schema input.
13
+ * Data schema decorator input.
14
14
  */
15
- export type DataSchemaInput = DataSchemaOrFactory | DataType;
15
+ export type DataSchemaDecoratorInput = DataSchemaOrFactory | DataType;
@@ -1,6 +1,6 @@
1
1
  import { Prototype } from '../../types.js';
2
- import { DataSchemaInput } from '../../data-schema-types.js';
3
2
  import { RequestDataMetadata } from './request-data-metadata.js';
3
+ import { DataSchemaDecoratorInput } from '../../data-schema-types.js';
4
4
  /**
5
5
  * Request data options.
6
6
  */
@@ -14,13 +14,13 @@ export declare function requestData<T extends object>(options: RequestDataOption
14
14
  /**
15
15
  * Decorator aliases.
16
16
  */
17
- export declare const requestParams: (schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
18
- export declare const requestParam: (propertyKey: string, schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
19
- export declare const requestQueries: (schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
20
- export declare const requestQuery: (propertyKey: string, schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
21
- export declare const requestHeaders: (schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
22
- export declare const requestHeader: (propertyKey: string, schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
23
- export declare const requestCookies: (schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
24
- export declare const requestCookie: (propertyKey: string, schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
25
- export declare const requestBody: (schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
26
- export declare const requestField: (propertyKey: string, schemaInput?: DataSchemaInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
17
+ export declare const requestParams: (schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
18
+ export declare const requestParam: (propertyKey: string, schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
19
+ export declare const requestQueries: (schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
20
+ export declare const requestQuery: (propertyKey: string, schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
21
+ export declare const requestHeaders: (schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
22
+ export declare const requestHeader: (propertyKey: string, schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
23
+ export declare const requestCookies: (schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
24
+ export declare const requestCookie: (propertyKey: string, schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
25
+ export declare const requestBody: (schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
26
+ export declare const requestField: (propertyKey: string, schemaInput?: DataSchemaDecoratorInput) => (target: Prototype<object>, propertyKey: string, index: number) => void;
@@ -1,8 +1,8 @@
1
1
  import { Prototype } from '../../types.js';
2
- import { DataSchemaInput } from '../../data-schema-types.js';
2
+ import { DataSchemaDecoratorInput } from '../../data-schema-types.js';
3
3
  /**
4
4
  * Response body decorator.
5
5
  *
6
6
  * @param schemaOrType
7
7
  */
8
- export declare function responseBody<T extends object>(schemaInput?: DataSchemaInput): (target: Prototype<T>, propertyKey: string, descriptor: PropertyDescriptor) => void;
8
+ export declare function responseBody<T extends object>(schemaInput?: DataSchemaDecoratorInput): (target: Prototype<T>, propertyKey: string, descriptor: PropertyDescriptor) => void;
@@ -1,6 +1,9 @@
1
- export * from '@e22m4u/js-trie-router';
2
1
  export * from './rest-router.js';
3
2
  export * from './errors/index.js';
4
3
  export * from './decorators/index.js';
5
4
  export * from './data-schema-types.js';
6
5
  export * from './controller-registry.js';
6
+ export { RouteHandler } from '@e22m4u/js-trie-router';
7
+ export { RequestContext } from '@e22m4u/js-trie-router';
8
+ export { RoutePreHandler } from '@e22m4u/js-trie-router';
9
+ export { RoutePostHandler } from '@e22m4u/js-trie-router';
package/dist/esm/index.js CHANGED
@@ -1,6 +1,6 @@
1
- export * from '@e22m4u/js-trie-router';
2
1
  export * from './rest-router.js';
3
2
  export * from './errors/index.js';
4
3
  export * from './decorators/index.js';
5
4
  export * from './data-schema-types.js';
6
5
  export * from './controller-registry.js';
6
+ export { RequestContext } from '@e22m4u/js-trie-router';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@e22m4u/ts-rest-router",
3
- "version": "0.6.2",
3
+ "version": "0.6.3",
4
4
  "description": "Декларативный REST-маршрутизатор на основе контроллеров для TypeScript",
5
5
  "author": "Mikhail Evstropov <e22m4u@yandex.ru>",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@
45
45
  "@e22m4u/js-format": "~0.2.0",
46
46
  "@e22m4u/js-service": "~0.4.2",
47
47
  "@e22m4u/js-trie-router": "~0.3.1",
48
- "@e22m4u/ts-data-schema": "~0.4.4",
48
+ "@e22m4u/ts-data-schema": "~0.4.5",
49
49
  "@e22m4u/ts-reflector": "~0.1.8",
50
50
  "http-errors": "~2.0.0"
51
51
  },
@@ -13,6 +13,6 @@ export type DataSchemaFactory = (container: ServiceContainer) => DataSchema;
13
13
  export type DataSchemaOrFactory = DataSchema | DataSchemaFactory;
14
14
 
15
15
  /**
16
- * Data schema input.
16
+ * Data schema decorator input.
17
17
  */
18
- export type DataSchemaInput = DataSchemaOrFactory | DataType;
18
+ export type DataSchemaDecoratorInput = DataSchemaOrFactory | DataType;
@@ -4,12 +4,12 @@ import {Constructor} from '../../types.js';
4
4
  import {DataType} from '@e22m4u/ts-data-schema';
5
5
  import {DataSchema} from '@e22m4u/ts-data-schema';
6
6
  import {DecoratorTargetType} from '@e22m4u/ts-reflector';
7
- import {DataSchemaInput} from '../../data-schema-types.js';
8
7
  import {getDecoratorTargetType} from '@e22m4u/ts-reflector';
9
8
  import {RequestDataSource} from './request-data-metadata.js';
10
9
  import {RequestDataMetadata} from './request-data-metadata.js';
11
10
  import {DataSchemaOrFactory} from '../../data-schema-types.js';
12
11
  import {RequestDataReflector} from './request-data-reflector.js';
12
+ import {DataSchemaDecoratorInput} from '../../data-schema-types.js';
13
13
 
14
14
  /**
15
15
  * Request data options.
@@ -44,7 +44,7 @@ export function requestData<T extends object>(options: RequestDataOptions) {
44
44
  * @param source
45
45
  */
46
46
  function createRequestDataDecoratorWithSource(source: RequestDataSource) {
47
- return function (schemaInput?: DataSchemaInput) {
47
+ return function (schemaInput?: DataSchemaDecoratorInput) {
48
48
  let schema: DataSchemaOrFactory;
49
49
  if (typeof schemaInput === 'function' || typeof schemaInput === 'object') {
50
50
  schema = schemaInput;
@@ -65,7 +65,10 @@ function createRequestDataDecoratorWithSource(source: RequestDataSource) {
65
65
  function createRequestDataPropertyDecoratorWithSource(
66
66
  source: RequestDataSource,
67
67
  ) {
68
- return function (propertyKey: string, schemaInput?: DataSchemaInput) {
68
+ return function (
69
+ propertyKey: string,
70
+ schemaInput?: DataSchemaDecoratorInput,
71
+ ) {
69
72
  const rootSchema: DataSchema = {type: DataType.OBJECT};
70
73
  const properties = {} as NoUndef<DataSchema['properties']>;
71
74
  let schemaOrFactory: DataSchemaOrFactory = rootSchema;
@@ -1,17 +1,19 @@
1
1
  import {Prototype} from '../../types.js';
2
2
  import {Constructor} from '../../types.js';
3
3
  import {DecoratorTargetType} from '@e22m4u/ts-reflector';
4
- import {DataSchemaInput} from '../../data-schema-types.js';
5
4
  import {getDecoratorTargetType} from '@e22m4u/ts-reflector';
6
5
  import {DataSchemaOrFactory} from '../../data-schema-types.js';
7
6
  import {ResponseBodyReflector} from './response-body-reflector.js';
7
+ import {DataSchemaDecoratorInput} from '../../data-schema-types.js';
8
8
 
9
9
  /**
10
10
  * Response body decorator.
11
11
  *
12
12
  * @param schemaOrType
13
13
  */
14
- export function responseBody<T extends object>(schemaInput?: DataSchemaInput) {
14
+ export function responseBody<T extends object>(
15
+ schemaInput?: DataSchemaDecoratorInput,
16
+ ) {
15
17
  return function (
16
18
  target: Prototype<T>,
17
19
  propertyKey: string,
package/src/index.ts CHANGED
@@ -1,7 +1,10 @@
1
- export * from '@e22m4u/js-trie-router';
2
-
3
1
  export * from './rest-router.js';
4
2
  export * from './errors/index.js';
5
3
  export * from './decorators/index.js';
6
4
  export * from './data-schema-types.js';
7
5
  export * from './controller-registry.js';
6
+
7
+ export {RouteHandler} from '@e22m4u/js-trie-router';
8
+ export {RequestContext} from '@e22m4u/js-trie-router';
9
+ export {RoutePreHandler} from '@e22m4u/js-trie-router';
10
+ export {RoutePostHandler} from '@e22m4u/js-trie-router';