@innet/server 2.0.0-beta.1 → 2.0.0-beta.2

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.
Files changed (110) hide show
  1. package/README.md +22 -0
  2. package/handler/handler.d.ts +1 -7
  3. package/handler/handler.es6.js +1 -4
  4. package/handler/handler.js +0 -3
  5. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  6. package/hooks/useNewSchema/useNewSchema.es6.js +1 -1
  7. package/hooks/useNewSchema/useNewSchema.js +1 -1
  8. package/hooks/useRequest/useRequest.d.ts +0 -1
  9. package/hooks/useResponse/useResponse.d.ts +0 -1
  10. package/hooks/useSchemaType/useSchemaType.es6.js +17 -9
  11. package/hooks/useSchemaType/useSchemaType.js +17 -9
  12. package/hooks/useServer/useServer.d.ts +0 -2
  13. package/index.es6.js +0 -1
  14. package/index.js +0 -1
  15. package/package.json +15 -15
  16. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  17. package/plugins/handler/serverFn/serverFn.js +1 -1
  18. package/plugins/main/api/api.es6.js +73 -73
  19. package/plugins/main/api/api.js +73 -73
  20. package/plugins/main/endpoint/endpoint.d.ts +5 -0
  21. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  22. package/plugins/main/endpoint/endpoint.js +4 -4
  23. package/plugins/main/host/host.es6.js +3 -1
  24. package/plugins/main/host/host.js +3 -1
  25. package/plugins/main/param/param.es6.js +2 -3
  26. package/plugins/main/param/param.js +2 -3
  27. package/plugins/main/response/response.es6.js +10 -3
  28. package/plugins/main/response/response.js +10 -3
  29. package/plugins/main/server/server.d.ts +0 -1
  30. package/plugins/main/server/server.es6.js +6 -9
  31. package/plugins/main/server/server.js +6 -9
  32. package/plugins/main/variable/variable.es6.js +3 -4
  33. package/plugins/main/variable/variable.js +3 -4
  34. package/plugins/request/cookie/cookie.d.ts +2 -2
  35. package/plugins/request/cookie/cookie.es6.js +1 -2
  36. package/plugins/request/cookie/cookie.js +1 -2
  37. package/plugins/request/error/error.es6.js +1 -2
  38. package/plugins/request/error/error.js +1 -2
  39. package/plugins/request/file/file.es6.js +1 -2
  40. package/plugins/request/file/file.js +1 -2
  41. package/plugins/request/proxy/proxy.d.ts +0 -1
  42. package/plugins/schema/array/array.es6.js +1 -2
  43. package/plugins/schema/array/array.js +1 -2
  44. package/plugins/schema/date/date.es6.js +8 -4
  45. package/plugins/schema/date/date.js +8 -4
  46. package/plugins/schema/integer/integer.es6.js +8 -3
  47. package/plugins/schema/integer/integer.js +8 -3
  48. package/plugins/schema/number/number.es6.js +1 -2
  49. package/plugins/schema/number/number.js +1 -2
  50. package/plugins/schema/object/object.es6.js +1 -2
  51. package/plugins/schema/object/object.js +1 -2
  52. package/plugins/schema/string/string.es6.js +1 -2
  53. package/plugins/schema/string/string.js +1 -2
  54. package/plugins/schema/tuple/tuple.es6.js +1 -2
  55. package/plugins/schema/tuple/tuple.js +1 -2
  56. package/plugins/schema/uuid/uuid.es6.js +5 -3
  57. package/plugins/schema/uuid/uuid.js +5 -3
  58. package/utils/action/Action.d.ts +4 -5
  59. package/utils/action/Action.es6.js +14 -16
  60. package/utils/action/Action.js +13 -15
  61. package/utils/parseBody/parseBody.d.ts +0 -1
  62. package/utils/parseBody/parseBody.es6.js +13 -16
  63. package/utils/parseBody/parseBody.js +13 -16
  64. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  65. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  66. package/utils/parseFormBody/parseFormBody.js +41 -41
  67. package/utils/parseSearch/parseSearch.es6.js +4 -1
  68. package/utils/parseSearch/parseSearch.js +4 -1
  69. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  70. package/utils/rules/arrayOf/arrayOf.js +1 -1
  71. package/utils/rules/bin/bin.es6.js +4 -1
  72. package/utils/rules/bin/bin.js +4 -1
  73. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  74. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  75. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  76. package/utils/rules/dateTo/dateTo.js +4 -1
  77. package/utils/rules/helpers.es6.js +4 -1
  78. package/utils/rules/helpers.js +4 -1
  79. package/utils/rules/int/int.es6.js +17 -4
  80. package/utils/rules/int/int.js +17 -4
  81. package/utils/rules/max/max.es6.js +9 -3
  82. package/utils/rules/max/max.js +9 -3
  83. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  84. package/utils/rules/maxBin/maxBin.js +5 -2
  85. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  86. package/utils/rules/maxDate/maxDate.js +5 -1
  87. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  88. package/utils/rules/maxLength/maxLength.js +5 -2
  89. package/utils/rules/min/min.es6.js +9 -3
  90. package/utils/rules/min/min.js +9 -3
  91. package/utils/rules/minBin/minBin.es6.js +5 -2
  92. package/utils/rules/minBin/minBin.js +5 -2
  93. package/utils/rules/minDate/minDate.es6.js +5 -1
  94. package/utils/rules/minDate/minDate.js +5 -1
  95. package/utils/rules/minLength/minLength.es6.js +5 -2
  96. package/utils/rules/minLength/minLength.js +5 -2
  97. package/utils/rules/num/num.es6.js +4 -1
  98. package/utils/rules/num/num.js +4 -1
  99. package/utils/rules/objectOf/objectOf.es6.js +6 -3
  100. package/utils/rules/objectOf/objectOf.js +6 -3
  101. package/utils/rules/pattern/pattern.es6.js +6 -2
  102. package/utils/rules/pattern/pattern.js +6 -2
  103. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  104. package/utils/rules/tupleOf/tupleOf.js +1 -1
  105. package/utils/rules/values/values.es6.js +5 -2
  106. package/utils/rules/values/values.js +5 -2
  107. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  108. package/utils/stringifySearch/stringifySearch.js +4 -1
  109. package/_virtual/_rollup-plugin-process-env.es6.js +0 -10
  110. package/_virtual/_rollup-plugin-process-env.js +0 -12
package/README.md CHANGED
@@ -1396,6 +1396,28 @@ export default (
1396
1396
  )
1397
1397
  ```
1398
1398
 
1399
+ #### operationId
1400
+
1401
+ `operationId` is an optional unique string used to identify an operation.
1402
+ If provided, these IDs must be unique among all operations described in your API.
1403
+
1404
+ Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.
1405
+
1406
+ *src/app.tsx*
1407
+ ```typescript jsx
1408
+ export default (
1409
+ <server>
1410
+ <api>
1411
+ <endpoint
1412
+ method='get'
1413
+ path='/users'
1414
+ operationId='getUsers'
1415
+ />
1416
+ </api>
1417
+ </server>
1418
+ )
1419
+ ```
1420
+
1399
1421
  ### \<tag>
1400
1422
 
1401
1423
  [← back](#endpoints)
@@ -1,4 +1,4 @@
1
- import { context, type ContextProps, type JSXElement, slot, type SlotProps, slots, type SlotsProps } from '@innet/jsx';
1
+ import { type JSXElement } from '@innet/jsx';
2
2
  import { arraySync, async } from '@innet/utils';
3
3
  import { type AnyProps, type ApiProps, type ArrayProps, type BinaryProps, blacklist, type BlacklistProps, type BodyProps, type BooleanProps, cms, type CmsProps, type ContactProps, type CookieProps, type DateProps, type DtsProps, type EndpointProps, type EnvProps, type ErrorProps, type FieldProps, file, type FileProps, type HeaderProps, type HostProps, type IntegerProps, type LicenseProps, type NullProps, type NumberProps, type ObjectProps, type ParamProps, preset, type PresetProps, protection, type ProtectionProps, type ProxyProps, type RedirectProps, type ResponseProps, type ReturnProps, type ServerProps, type StringProps, type SuccessProps, type SwaggerProps, type TagProps, type TupleProps, type UuidProps, type VariableProps, whitelist, type WhitelistProps } from '../plugins';
4
4
  export declare const arrayPlugins: (typeof arraySync)[];
@@ -12,7 +12,6 @@ export declare const JSXPlugins: {
12
12
  boolean: import("innet").HandlerPlugin;
13
13
  cms: typeof cms;
14
14
  contact: import("innet").HandlerPlugin;
15
- context: typeof context;
16
15
  cookie: import("innet").HandlerPlugin;
17
16
  date: import("innet").HandlerPlugin;
18
17
  dts: import("innet").HandlerPlugin;
@@ -36,8 +35,6 @@ export declare const JSXPlugins: {
36
35
  response: import("innet").HandlerPlugin;
37
36
  return: import("innet").HandlerPlugin;
38
37
  server: import("innet").HandlerPlugin;
39
- slot: typeof slot;
40
- slots: typeof slots;
41
38
  string: import("innet").HandlerPlugin;
42
39
  success: import("innet").HandlerPlugin;
43
40
  swagger: import("innet").HandlerPlugin;
@@ -70,7 +67,6 @@ declare global {
70
67
  boolean: BooleanProps;
71
68
  cms: CmsProps;
72
69
  contact: ContactProps;
73
- context: ContextProps;
74
70
  cookie: CookieProps;
75
71
  date: DateProps;
76
72
  dts: DtsProps;
@@ -94,8 +90,6 @@ declare global {
94
90
  response: ResponseProps;
95
91
  return: ReturnProps;
96
92
  server: ServerProps;
97
- slot: SlotProps;
98
- slots: SlotsProps;
99
93
  string: StringProps;
100
94
  success: SuccessProps;
101
95
  swagger: SwaggerProps;
@@ -1,5 +1,5 @@
1
1
  import { createHandler } from 'innet';
2
- import { context, slot, slots, jsxPlugins, jsxComponent } from '@innet/jsx';
2
+ import { jsxPlugins, jsxComponent } from '@innet/jsx';
3
3
  import { arraySync, async, promise, array as array$1, nullish, object as object$1, fn } from '@innet/utils';
4
4
  import '../plugins/index.es6.js';
5
5
  import { any } from '../plugins/schema/any/any.es6.js';
@@ -57,7 +57,6 @@ const JSXPlugins = {
57
57
  boolean,
58
58
  cms,
59
59
  contact,
60
- context,
61
60
  cookie,
62
61
  date,
63
62
  dts,
@@ -81,8 +80,6 @@ const JSXPlugins = {
81
80
  response,
82
81
  return: returnPlugin,
83
82
  server,
84
- slot,
85
- slots,
86
83
  string,
87
84
  success,
88
85
  swagger,
@@ -61,7 +61,6 @@ const JSXPlugins = {
61
61
  boolean: boolean.boolean,
62
62
  cms: cms.cms,
63
63
  contact: contact.contact,
64
- context: jsx.context,
65
64
  cookie: cookie.cookie,
66
65
  date: date.date,
67
66
  dts: dts.dts,
@@ -85,8 +84,6 @@ const JSXPlugins = {
85
84
  response: response.response,
86
85
  return: _return.returnPlugin,
87
86
  server: server.server,
88
- slot: jsx.slot,
89
- slots: jsx.slots,
90
87
  string: string.string,
91
88
  success: success.success,
92
89
  swagger: swagger.swagger,
@@ -1,3 +1,2 @@
1
- /// <reference types="node" />
2
1
  import { type IncomingHttpHeaders } from 'http';
3
2
  export declare function useHeaders<D extends IncomingHttpHeaders>(): D;
@@ -15,7 +15,7 @@ function useNewSchema(schema = Object.create(null)) {
15
15
  parentSchema.oneOf.push(schema);
16
16
  }
17
17
  else if (parentSchema.type || '$ref' in parentSchema) {
18
- const oldSchema = Object.assign({}, parentSchema);
18
+ const oldSchema = { ...parentSchema };
19
19
  for (const key in parentSchema) {
20
20
  // @ts-expect-error: FIXME
21
21
  delete parentSchema[key];
@@ -19,7 +19,7 @@ function useNewSchema(schema = Object.create(null)) {
19
19
  parentSchema.oneOf.push(schema);
20
20
  }
21
21
  else if (parentSchema.type || '$ref' in parentSchema) {
22
- const oldSchema = Object.assign({}, parentSchema);
22
+ const oldSchema = { ...parentSchema };
23
23
  for (const key in parentSchema) {
24
24
  // @ts-expect-error: FIXME
25
25
  delete parentSchema[key];
@@ -1,2 +1 @@
1
- /// <reference types="node" />
2
1
  export declare function useRequest(): import("http").IncomingMessage;
@@ -1,2 +1 @@
1
- /// <reference types="node" />
2
1
  export declare function useResponse(): import("http").ServerResponse<import("http").IncomingMessage>;
@@ -1,12 +1,10 @@
1
- import { __rest } from 'tslib';
2
1
  import '../useApi/index.es6.js';
3
2
  import '../useNewSchema/index.es6.js';
4
3
  import { useApi } from '../useApi/useApi.es6.js';
5
4
  import { useNewSchema } from '../useNewSchema/useNewSchema.es6.js';
6
5
 
7
- function useSchemaType(type, _a = {}) {
8
- var _b;
9
- var { example, examples, ref, values } = _a, options = __rest(_a, ["example", "examples", "ref", "values"]);
6
+ function useSchemaType(type, { example, examples, ref, values, ...options } = {}) {
7
+ var _a;
10
8
  if (ref) {
11
9
  const { docs } = useApi();
12
10
  if (!docs.components) {
@@ -18,14 +16,24 @@ function useSchemaType(type, _a = {}) {
18
16
  useNewSchema({
19
17
  $ref: `#/components/schemas/${ref}`,
20
18
  });
21
- if ((_b = docs.components.schemas) === null || _b === void 0 ? void 0 : _b[ref]) {
19
+ if ((_a = docs.components.schemas) === null || _a === void 0 ? void 0 : _a[ref]) {
22
20
  return;
23
21
  }
24
- return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { enum: values, example,
25
- examples, type: type === 'any' ? undefined : type }));
22
+ return (docs.components.schemas[ref] = {
23
+ ...options,
24
+ enum: values,
25
+ example,
26
+ examples,
27
+ type: type === 'any' ? undefined : type,
28
+ });
26
29
  }
27
- return useNewSchema(Object.assign(Object.assign({}, options), { enum: values, example,
28
- examples, type: type === 'any' ? undefined : type }));
30
+ return useNewSchema({
31
+ ...options,
32
+ enum: values,
33
+ example,
34
+ examples,
35
+ type: type === 'any' ? undefined : type,
36
+ });
29
37
  }
30
38
 
31
39
  export { useSchemaType };
@@ -2,15 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var tslib = require('tslib');
6
5
  require('../useApi/index.js');
7
6
  require('../useNewSchema/index.js');
8
7
  var useApi = require('../useApi/useApi.js');
9
8
  var useNewSchema = require('../useNewSchema/useNewSchema.js');
10
9
 
11
- function useSchemaType(type, _a = {}) {
12
- var _b;
13
- var { example, examples, ref, values } = _a, options = tslib.__rest(_a, ["example", "examples", "ref", "values"]);
10
+ function useSchemaType(type, { example, examples, ref, values, ...options } = {}) {
11
+ var _a;
14
12
  if (ref) {
15
13
  const { docs } = useApi.useApi();
16
14
  if (!docs.components) {
@@ -22,14 +20,24 @@ function useSchemaType(type, _a = {}) {
22
20
  useNewSchema.useNewSchema({
23
21
  $ref: `#/components/schemas/${ref}`,
24
22
  });
25
- if ((_b = docs.components.schemas) === null || _b === void 0 ? void 0 : _b[ref]) {
23
+ if ((_a = docs.components.schemas) === null || _a === void 0 ? void 0 : _a[ref]) {
26
24
  return;
27
25
  }
28
- return (docs.components.schemas[ref] = Object.assign(Object.assign({}, options), { enum: values, example,
29
- examples, type: type === 'any' ? undefined : type }));
26
+ return (docs.components.schemas[ref] = {
27
+ ...options,
28
+ enum: values,
29
+ example,
30
+ examples,
31
+ type: type === 'any' ? undefined : type,
32
+ });
30
33
  }
31
- return useNewSchema.useNewSchema(Object.assign(Object.assign({}, options), { enum: values, example,
32
- examples, type: type === 'any' ? undefined : type }));
34
+ return useNewSchema.useNewSchema({
35
+ ...options,
36
+ enum: values,
37
+ example,
38
+ examples,
39
+ type: type === 'any' ? undefined : type,
40
+ });
33
41
  }
34
42
 
35
43
  exports.useSchemaType = useSchemaType;
@@ -1,5 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
1
  import { Context } from '@innet/jsx';
4
2
  import { type Server as HttpServer } from 'http';
5
3
  import { type Server as HttpsServer } from 'https';
package/index.es6.js CHANGED
@@ -1,4 +1,3 @@
1
- import './_virtual/_rollup-plugin-process-env.es6.js';
2
1
  import './handler/index.es6.js';
3
2
  import './plugins/index.es6.js';
4
3
  import './utils/index.es6.js';
package/index.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- require('./_virtual/_rollup-plugin-process-env.js');
6
5
  require('./handler/index.js');
7
6
  require('./plugins/index.js');
8
7
  require('./utils/index.js');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@innet/server",
3
- "version": "2.0.0-beta.1",
3
+ "version": "2.0.0-beta.2",
4
4
  "description": "Create server-side application with innet",
5
5
  "main": "index.js",
6
6
  "module": "index.es6.js",
@@ -21,7 +21,7 @@
21
21
  },
22
22
  "repository": {
23
23
  "type": "git",
24
- "url": "https://github.com/d8corp/innet-server.git"
24
+ "url": "git+https://github.com/d8corp/innet-server.git"
25
25
  },
26
26
  "keywords": [
27
27
  "innet",
@@ -35,23 +35,23 @@
35
35
  },
36
36
  "homepage": "https://github.com/d8corp/innet-server",
37
37
  "dependencies": {
38
- "@cantinc/utils": "^1.4.2",
39
- "@innet/jsx": "^2.0.0-beta.2",
40
- "@innet/utils": "^2.0.0-alpha.1",
41
- "@types/cookie": "^0.5.1",
42
- "@types/multiparty": "^0.0.33",
43
- "@types/qs": "^6.9.7",
44
- "cookie": "^0.5.0",
38
+ "@cantinc/utils": "^1.4.4",
39
+ "@innet/jsx": "^2.0.0-rc.3",
40
+ "@innet/utils": "^2.0.3-beta.1",
41
+ "@types/cookie": "^1.0.0",
42
+ "@types/multiparty": "^4.2.1",
43
+ "@types/qs": "^6.15.0",
44
+ "cookie": "^1.1.1",
45
45
  "http-proxy": "^1.18.1",
46
- "innet": "^2.0.0-alpha.3",
47
- "mime": "^3.0.0",
46
+ "innet": "^2.0.1",
47
+ "mime": "^4.1.0",
48
48
  "multiparty": "^4.2.3",
49
49
  "openapi-types": "^12.1.3",
50
- "qs": "^6.11.2",
50
+ "qs": "^6.15.0",
51
51
  "request-ip": "^3.3.0",
52
52
  "string_decoder": "^1.3.0",
53
- "tslib": "^2.6.1",
54
- "uuid": "^9.0.0",
55
- "watch-state": "^3.5.0-alpha.3"
53
+ "tslib": "^2.8.1",
54
+ "uuid": "^13.0.0",
55
+ "watch-state": "^3.6.2"
56
56
  }
57
57
  }
@@ -5,7 +5,7 @@ const serverFn = () => {
5
5
  return () => {
6
6
  const handler = useHandler();
7
7
  const fn = useApp();
8
- new Watch(update => {
8
+ new Watch((update) => {
9
9
  innet(fn(update), handler);
10
10
  });
11
11
  };
@@ -13,7 +13,7 @@ const serverFn = () => {
13
13
  return () => {
14
14
  const handler = innet.useHandler();
15
15
  const fn = innet.useApp();
16
- new watchState.Watch(update => {
16
+ new watchState.Watch((update) => {
17
17
  innet__default["default"](fn(update), handler);
18
18
  });
19
19
  };
@@ -1,4 +1,3 @@
1
- import { __rest, __awaiter } from 'tslib';
2
1
  import innet, { useNewHandler } from 'innet';
3
2
  import { useProps } from '@innet/jsx';
4
3
  import '../../../hooks/index.es6.js';
@@ -15,8 +14,8 @@ import { paramsContext } from '../../../hooks/useParams/useParams.es6.js';
15
14
  const api = () => {
16
15
  const handler = useNewHandler();
17
16
  const props = useProps();
18
- const { children, exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0' } = props, rest = __rest(props, ["children", "exclude", "include", "prefix", "title", "version"]);
19
- const info = Object.assign(Object.assign({}, rest), { title, version });
17
+ const { children, exclude, include, prefix = process.env.INNET_API_PREFIX || '', title = '', version = process.env.INNET_API_VERSION || '0.0.0', ...rest } = props;
18
+ const info = { ...rest, title, version };
20
19
  const endpoints = {};
21
20
  const docs = {
22
21
  info,
@@ -38,7 +37,7 @@ const api = () => {
38
37
  };
39
38
  serverPlugins.set(handler, plugins);
40
39
  apiContext.set(handler, context);
41
- useServerPlugin(() => __awaiter(void 0, void 0, void 0, function* () {
40
+ useServerPlugin(async () => {
42
41
  var _a, _b, _c, _d, _e, _f;
43
42
  const action = useAction();
44
43
  if (!condition(action))
@@ -62,91 +61,92 @@ const api = () => {
62
61
  const [deep, currentEndpoint, params] = endpointQueue.shift();
63
62
  const key = splitPath[deep];
64
63
  if (deep + 1 === splitPath.length) {
65
- function run(runEndpoint, params) {
64
+ async function run(runEndpoint, params) {
66
65
  var _a, _b, _c, _d, _e;
67
- return __awaiter(this, void 0, void 0, function* () {
68
- const pathRules = (_a = runEndpoint.rules) === null || _a === void 0 ? void 0 : _a.path;
69
- const headerRules = (_b = runEndpoint.rules) === null || _b === void 0 ? void 0 : _b.header;
70
- const cookieRules = (_c = runEndpoint.rules) === null || _c === void 0 ? void 0 : _c.cookie;
71
- const searchRules = (_d = runEndpoint.rules) === null || _d === void 0 ? void 0 : _d.search;
72
- const bodyRules = (_e = runEndpoint.rules) === null || _e === void 0 ? void 0 : _e.body;
73
- if (pathRules) {
74
- try {
75
- Object.assign(params, pathRules(params, { in: 'path' }));
76
- }
77
- catch (_f) {
78
- return false;
79
- }
66
+ const pathRules = (_a = runEndpoint.rules) === null || _a === void 0 ? void 0 : _a.path;
67
+ const headerRules = (_b = runEndpoint.rules) === null || _b === void 0 ? void 0 : _b.header;
68
+ const cookieRules = (_c = runEndpoint.rules) === null || _c === void 0 ? void 0 : _c.cookie;
69
+ const searchRules = (_d = runEndpoint.rules) === null || _d === void 0 ? void 0 : _d.search;
70
+ const bodyRules = (_e = runEndpoint.rules) === null || _e === void 0 ? void 0 : _e.body;
71
+ if (pathRules) {
72
+ try {
73
+ Object.assign(params, pathRules(params, { in: 'path' }));
80
74
  }
81
- function checkActionRules(rules, key = 'search') {
82
- if (rules) {
83
- try {
84
- action[key] = rules(action[key]);
85
- }
86
- catch (e) {
87
- res.setHeader('Content-Type', 'application/json');
88
- if (e instanceof RulesError) {
89
- res.statusCode = 400;
90
- res.write(JSONString({
91
- data: Object.assign(Object.assign({}, e.data), { in: key }),
92
- error: 'requestValidation',
93
- }));
94
- res.end();
95
- }
96
- else {
97
- console.error(e);
98
- res.statusCode = 500;
99
- res.write(JSONString({
100
- data: { in: key },
101
- error: 'unknown',
102
- }));
103
- res.end();
104
- }
105
- return true;
106
- }
107
- }
75
+ catch (_f) {
108
76
  return false;
109
77
  }
110
- if (checkActionRules(headerRules, 'headers'))
111
- return true;
112
- if (checkActionRules(cookieRules, 'cookies'))
113
- return true;
114
- if (checkActionRules(searchRules, 'search'))
115
- return true;
116
- if (bodyRules) {
117
- yield action.parseBody();
118
- if (!action.body) {
119
- res.statusCode = 400;
78
+ }
79
+ function checkActionRules(rules, key = 'search') {
80
+ if (rules) {
81
+ try {
82
+ action[key] = rules(action[key]);
83
+ }
84
+ catch (e) {
120
85
  res.setHeader('Content-Type', 'application/json');
121
- res.write(JSONString({
122
- error: 'requestBodyContentType',
123
- }));
124
- res.end();
86
+ if (e instanceof RulesError) {
87
+ res.statusCode = 400;
88
+ res.write(JSONString({
89
+ data: {
90
+ ...e.data,
91
+ in: key,
92
+ },
93
+ error: 'requestValidation',
94
+ }));
95
+ res.end();
96
+ }
97
+ else {
98
+ console.error(e);
99
+ res.statusCode = 500;
100
+ res.write(JSONString({
101
+ data: { in: key },
102
+ error: 'unknown',
103
+ }));
104
+ res.end();
105
+ }
125
106
  return true;
126
107
  }
127
- if (checkActionRules(bodyRules, 'body'))
128
- return true;
129
108
  }
130
- paramsContext.set(actionHandler, params);
131
- for (const plugin of runEndpoint.plugins) {
132
- const result = yield plugin();
133
- if (result === undefined)
134
- continue;
135
- innet(result, actionHandler);
109
+ return false;
110
+ }
111
+ if (checkActionRules(headerRules, 'headers'))
112
+ return true;
113
+ if (checkActionRules(cookieRules, 'cookies'))
114
+ return true;
115
+ if (checkActionRules(searchRules, 'search'))
116
+ return true;
117
+ if (bodyRules) {
118
+ await action.parseBody();
119
+ if (!action.body) {
120
+ res.statusCode = 400;
121
+ res.setHeader('Content-Type', 'application/json');
122
+ res.write(JSONString({
123
+ error: 'requestBodyContentType',
124
+ }));
125
+ res.end();
136
126
  return true;
137
127
  }
128
+ if (checkActionRules(bodyRules, 'body'))
129
+ return true;
130
+ }
131
+ paramsContext.set(actionHandler, params);
132
+ for (const plugin of runEndpoint.plugins) {
133
+ const result = await plugin();
134
+ if (result === undefined)
135
+ continue;
136
+ innet(result, actionHandler);
138
137
  return true;
139
- });
138
+ }
139
+ return true;
140
140
  }
141
141
  if ((_d = (_c = currentEndpoint.static) === null || _c === void 0 ? void 0 : _c[key]) === null || _d === void 0 ? void 0 : _d.plugins) {
142
- if (!(yield run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params)))
142
+ if (!await run((_e = currentEndpoint.static) === null || _e === void 0 ? void 0 : _e[key], params))
143
143
  continue;
144
144
  return null;
145
145
  }
146
146
  if (currentEndpoint.dynamic) {
147
147
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
148
148
  if (dynamicEndpoint.plugins) {
149
- if (!(yield run(dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key }))))
149
+ if (!await run(dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }))
150
150
  continue;
151
151
  return null;
152
152
  }
@@ -159,12 +159,12 @@ const api = () => {
159
159
  }
160
160
  if (currentEndpoint.dynamic) {
161
161
  for (const dynamicEndpoint of currentEndpoint.dynamic) {
162
- endpointQueue.push([deep + 1, dynamicEndpoint, Object.assign(Object.assign({}, params), { [dynamicEndpoint.key.slice(1, -1)]: key })]);
162
+ endpointQueue.push([deep + 1, dynamicEndpoint, { ...params, [dynamicEndpoint.key.slice(1, -1)]: key }]);
163
163
  }
164
164
  }
165
165
  }
166
166
  for (const plugin of plugins) {
167
- const result = yield plugin();
167
+ const result = await plugin();
168
168
  if (result === undefined)
169
169
  continue;
170
170
  const newHandler = Object.create(handler);
@@ -172,7 +172,7 @@ const api = () => {
172
172
  innet(result, newHandler);
173
173
  return null;
174
174
  }
175
- }));
175
+ });
176
176
  innet(children, handler);
177
177
  };
178
178