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

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 (154) hide show
  1. package/README.md +1869 -3651
  2. package/handler/handler.d.ts +5 -2
  3. package/handler/handler.es6.js +2 -0
  4. package/handler/handler.js +2 -0
  5. package/hooks/index.d.ts +25 -23
  6. package/hooks/index.es6.js +25 -23
  7. package/hooks/index.js +25 -23
  8. package/hooks/useAction/useAction.es6.js +1 -1
  9. package/hooks/useAction/useAction.js +1 -1
  10. package/hooks/useApi/useApi.d.ts +2 -0
  11. package/hooks/useData/index.d.ts +1 -0
  12. package/hooks/useData/index.es6.js +1 -0
  13. package/hooks/useData/index.js +9 -0
  14. package/hooks/useData/useData.d.ts +6 -0
  15. package/hooks/useData/useData.es6.js +29 -0
  16. package/hooks/useData/useData.js +33 -0
  17. package/hooks/useEffect/index.d.ts +1 -0
  18. package/hooks/useEffect/index.es6.js +1 -0
  19. package/hooks/useEffect/index.js +9 -0
  20. package/hooks/useEffect/useEffect.d.ts +2 -0
  21. package/hooks/useEffect/useEffect.es6.js +8 -0
  22. package/hooks/useEffect/useEffect.js +12 -0
  23. package/hooks/useSchemaType/useSchemaType.d.ts +2 -2
  24. package/hooks/useSchemaType/useSchemaType.es6.js +13 -4
  25. package/hooks/useSchemaType/useSchemaType.js +13 -4
  26. package/hooks/useSearch/useSearch.es6.js +1 -1
  27. package/hooks/useSearch/useSearch.js +1 -1
  28. package/hooks/useServer/useServer.d.ts +2 -0
  29. package/index.d.ts +2 -2
  30. package/index.es6.js +90 -86
  31. package/index.js +204 -193
  32. package/package.json +5 -4
  33. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  34. package/plugins/handler/serverFn/serverFn.js +1 -5
  35. package/plugins/index.d.ts +2 -2
  36. package/plugins/index.es6.js +2 -2
  37. package/plugins/index.js +2 -2
  38. package/plugins/main/api/api.es6.js +6 -5
  39. package/plugins/main/api/api.js +8 -11
  40. package/plugins/main/body/body.es6.js +4 -4
  41. package/plugins/main/body/body.js +4 -8
  42. package/plugins/main/endpoint/endpoint.es6.js +4 -4
  43. package/plugins/main/endpoint/endpoint.js +4 -8
  44. package/plugins/main/host/host.es6.js +1 -1
  45. package/plugins/main/host/host.js +1 -5
  46. package/plugins/main/index.d.ts +8 -8
  47. package/plugins/main/index.es6.js +8 -8
  48. package/plugins/main/index.js +8 -8
  49. package/plugins/main/param/param.es6.js +1 -1
  50. package/plugins/main/param/param.js +1 -5
  51. package/plugins/main/preset/preset.es6.js +1 -1
  52. package/plugins/main/preset/preset.js +1 -5
  53. package/plugins/main/response/response.d.ts +2 -1
  54. package/plugins/main/response/response.es6.js +1 -1
  55. package/plugins/main/response/response.js +1 -5
  56. package/plugins/main/server/server.d.ts +4 -0
  57. package/plugins/main/server/server.es6.js +5 -3
  58. package/plugins/main/server/server.js +6 -5
  59. package/plugins/main/tag/index.es6.js +1 -1
  60. package/plugins/main/tag/index.js +1 -0
  61. package/plugins/main/tag/tag.d.ts +8 -1
  62. package/plugins/main/tag/tag.es6.js +20 -3
  63. package/plugins/main/tag/tag.js +20 -6
  64. package/plugins/request/cms/cms.es6.js +1 -1
  65. package/plugins/request/cms/cms.js +2 -3
  66. package/plugins/request/error/error.es6.js +7 -3
  67. package/plugins/request/error/error.js +7 -3
  68. package/plugins/request/file/file.es6.js +2 -2
  69. package/plugins/request/file/file.js +2 -3
  70. package/plugins/request/header/header.es6.js +1 -1
  71. package/plugins/request/header/header.js +1 -1
  72. package/plugins/request/index.d.ts +5 -5
  73. package/plugins/request/index.es6.js +5 -5
  74. package/plugins/request/index.js +5 -5
  75. package/plugins/request/success/success.es6.js +6 -4
  76. package/plugins/request/success/success.js +6 -4
  77. package/plugins/schema/any/any.d.ts +2 -2
  78. package/plugins/schema/array/array.d.ts +5 -2
  79. package/plugins/schema/array/array.es6.js +14 -5
  80. package/plugins/schema/array/array.js +15 -10
  81. package/plugins/schema/binary/binary.d.ts +4 -0
  82. package/plugins/schema/boolean/boolean.d.ts +3 -2
  83. package/plugins/schema/date/date.d.ts +3 -2
  84. package/plugins/schema/date/date.es6.js +2 -2
  85. package/plugins/schema/date/date.js +2 -2
  86. package/plugins/schema/field/field.d.ts +4 -0
  87. package/plugins/schema/field/field.es6.js +16 -3
  88. package/plugins/schema/field/field.js +16 -7
  89. package/plugins/schema/index.d.ts +8 -8
  90. package/plugins/schema/index.es6.js +8 -8
  91. package/plugins/schema/index.js +8 -8
  92. package/plugins/schema/integer/integer.d.ts +39 -2
  93. package/plugins/schema/integer/integer.es6.js +25 -10
  94. package/plugins/schema/integer/integer.js +25 -10
  95. package/plugins/schema/null/null.d.ts +2 -2
  96. package/plugins/schema/number/number.d.ts +34 -2
  97. package/plugins/schema/number/number.es6.js +23 -7
  98. package/plugins/schema/number/number.js +22 -6
  99. package/plugins/schema/object/object.d.ts +2 -2
  100. package/plugins/schema/object/object.es6.js +8 -6
  101. package/plugins/schema/object/object.js +8 -10
  102. package/plugins/schema/string/string.d.ts +29 -2
  103. package/plugins/schema/string/string.es6.js +11 -5
  104. package/plugins/schema/string/string.js +10 -4
  105. package/plugins/schema/tuple/tuple.d.ts +2 -2
  106. package/plugins/schema/tuple/tuple.es6.js +4 -4
  107. package/plugins/schema/tuple/tuple.js +4 -8
  108. package/plugins/schema/uuid/uuid.d.ts +2 -2
  109. package/plugins/schema/uuid/uuid.es6.js +2 -2
  110. package/plugins/schema/uuid/uuid.js +1 -1
  111. package/plugins/utils/dts/dts.es6.js +5 -2
  112. package/plugins/utils/dts/dts.js +5 -2
  113. package/plugins/utils/env/env.es6.js +1 -1
  114. package/plugins/utils/env/env.js +1 -5
  115. package/plugins/utils/index.d.ts +3 -2
  116. package/plugins/utils/index.es6.js +3 -2
  117. package/plugins/utils/index.js +3 -2
  118. package/plugins/utils/swagger/swagger.d.ts +1 -0
  119. package/plugins/utils/swagger/swagger.es6.js +1 -0
  120. package/plugins/utils/swagger/swagger.js +1 -0
  121. package/plugins/utils/ui/index.d.ts +1 -0
  122. package/plugins/utils/ui/index.es6.js +1 -0
  123. package/plugins/utils/ui/index.js +10 -0
  124. package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
  125. package/plugins/utils/ui/rapidoc.html.js +7 -0
  126. package/plugins/utils/ui/redoc.html.es6.js +3 -0
  127. package/plugins/utils/ui/redoc.html.js +7 -0
  128. package/plugins/utils/ui/scalar.html.es6.js +3 -0
  129. package/plugins/utils/ui/scalar.html.js +7 -0
  130. package/plugins/utils/ui/swagger.html.es6.js +3 -0
  131. package/plugins/utils/ui/swagger.html.js +7 -0
  132. package/plugins/utils/ui/ui.d.ts +13 -0
  133. package/plugins/utils/ui/ui.es6.js +45 -0
  134. package/plugins/utils/ui/ui.js +50 -0
  135. package/types.d.ts +23 -3
  136. package/utils/generateTypes/generateTypes.es6.js +105 -76
  137. package/utils/generateTypes/generateTypes.js +105 -76
  138. package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
  139. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  140. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  141. package/utils/getSafeSchema/index.d.ts +1 -0
  142. package/utils/getSafeSchema/index.es6.js +1 -0
  143. package/utils/getSafeSchema/index.js +9 -0
  144. package/utils/index.d.ts +9 -8
  145. package/utils/index.es6.js +9 -8
  146. package/utils/index.js +9 -8
  147. package/utils/rules/index.d.ts +17 -17
  148. package/utils/rules/index.es6.js +17 -17
  149. package/utils/rules/index.js +18 -18
  150. package/utils/rules/values/index.es6.js +1 -1
  151. package/utils/rules/values/index.js +1 -0
  152. package/utils/rules/values/values.d.ts +3 -1
  153. package/utils/rules/values/values.es6.js +4 -1
  154. package/utils/rules/values/values.js +4 -0
@@ -1,6 +1,5 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useContext, useChildren } from '@innet/jsx';
3
- import { callHandler } from '@innet/utils';
4
3
  import { allBodyTypes } from '../../../constants.es6.js';
5
4
  import '../../../hooks/index.es6.js';
6
5
  import '../../../utils/index.es6.js';
@@ -9,6 +8,7 @@ import { schemaContext } from '../../../hooks/useSchemaContext/useSchemaContext.
9
8
  import { getOrAdd } from '../../../utils/getOrAdd/getOrAdd.es6.js';
10
9
  import { bodyFileContext } from '../../../hooks/useBodyFile/useBodyFile.es6.js';
11
10
  import { ruleContext } from '../../../hooks/useRule/useRule.es6.js';
11
+ import { useEffect } from '../../../hooks/useEffect/useEffect.es6.js';
12
12
 
13
13
  const body = () => {
14
14
  const endpoint = useContext(endpointContext);
@@ -40,7 +40,7 @@ const body = () => {
40
40
  rules.body = rule;
41
41
  });
42
42
  innet(children, handler);
43
- innet(() => {
43
+ useEffect(() => {
44
44
  if (fileUsed) {
45
45
  requestBody.content['multipart/form-data'] = { schema };
46
46
  }
@@ -49,7 +49,7 @@ const body = () => {
49
49
  requestBody.content[type] = { schema };
50
50
  }
51
51
  }
52
- }, callHandler);
52
+ });
53
53
  };
54
54
 
55
55
  export { body };
@@ -4,7 +4,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var innet = require('innet');
6
6
  var jsx = require('@innet/jsx');
7
- var utils = require('@innet/utils');
8
7
  var constants = require('../../../constants.js');
9
8
  require('../../../hooks/index.js');
10
9
  require('../../../utils/index.js');
@@ -13,10 +12,7 @@ var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext
13
12
  var getOrAdd = require('../../../utils/getOrAdd/getOrAdd.js');
14
13
  var useBodyFile = require('../../../hooks/useBodyFile/useBodyFile.js');
15
14
  var useRule = require('../../../hooks/useRule/useRule.js');
16
-
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
18
-
19
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
15
+ var useEffect = require('../../../hooks/useEffect/useEffect.js');
20
16
 
21
17
  const body = () => {
22
18
  const endpoint = jsx.useContext(useEndpoint.endpointContext);
@@ -47,8 +43,8 @@ const body = () => {
47
43
  useRule.ruleContext.set(handler, rule => {
48
44
  rules.body = rule;
49
45
  });
50
- innet__default["default"](children, handler);
51
- innet__default["default"](() => {
46
+ innet.innet(children, handler);
47
+ useEffect.useEffect(() => {
52
48
  if (fileUsed) {
53
49
  requestBody.content['multipart/form-data'] = { schema };
54
50
  }
@@ -57,7 +53,7 @@ const body = () => {
57
53
  requestBody.content[type] = { schema };
58
54
  }
59
55
  }
60
- }, utils.callHandler);
56
+ });
61
57
  };
62
58
 
63
59
  exports.body = body;
@@ -1,4 +1,4 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
@@ -24,12 +24,12 @@ const endpoint = () => {
24
24
  throw Error(`You cannot use the same endpoints ${method}:${path}`);
25
25
  }
26
26
  const operation = {};
27
- if (summary) {
28
- operation.summary = summary;
29
- }
30
27
  if (operationId) {
31
28
  operation.operationId = operationId;
32
29
  }
30
+ if (summary) {
31
+ operation.summary = summary;
32
+ }
33
33
  if (description) {
34
34
  operation.description = description;
35
35
  }
@@ -12,10 +12,6 @@ var getEndpoint = require('../../../utils/getEndpoint/getEndpoint.js');
12
12
  var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
13
13
  var useServerPlugins = require('../../../hooks/useServerPlugins/useServerPlugins.js');
14
14
 
15
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
16
-
17
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
18
-
19
15
  const endpoint = () => {
20
16
  const handler = innet.useNewHandler();
21
17
  const tag = useTag.useTag();
@@ -32,12 +28,12 @@ const endpoint = () => {
32
28
  throw Error(`You cannot use the same endpoints ${method}:${path}`);
33
29
  }
34
30
  const operation = {};
35
- if (summary) {
36
- operation.summary = summary;
37
- }
38
31
  if (operationId) {
39
32
  operation.operationId = operationId;
40
33
  }
34
+ if (summary) {
35
+ operation.summary = summary;
36
+ }
41
37
  if (description) {
42
38
  operation.description = description;
43
39
  }
@@ -58,7 +54,7 @@ const endpoint = () => {
58
54
  useEndpoint.endpointContext.set(handler, { endpoint, operation, props });
59
55
  // @ts-expect-error: it's always an object
60
56
  useServerPlugins.serverPlugins.set(handler, endpoint.plugins);
61
- innet__default["default"](children, handler);
57
+ innet.innet(children, handler);
62
58
  };
63
59
 
64
60
  exports.endpoint = endpoint;
@@ -1,4 +1,4 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps, useChildren, useContext } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
@@ -9,10 +9,6 @@ var useApi = require('../../../hooks/useApi/useApi.js');
9
9
  var useEndpoint = require('../../../hooks/useEndpoint/useEndpoint.js');
10
10
  var useHost = require('../../../hooks/useHost/useHost.js');
11
11
 
12
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
-
14
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
15
-
16
12
  const host = () => {
17
13
  const handler = innet.useNewHandler();
18
14
  const { docs } = useApi.useApi();
@@ -30,7 +26,7 @@ const host = () => {
30
26
  // @ts-expect-error: FIXME
31
27
  servers.push(server);
32
28
  handler[useHost.hostContext.key] = { server };
33
- innet__default["default"](children, handler);
29
+ innet.innet(children, handler);
34
30
  };
35
31
 
36
32
  exports.host = host;
@@ -1,13 +1,13 @@
1
- export * from './server';
2
1
  export * from './api';
2
+ export * from './body';
3
3
  export * from './contact';
4
- export * from './license';
5
- export * from './host';
6
- export * from './variable';
7
- export * from './tag';
8
4
  export * from './endpoint';
9
- export * from './response';
10
- export * from './return';
5
+ export * from './host';
6
+ export * from './license';
11
7
  export * from './param';
12
- export * from './body';
13
8
  export * from './preset';
9
+ export * from './response';
10
+ export * from './return';
11
+ export * from './server';
12
+ export * from './tag';
13
+ export * from './variable';
@@ -1,13 +1,13 @@
1
- import './server/index.es6.js';
2
1
  import './api/index.es6.js';
2
+ import './body/index.es6.js';
3
3
  import './contact/index.es6.js';
4
- import './license/index.es6.js';
5
- import './host/index.es6.js';
6
- import './variable/index.es6.js';
7
- import './tag/index.es6.js';
8
4
  import './endpoint/index.es6.js';
9
- import './response/index.es6.js';
10
- import './return/index.es6.js';
5
+ import './host/index.es6.js';
6
+ import './license/index.es6.js';
11
7
  import './param/index.es6.js';
12
- import './body/index.es6.js';
13
8
  import './preset/index.es6.js';
9
+ import './response/index.es6.js';
10
+ import './return/index.es6.js';
11
+ import './server/index.es6.js';
12
+ import './tag/index.es6.js';
13
+ import './variable/index.es6.js';
@@ -1,16 +1,16 @@
1
1
  'use strict';
2
2
 
3
- require('./server/index.js');
4
3
  require('./api/index.js');
4
+ require('./body/index.js');
5
5
  require('./contact/index.js');
6
- require('./license/index.js');
7
- require('./host/index.js');
8
- require('./variable/index.js');
9
- require('./tag/index.js');
10
6
  require('./endpoint/index.js');
11
- require('./response/index.js');
12
- require('./return/index.js');
7
+ require('./host/index.js');
8
+ require('./license/index.js');
13
9
  require('./param/index.js');
14
- require('./body/index.js');
15
10
  require('./preset/index.js');
11
+ require('./response/index.js');
12
+ require('./return/index.js');
13
+ require('./server/index.js');
14
+ require('./tag/index.js');
15
+ require('./variable/index.js');
16
16
 
@@ -1,4 +1,4 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
@@ -16,10 +16,6 @@ var useRule = require('../../../hooks/useRule/useRule.js');
16
16
  var required = require('../../../utils/rules/required/required.js');
17
17
  var oneOf = require('../../../utils/rules/oneOf/oneOf.js');
18
18
 
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
22
-
23
19
  const inMap = {
24
20
  cookie: 'cookie',
25
21
  header: 'header',
@@ -64,7 +60,7 @@ const param = () => {
64
60
  rulesMap[key] = override(rule);
65
61
  }
66
62
  });
67
- innet__default["default"](children, handler);
63
+ innet.innet(children, handler);
68
64
  };
69
65
 
70
66
  exports.param = param;
@@ -1,4 +1,4 @@
1
- import innet, { useHandler } from 'innet';
1
+ import { innet, useHandler } from 'innet';
2
2
  import { useChildren } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import { useServerPlugin } from '../../../hooks/useServerPlugin/useServerPlugin.es6.js';
@@ -7,14 +7,10 @@ var jsx = require('@innet/jsx');
7
7
  require('../../../hooks/index.js');
8
8
  var useServerPlugin = require('../../../hooks/useServerPlugin/useServerPlugin.js');
9
9
 
10
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
11
-
12
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
13
-
14
10
  function preset() {
15
11
  const children = jsx.useChildren();
16
12
  useServerPlugin.useServerPlugin(() => {
17
- innet__default["default"](children, innet.useHandler());
13
+ innet.innet(children, innet.useHandler());
18
14
  });
19
15
  }
20
16
 
@@ -1,6 +1,7 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
2
  import { type ErrorStatuses, type RedirectStatuses, type SuccessStatuses } from '../../request';
3
3
  export type StatusKey = ErrorStatuses | RedirectStatuses | SuccessStatuses;
4
+ export type ResponseStatus = 'default' | `${1 | 2 | 3 | 4 | 5}XX` | StatusKey | number;
4
5
  export interface ResponseProps {
5
6
  children?: any;
6
7
  /**
@@ -14,7 +15,7 @@ export interface ResponseProps {
14
15
  * For example, 2XX represents all response codes between [200-299].
15
16
  * Only the following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX.
16
17
  * */
17
- status?: 'default' | `${1 | 2 | 3 | 4 | 5}XX` | StatusKey | number;
18
+ status?: ResponseStatus;
18
19
  type?: string;
19
20
  }
20
21
  export declare const statuses: Record<StatusKey, number>;
@@ -1,4 +1,4 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useProps, useContext } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import '../../../utils/index.es6.js';
@@ -16,10 +16,6 @@ var useSchemaContext = require('../../../hooks/useSchemaContext/useSchemaContext
16
16
  var getOrAdd = require('../../../utils/getOrAdd/getOrAdd.js');
17
17
  var useRule = require('../../../hooks/useRule/useRule.js');
18
18
 
19
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
20
-
21
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
22
-
23
19
  const statuses = {
24
20
  ...error.errorStatuses,
25
21
  ...redirect.redirectStatuses,
@@ -62,7 +58,7 @@ const response = () => {
62
58
  useRule.ruleContext.set(handler, rule => {
63
59
  rules.response = rule;
64
60
  });
65
- innet__default["default"](children, handler);
61
+ innet.innet(children, handler);
66
62
  };
67
63
 
68
64
  exports.response = response;
@@ -3,6 +3,10 @@ import { type IncomingMessage, type ServerResponse } from 'http';
3
3
  import { type ServerStartParams, type SSL } from '../../../types';
4
4
  export interface ServerProps {
5
5
  children?: any;
6
+ formatError?: (target: {
7
+ data: any;
8
+ error: string;
9
+ }) => string;
6
10
  onClose?: () => any;
7
11
  onError?: (e: Error) => any;
8
12
  onRequest?: (req: IncomingMessage, res: ServerResponse) => any;
@@ -1,4 +1,4 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, useApp, useHandler, net, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import fs from 'node:fs';
4
4
  import http from 'node:http';
@@ -36,7 +36,7 @@ const server = () => {
36
36
  const { onClose, onError, onRequest, onStart, port = Number((_c = env.INNET_PORT) !== null && _c !== void 0 ? _c : (https ? 443 : 80)), } = props;
37
37
  const plugins = new Set();
38
38
  const server = https ? http2.createServer({ cert, key }) : http.createServer();
39
- serverContext.set(handler, { port, server });
39
+ serverContext.set(handler, { port, props, server });
40
40
  serverPlugins.set(handler, plugins);
41
41
  serverPortContext.set(handler, port);
42
42
  serverHttpsContext.set(handler, https);
@@ -56,8 +56,10 @@ const server = () => {
56
56
  actionContext.set(requestHandler, action);
57
57
  requestHandlerContext.set(requestHandler, requestHandler);
58
58
  async function server() {
59
+ const app = useApp();
60
+ const handler = useHandler();
59
61
  for (const plugin of plugins) {
60
- const result = await plugin();
62
+ const result = await net(plugin, app, handler);
61
63
  if (result !== undefined) {
62
64
  return result;
63
65
  }
@@ -20,7 +20,6 @@ var useRequestHandler = require('../../../hooks/useRequestHandler/useRequestHand
20
20
 
21
21
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
22
22
 
23
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
24
23
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
25
24
  var http__default = /*#__PURE__*/_interopDefaultLegacy(http);
26
25
  var http2__default = /*#__PURE__*/_interopDefaultLegacy(http2);
@@ -47,7 +46,7 @@ const server = () => {
47
46
  const { onClose, onError, onRequest, onStart, port = Number((_c = env.INNET_PORT) !== null && _c !== void 0 ? _c : (https ? 443 : 80)), } = props;
48
47
  const plugins = new Set();
49
48
  const server = https ? http2__default["default"].createServer({ cert, key }) : http__default["default"].createServer();
50
- useServer.serverContext.set(handler, { port, server });
49
+ useServer.serverContext.set(handler, { port, props, server });
51
50
  useServerPlugins.serverPlugins.set(handler, plugins);
52
51
  useServerPort.serverPortContext.set(handler, port);
53
52
  useIsServerHttps.serverHttpsContext.set(handler, https);
@@ -67,16 +66,18 @@ const server = () => {
67
66
  useAction.actionContext.set(requestHandler, action);
68
67
  useRequestHandler.requestHandlerContext.set(requestHandler, requestHandler);
69
68
  async function server() {
69
+ const app = innet.useApp();
70
+ const handler = innet.useHandler();
70
71
  for (const plugin of plugins) {
71
- const result = await plugin();
72
+ const result = await innet.net(plugin, app, handler);
72
73
  if (result !== undefined) {
73
74
  return result;
74
75
  }
75
76
  }
76
77
  }
77
- innet__default["default"]({ props, type: server }, requestHandler);
78
+ innet.innet({ props, type: server }, requestHandler);
78
79
  });
79
- innet__default["default"](props.children, handler);
80
+ innet.innet(props.children, handler);
80
81
  server.listen(port, () => {
81
82
  onStart === null || onStart === void 0 ? void 0 : onStart({ https, port });
82
83
  });
@@ -1 +1 @@
1
- export { tag } from './tag.es6.js';
1
+ export { TAG_GROUP_NAME, tag } from './tag.es6.js';
@@ -6,4 +6,5 @@ var tag = require('./tag.js');
6
6
 
7
7
 
8
8
 
9
+ exports.TAG_GROUP_NAME = tag.TAG_GROUP_NAME;
9
10
  exports.tag = tag.tag;
@@ -1,4 +1,9 @@
1
1
  import { type HandlerPlugin } from 'innet';
2
+ export interface TagGroup {
3
+ name: string;
4
+ tags: string[];
5
+ }
6
+ export declare const TAG_GROUP_NAME = "x-tagGroups";
2
7
  export interface TagProps {
3
8
  children?: any;
4
9
  /**
@@ -6,7 +11,9 @@ export interface TagProps {
6
11
  * [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
7
12
  * */
8
13
  description?: string;
9
- /** The name of the tag. */
14
+ /** A name of the tag group. */
15
+ group?: string;
16
+ /** A name of the tag. */
10
17
  name: string;
11
18
  }
12
19
  export declare const tag: HandlerPlugin;
@@ -1,14 +1,15 @@
1
- import innet, { useNewHandler } from 'innet';
1
+ import { useNewHandler, innet } from 'innet';
2
2
  import { useContext, useProps } from '@innet/jsx';
3
3
  import '../../../hooks/index.es6.js';
4
4
  import { tagContext } from '../../../hooks/useTag/useTag.es6.js';
5
5
  import { useApi } from '../../../hooks/useApi/useApi.es6.js';
6
6
 
7
+ const TAG_GROUP_NAME = 'x-tagGroups';
7
8
  const tag = () => {
8
9
  if (useContext(tagContext)) {
9
10
  throw Error('You cannot use a <tag> inside another one');
10
11
  }
11
- const { children, description, name, } = useProps();
12
+ const { children, description, group, name, } = useProps();
12
13
  const { docs } = useApi();
13
14
  const tag = { name };
14
15
  if (description) {
@@ -23,9 +24,25 @@ const tag = () => {
23
24
  else {
24
25
  throw Error(`You cannot use two tags with the same name (${name})`);
25
26
  }
27
+ if (group) {
28
+ if (docs[TAG_GROUP_NAME]) {
29
+ const groups = docs[TAG_GROUP_NAME];
30
+ const tagGroup = groups.find(({ name }) => name === group);
31
+ if (tagGroup) {
32
+ tagGroup.tags.push(name);
33
+ }
34
+ else {
35
+ groups.push({ name: group, tags: [name] });
36
+ }
37
+ }
38
+ else {
39
+ // @ts-expect-error Custom field
40
+ docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
41
+ }
42
+ }
26
43
  const handler = useNewHandler();
27
44
  handler[tagContext.key] = tag;
28
45
  innet(children, handler);
29
46
  };
30
47
 
31
- export { tag };
48
+ export { TAG_GROUP_NAME, tag };
@@ -8,15 +8,12 @@ require('../../../hooks/index.js');
8
8
  var useTag = require('../../../hooks/useTag/useTag.js');
9
9
  var useApi = require('../../../hooks/useApi/useApi.js');
10
10
 
11
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
12
-
13
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
14
-
11
+ const TAG_GROUP_NAME = 'x-tagGroups';
15
12
  const tag = () => {
16
13
  if (jsx.useContext(useTag.tagContext)) {
17
14
  throw Error('You cannot use a <tag> inside another one');
18
15
  }
19
- const { children, description, name, } = jsx.useProps();
16
+ const { children, description, group, name, } = jsx.useProps();
20
17
  const { docs } = useApi.useApi();
21
18
  const tag = { name };
22
19
  if (description) {
@@ -31,9 +28,26 @@ const tag = () => {
31
28
  else {
32
29
  throw Error(`You cannot use two tags with the same name (${name})`);
33
30
  }
31
+ if (group) {
32
+ if (docs[TAG_GROUP_NAME]) {
33
+ const groups = docs[TAG_GROUP_NAME];
34
+ const tagGroup = groups.find(({ name }) => name === group);
35
+ if (tagGroup) {
36
+ tagGroup.tags.push(name);
37
+ }
38
+ else {
39
+ groups.push({ name: group, tags: [name] });
40
+ }
41
+ }
42
+ else {
43
+ // @ts-expect-error Custom field
44
+ docs[TAG_GROUP_NAME] = [{ name: group, tags: [name] }];
45
+ }
46
+ }
34
47
  const handler = innet.useNewHandler();
35
48
  handler[useTag.tagContext.key] = tag;
36
- innet__default["default"](children, handler);
49
+ innet.innet(children, handler);
37
50
  };
38
51
 
52
+ exports.TAG_GROUP_NAME = TAG_GROUP_NAME;
39
53
  exports.tag = tag;
@@ -1,4 +1,4 @@
1
- import innet, { useHandler } from 'innet';
1
+ import { useHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import path from 'node:path';
4
4
  import '../file/index.es6.js';
@@ -12,7 +12,6 @@ var file = require('../file/file.js');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
14
14
 
15
- var innet__default = /*#__PURE__*/_interopDefaultLegacy(innet);
16
15
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
17
16
 
18
17
  function cms() {
@@ -23,10 +22,10 @@ function cms() {
23
22
  url = url.slice(prefix.length);
24
23
  }
25
24
  else {
26
- return innet__default["default"](children, handler);
25
+ return innet.innet(children, handler);
27
26
  }
28
27
  const filePath = path__default["default"].join(dir, url);
29
- innet__default["default"]({ children, props: { path: filePath }, type: file.file }, handler);
28
+ innet.innet({ children, props: { path: filePath }, type: file.file }, handler);
30
29
  }
31
30
 
32
31
  exports.cms = cms;
@@ -1,6 +1,7 @@
1
1
  import { useProps } from '@innet/jsx';
2
2
  import '../../../hooks/index.es6.js';
3
3
  import '../../../utils/index.es6.js';
4
+ import { useServer } from '../../../hooks/useServer/useServer.es6.js';
4
5
  import { useResponse } from '../../../hooks/useResponse/useResponse.es6.js';
5
6
  import { JSONString } from '../../../utils/JSONString/JSONString.es6.js';
6
7
 
@@ -58,14 +59,17 @@ const errorStatuses = {
58
59
  webServerIsDown: 521,
59
60
  };
60
61
  const error = () => {
61
- const { children, ...props } = useProps();
62
+ var _a;
63
+ const server = useServer();
62
64
  const res = useResponse();
63
65
  if (!res) {
64
- throw Error('<error> MUST be in <request>');
66
+ throw Error('<error> MUST be in <return>');
65
67
  }
68
+ const { children, ...props } = useProps();
66
69
  const { code = 'undefined', status = 520, } = props;
67
70
  res.statusCode = typeof status === 'string' ? errorStatuses[status] : status;
68
- const content = JSONString({ data: children, error: code });
71
+ const format = (_a = server.props.formatError) !== null && _a !== void 0 ? _a : JSONString;
72
+ const content = format({ data: children, error: code });
69
73
  res.setHeader('Content-Type', 'application/json');
70
74
  res.setHeader('Content-Length', content.length);
71
75
  res.write(content);
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var jsx = require('@innet/jsx');
6
6
  require('../../../hooks/index.js');
7
7
  require('../../../utils/index.js');
8
+ var useServer = require('../../../hooks/useServer/useServer.js');
8
9
  var useResponse = require('../../../hooks/useResponse/useResponse.js');
9
10
  var JSONString = require('../../../utils/JSONString/JSONString.js');
10
11
 
@@ -62,14 +63,17 @@ const errorStatuses = {
62
63
  webServerIsDown: 521,
63
64
  };
64
65
  const error = () => {
65
- const { children, ...props } = jsx.useProps();
66
+ var _a;
67
+ const server = useServer.useServer();
66
68
  const res = useResponse.useResponse();
67
69
  if (!res) {
68
- throw Error('<error> MUST be in <request>');
70
+ throw Error('<error> MUST be in <return>');
69
71
  }
72
+ const { children, ...props } = jsx.useProps();
70
73
  const { code = 'undefined', status = 520, } = props;
71
74
  res.statusCode = typeof status === 'string' ? errorStatuses[status] : status;
72
- const content = JSONString.JSONString({ data: children, error: code });
75
+ const format = (_a = server.props.formatError) !== null && _a !== void 0 ? _a : JSONString.JSONString;
76
+ const content = format({ data: children, error: code });
73
77
  res.setHeader('Content-Type', 'application/json');
74
78
  res.setHeader('Content-Length', content.length);
75
79
  res.write(content);
@@ -1,4 +1,4 @@
1
- import innet, { useHandler } from 'innet';
1
+ import { useHandler, innet } from 'innet';
2
2
  import { useProps } from '@innet/jsx';
3
3
  import fs from 'node:fs';
4
4
  import mime from 'mime';
@@ -11,7 +11,7 @@ function file() {
11
11
  const { children, ...props } = useProps();
12
12
  const res = useResponse();
13
13
  if (!res) {
14
- useThrow('<{type}> MUST be in <request> or <fallback>');
14
+ useThrow('<{type}> MUST be in <return> or <preset>');
15
15
  }
16
16
  const { path } = props;
17
17
  if (fs.existsSync(path)) {