@innet/server 2.0.0-alpha.9 → 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 (345) hide show
  1. package/README.md +1063 -445
  2. package/handler/handler.d.ts +23 -18
  3. package/handler/handler.es6.js +15 -14
  4. package/handler/handler.js +14 -13
  5. package/hooks/index.d.ts +6 -1
  6. package/hooks/index.es6.js +6 -1
  7. package/hooks/index.js +6 -1
  8. package/hooks/useAction/useAction.es6.js +1 -1
  9. package/hooks/useAction/useAction.js +1 -1
  10. package/hooks/useApi/useApi.d.ts +1 -3
  11. package/hooks/useClientIp/useClientIp.d.ts +1 -1
  12. package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
  13. package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
  14. package/hooks/useEndpoint/useEndpoint.js +3 -1
  15. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  16. package/hooks/useIsServerHttps/index.d.ts +1 -0
  17. package/hooks/useIsServerHttps/index.es6.js +1 -0
  18. package/hooks/useIsServerHttps/index.js +10 -0
  19. package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
  20. package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
  21. package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
  22. package/hooks/useNewSchema/useNewSchema.es6.js +2 -2
  23. package/hooks/useNewSchema/useNewSchema.js +2 -2
  24. package/hooks/useObjectSchemaContext/index.d.ts +1 -0
  25. package/hooks/useObjectSchemaContext/index.es6.js +1 -0
  26. package/hooks/useObjectSchemaContext/index.js +10 -0
  27. package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
  28. package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
  29. package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
  30. package/hooks/useRequest/index.es6.js +1 -1
  31. package/hooks/useRequest/index.js +0 -1
  32. package/hooks/useRequest/useRequest.d.ts +1 -5
  33. package/hooks/useRequest/useRequest.es6.js +4 -4
  34. package/hooks/useRequest/useRequest.js +3 -4
  35. package/hooks/useRequestHandler/index.d.ts +1 -0
  36. package/hooks/useRequestHandler/index.es6.js +1 -0
  37. package/hooks/useRequestHandler/index.js +10 -0
  38. package/hooks/useRequestHandler/useRequestHandler.d.ts +4 -0
  39. package/hooks/useRequestHandler/useRequestHandler.es6.js +14 -0
  40. package/hooks/useRequestHandler/useRequestHandler.js +19 -0
  41. package/hooks/useResponse/index.es6.js +1 -1
  42. package/hooks/useResponse/index.js +0 -1
  43. package/hooks/useResponse/useResponse.d.ts +1 -5
  44. package/hooks/useResponse/useResponse.es6.js +4 -4
  45. package/hooks/useResponse/useResponse.js +3 -4
  46. package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
  47. package/hooks/useSchemaType/useSchemaType.es6.js +16 -9
  48. package/hooks/useSchemaType/useSchemaType.js +16 -9
  49. package/hooks/useServer/useServer.d.ts +2 -3
  50. package/hooks/useServer/useServer.es6.js +3 -1
  51. package/hooks/useServer/useServer.js +3 -1
  52. package/hooks/useServerPlugin/index.d.ts +1 -0
  53. package/hooks/useServerPlugin/index.es6.js +1 -0
  54. package/hooks/useServerPlugin/index.js +9 -0
  55. package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
  56. package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
  57. package/hooks/useServerPlugin/useServerPlugin.js +17 -0
  58. package/hooks/useServerPlugins/index.d.ts +1 -0
  59. package/hooks/useServerPlugins/index.es6.js +1 -0
  60. package/hooks/useServerPlugins/index.js +10 -0
  61. package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
  62. package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
  63. package/hooks/useServerPlugins/useServerPlugins.js +19 -0
  64. package/hooks/useServerPort/index.d.ts +1 -0
  65. package/hooks/useServerPort/index.es6.js +1 -0
  66. package/hooks/useServerPort/index.js +10 -0
  67. package/hooks/useServerPort/useServerPort.d.ts +3 -0
  68. package/hooks/useServerPort/useServerPort.es6.js +14 -0
  69. package/hooks/useServerPort/useServerPort.js +19 -0
  70. package/index.es6.js +15 -9
  71. package/index.js +30 -14
  72. package/package.json +15 -16
  73. package/plugins/handler/serverFn/serverFn.es6.js +1 -1
  74. package/plugins/handler/serverFn/serverFn.js +1 -1
  75. package/plugins/main/api/api.d.ts +11 -8
  76. package/plugins/main/api/api.es6.js +112 -113
  77. package/plugins/main/api/api.js +111 -112
  78. package/plugins/main/body/body.d.ts +1 -0
  79. package/plugins/main/contact/contact.d.ts +2 -2
  80. package/plugins/main/endpoint/endpoint.d.ts +21 -15
  81. package/plugins/main/endpoint/endpoint.es6.js +11 -9
  82. package/plugins/main/endpoint/endpoint.js +10 -8
  83. package/plugins/main/host/host.d.ts +5 -5
  84. package/plugins/main/host/host.es6.js +3 -1
  85. package/plugins/main/host/host.js +3 -1
  86. package/plugins/main/index.d.ts +2 -2
  87. package/plugins/main/index.es6.js +2 -2
  88. package/plugins/main/index.js +2 -2
  89. package/plugins/main/license/license.d.ts +5 -5
  90. package/plugins/main/param/param.d.ts +12 -11
  91. package/plugins/main/param/param.es6.js +6 -7
  92. package/plugins/main/param/param.js +5 -6
  93. package/plugins/main/preset/index.d.ts +1 -0
  94. package/plugins/main/preset/index.es6.js +1 -0
  95. package/plugins/{utils/prod → main/preset}/index.js +2 -2
  96. package/plugins/main/preset/preset.d.ts +3 -0
  97. package/plugins/main/preset/preset.es6.js +13 -0
  98. package/plugins/{utils/dev/dev.js → main/preset/preset.js} +9 -6
  99. package/plugins/main/response/index.es6.js +1 -1
  100. package/plugins/main/response/index.js +1 -0
  101. package/plugins/main/response/response.d.ts +6 -1
  102. package/plugins/main/response/response.es6.js +28 -12
  103. package/plugins/main/response/response.js +27 -10
  104. package/plugins/main/return/index.d.ts +1 -0
  105. package/plugins/main/return/index.es6.js +1 -0
  106. package/plugins/main/return/index.js +9 -0
  107. package/plugins/main/return/return.d.ts +4 -0
  108. package/plugins/main/return/return.es6.js +10 -0
  109. package/plugins/main/return/return.js +14 -0
  110. package/plugins/main/server/server.d.ts +6 -6
  111. package/plugins/main/server/server.es6.js +40 -16
  112. package/plugins/main/server/server.js +39 -15
  113. package/plugins/main/tag/tag.d.ts +3 -2
  114. package/plugins/main/tag/tag.es6.js +6 -4
  115. package/plugins/main/tag/tag.js +5 -3
  116. package/plugins/main/variable/variable.d.ts +5 -5
  117. package/plugins/main/variable/variable.es6.js +4 -3
  118. package/plugins/main/variable/variable.js +4 -3
  119. package/plugins/request/cms/cms.d.ts +1 -0
  120. package/plugins/request/cms/cms.es6.js +3 -4
  121. package/plugins/request/cms/cms.js +2 -3
  122. package/plugins/request/cookie/cookie.d.ts +2 -2
  123. package/plugins/request/cookie/cookie.es6.js +1 -2
  124. package/plugins/request/cookie/cookie.js +1 -2
  125. package/plugins/request/error/error.d.ts +41 -40
  126. package/plugins/request/error/error.es6.js +47 -45
  127. package/plugins/request/error/error.js +46 -44
  128. package/plugins/request/file/file.d.ts +1 -0
  129. package/plugins/request/file/file.es6.js +4 -6
  130. package/plugins/request/file/file.js +3 -5
  131. package/plugins/request/header/header.es6.js +1 -1
  132. package/plugins/request/header/header.js +1 -1
  133. package/plugins/request/proxy/proxy.d.ts +3 -1
  134. package/plugins/request/proxy/proxy.es6.js +5 -2
  135. package/plugins/request/proxy/proxy.js +5 -2
  136. package/plugins/request/redirect/redirect.d.ts +8 -7
  137. package/plugins/request/redirect/redirect.es6.js +7 -7
  138. package/plugins/request/redirect/redirect.js +7 -7
  139. package/plugins/request/success/success.d.ts +8 -6
  140. package/plugins/request/success/success.es6.js +21 -11
  141. package/plugins/request/success/success.js +20 -10
  142. package/plugins/schema/any/any.d.ts +5 -0
  143. package/plugins/schema/any/any.es6.js +27 -0
  144. package/plugins/schema/any/any.js +31 -0
  145. package/plugins/schema/array/array.d.ts +1 -0
  146. package/plugins/schema/array/array.es6.js +2 -3
  147. package/plugins/schema/array/array.js +1 -2
  148. package/plugins/schema/binary/binary.d.ts +3 -3
  149. package/plugins/schema/date/date.d.ts +1 -1
  150. package/plugins/schema/date/date.es6.js +8 -4
  151. package/plugins/schema/date/date.js +8 -4
  152. package/plugins/schema/field/field.d.ts +2 -0
  153. package/plugins/schema/field/field.es6.js +8 -8
  154. package/plugins/schema/field/field.js +6 -6
  155. package/plugins/schema/index.d.ts +1 -0
  156. package/plugins/schema/index.es6.js +1 -0
  157. package/plugins/schema/index.js +1 -0
  158. package/plugins/schema/integer/integer.d.ts +3 -3
  159. package/plugins/schema/integer/integer.es6.js +8 -3
  160. package/plugins/schema/integer/integer.js +8 -3
  161. package/plugins/schema/number/number.d.ts +2 -2
  162. package/plugins/schema/number/number.es6.js +1 -2
  163. package/plugins/schema/number/number.js +1 -2
  164. package/plugins/schema/object/object.d.ts +1 -0
  165. package/plugins/schema/object/object.es6.js +19 -7
  166. package/plugins/schema/object/object.js +18 -6
  167. package/plugins/schema/string/string.d.ts +2 -2
  168. package/plugins/schema/string/string.es6.js +44 -31
  169. package/plugins/schema/string/string.js +44 -31
  170. package/plugins/schema/tuple/tuple.d.ts +1 -0
  171. package/plugins/schema/tuple/tuple.es6.js +4 -5
  172. package/plugins/schema/tuple/tuple.js +3 -4
  173. package/plugins/schema/uuid/uuid.es6.js +5 -3
  174. package/plugins/schema/uuid/uuid.js +5 -3
  175. package/plugins/utils/blacklist/blacklist.d.ts +5 -0
  176. package/plugins/utils/blacklist/blacklist.es6.js +17 -0
  177. package/plugins/utils/blacklist/blacklist.js +21 -0
  178. package/plugins/utils/blacklist/index.d.ts +1 -0
  179. package/plugins/utils/blacklist/index.es6.js +1 -0
  180. package/plugins/utils/blacklist/index.js +9 -0
  181. package/plugins/utils/dts/dts.d.ts +2 -1
  182. package/plugins/utils/dts/dts.es6.js +2 -2
  183. package/plugins/utils/dts/dts.js +2 -2
  184. package/plugins/utils/env/env.d.ts +7 -0
  185. package/plugins/utils/env/env.es6.js +11 -0
  186. package/plugins/utils/{prod/prod.js → env/env.js} +5 -4
  187. package/plugins/utils/env/index.d.ts +1 -0
  188. package/plugins/utils/env/index.es6.js +1 -0
  189. package/plugins/utils/{dev → env}/index.js +2 -2
  190. package/plugins/utils/index.d.ts +3 -2
  191. package/plugins/utils/index.es6.js +3 -2
  192. package/plugins/utils/index.js +3 -2
  193. package/plugins/utils/protection/protection.d.ts +4 -4
  194. package/plugins/utils/protection/protection.es6.js +13 -16
  195. package/plugins/utils/protection/protection.js +13 -16
  196. package/plugins/utils/swagger/swagger.es6.js +7 -5
  197. package/plugins/utils/swagger/swagger.js +7 -5
  198. package/plugins/utils/whitelist/index.d.ts +1 -0
  199. package/plugins/utils/whitelist/index.es6.js +1 -0
  200. package/plugins/utils/whitelist/index.js +9 -0
  201. package/plugins/utils/whitelist/whitelist.d.ts +5 -0
  202. package/plugins/utils/whitelist/whitelist.es6.js +19 -0
  203. package/plugins/utils/whitelist/whitelist.js +23 -0
  204. package/types.d.ts +15 -22
  205. package/utils/FileData/Bin.d.ts +13 -13
  206. package/utils/FileData/Bin.es6.js +2 -2
  207. package/utils/FileData/Bin.js +2 -2
  208. package/utils/action/Action.d.ts +13 -14
  209. package/utils/action/Action.es6.js +92 -92
  210. package/utils/action/Action.js +91 -91
  211. package/utils/dateFormat/dateFormat.d.ts +1 -1
  212. package/utils/dateFormat/dateFormat.es6.js +1 -1
  213. package/utils/dateFormat/dateFormat.js +1 -1
  214. package/utils/decorators/once/once.es6.js +1 -1
  215. package/utils/decorators/once/once.js +1 -1
  216. package/utils/generateTypes/generateTypes.d.ts +2 -2
  217. package/utils/generateTypes/generateTypes.es6.js +85 -25
  218. package/utils/generateTypes/generateTypes.js +85 -25
  219. package/utils/getEndpoint/getEndpoint.es6.js +2 -2
  220. package/utils/getEndpoint/getEndpoint.js +2 -2
  221. package/utils/getOrAdd/getOrAdd.d.ts +1 -1
  222. package/utils/httpOnStart/httpOnStart.d.ts +1 -1
  223. package/utils/httpOnStart/httpOnStart.es6.js +1 -1
  224. package/utils/httpOnStart/httpOnStart.js +1 -1
  225. package/utils/parseBody/parseBody.d.ts +0 -1
  226. package/utils/parseBody/parseBody.es6.js +13 -16
  227. package/utils/parseBody/parseBody.js +13 -16
  228. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  229. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  230. package/utils/parseFormBody/parseFormBody.js +41 -41
  231. package/utils/parseSearch/parseSearch.es6.js +4 -1
  232. package/utils/parseSearch/parseSearch.js +4 -1
  233. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  234. package/utils/rules/arrayOf/arrayOf.js +1 -1
  235. package/utils/rules/bin/bin.es6.js +4 -1
  236. package/utils/rules/bin/bin.js +4 -1
  237. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  238. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  239. package/utils/rules/dateTo/dateTo.d.ts +1 -1
  240. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  241. package/utils/rules/dateTo/dateTo.js +4 -1
  242. package/utils/rules/helpers.d.ts +1 -1
  243. package/utils/rules/helpers.es6.js +4 -1
  244. package/utils/rules/helpers.js +4 -1
  245. package/utils/rules/index.d.ts +0 -1
  246. package/utils/rules/index.es6.js +0 -1
  247. package/utils/rules/index.js +0 -1
  248. package/utils/rules/int/int.es6.js +17 -4
  249. package/utils/rules/int/int.js +17 -4
  250. package/utils/rules/max/max.d.ts +1 -1
  251. package/utils/rules/max/max.es6.js +10 -4
  252. package/utils/rules/max/max.js +10 -4
  253. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  254. package/utils/rules/maxBin/maxBin.js +5 -2
  255. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  256. package/utils/rules/maxDate/maxDate.js +5 -1
  257. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  258. package/utils/rules/maxLength/maxLength.js +5 -2
  259. package/utils/rules/min/min.d.ts +1 -1
  260. package/utils/rules/min/min.es6.js +10 -4
  261. package/utils/rules/min/min.js +10 -4
  262. package/utils/rules/minBin/minBin.es6.js +5 -2
  263. package/utils/rules/minBin/minBin.js +5 -2
  264. package/utils/rules/minDate/minDate.es6.js +5 -1
  265. package/utils/rules/minDate/minDate.js +5 -1
  266. package/utils/rules/minLength/minLength.es6.js +5 -2
  267. package/utils/rules/minLength/minLength.js +5 -2
  268. package/utils/rules/num/num.es6.js +4 -1
  269. package/utils/rules/num/num.js +4 -1
  270. package/utils/rules/objectOf/objectOf.d.ts +1 -1
  271. package/utils/rules/objectOf/objectOf.es6.js +16 -3
  272. package/utils/rules/objectOf/objectOf.js +16 -3
  273. package/utils/rules/pattern/pattern.d.ts +1 -1
  274. package/utils/rules/pattern/pattern.es6.js +6 -1
  275. package/utils/rules/pattern/pattern.js +6 -1
  276. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  277. package/utils/rules/tupleOf/tupleOf.js +1 -1
  278. package/utils/rules/values/values.es6.js +5 -2
  279. package/utils/rules/values/values.js +5 -2
  280. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  281. package/utils/stringifySearch/stringifySearch.js +4 -1
  282. package/example/app/App/App.d.ts +0 -1
  283. package/example/app/App/index.d.ts +0 -1
  284. package/example/index.d.ts +0 -1
  285. package/example/requests/index.d.ts +0 -1
  286. package/example/requests/todo/AddTodo/AddTodo.d.ts +0 -1
  287. package/example/requests/todo/AddTodo/index.d.ts +0 -1
  288. package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +0 -1
  289. package/example/requests/todo/DeleteTodo/index.d.ts +0 -1
  290. package/example/requests/todo/EditTodo/EditTodo.d.ts +0 -1
  291. package/example/requests/todo/EditTodo/index.d.ts +0 -1
  292. package/example/requests/todo/GetTodo/GetTodo.d.ts +0 -1
  293. package/example/requests/todo/GetTodo/index.d.ts +0 -1
  294. package/example/requests/todo/GetTodos/GetTodos.d.ts +0 -1
  295. package/example/requests/todo/GetTodos/index.d.ts +0 -1
  296. package/example/requests/todo/index.d.ts +0 -5
  297. package/example/requests/todo/todos.d.ts +0 -1
  298. package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +0 -1
  299. package/example/schemas/app/ListQueryParams/index.d.ts +0 -1
  300. package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -4
  301. package/example/schemas/app/ListSchema/index.d.ts +0 -1
  302. package/example/schemas/app/index.d.ts +0 -2
  303. package/example/schemas/index.d.ts +0 -2
  304. package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +0 -4
  305. package/example/schemas/todo/TodoSchema/index.d.ts +0 -1
  306. package/example/schemas/todo/index.d.ts +0 -1
  307. package/example/tags/Todo/Todo.d.ts +0 -1
  308. package/example/tags/Todo/index.d.ts +0 -1
  309. package/example/tags/index.d.ts +0 -1
  310. package/hooks/useRequestPlugin/index.d.ts +0 -1
  311. package/hooks/useRequestPlugin/index.es6.js +0 -1
  312. package/hooks/useRequestPlugin/index.js +0 -9
  313. package/hooks/useRequestPlugin/useRequestPlugin.d.ts +0 -2
  314. package/hooks/useRequestPlugin/useRequestPlugin.es6.js +0 -13
  315. package/hooks/useRequestPlugin/useRequestPlugin.js +0 -17
  316. package/openApi.test.d.ts +0 -1
  317. package/plugins/main/fallback/fallback.d.ts +0 -4
  318. package/plugins/main/fallback/fallback.es6.js +0 -19
  319. package/plugins/main/fallback/fallback.js +0 -23
  320. package/plugins/main/fallback/index.d.ts +0 -1
  321. package/plugins/main/fallback/index.es6.js +0 -1
  322. package/plugins/main/fallback/index.js +0 -9
  323. package/plugins/main/request/index.d.ts +0 -1
  324. package/plugins/main/request/index.es6.js +0 -1
  325. package/plugins/main/request/index.js +0 -9
  326. package/plugins/main/request/request.d.ts +0 -4
  327. package/plugins/main/request/request.es6.js +0 -21
  328. package/plugins/main/request/request.js +0 -25
  329. package/plugins/utils/dev/dev.d.ts +0 -4
  330. package/plugins/utils/dev/dev.es6.js +0 -10
  331. package/plugins/utils/dev/index.d.ts +0 -1
  332. package/plugins/utils/dev/index.es6.js +0 -1
  333. package/plugins/utils/prod/index.d.ts +0 -1
  334. package/plugins/utils/prod/index.es6.js +0 -1
  335. package/plugins/utils/prod/prod.d.ts +0 -4
  336. package/plugins/utils/prod/prod.es6.js +0 -10
  337. package/utils/decorators/once/once.test.d.ts +0 -1
  338. package/utils/generateTypes/generateTypes.test.d.ts +0 -1
  339. package/utils/parseSearch/parseSearch.test.d.ts +0 -1
  340. package/utils/rules/any/any.d.ts +0 -1
  341. package/utils/rules/any/any.es6.js +0 -5
  342. package/utils/rules/any/any.js +0 -9
  343. /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
  344. /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
  345. /package/{utils/rules → plugins/schema}/any/index.js +0 -0
package/README.md CHANGED
@@ -46,7 +46,7 @@ Customize
46
46
 
47
47
  [← back](#index)
48
48
 
49
- The simplest way to start working with `@innet/server`, it is `innetjs` usage.
49
+ The simplest way to start working with `@innet/server`, it is [innetjs](https://www.npmjs.com/package/innetjs) usage.
50
50
 
51
51
  ```shell
52
52
  npx innetjs init my-app -t api
@@ -77,6 +77,28 @@ innet(app, server)
77
77
 
78
78
  Here is a **Hello World** example:
79
79
 
80
+ *src/app.tsx*
81
+ ```typescript jsx
82
+ export default (
83
+ <server>
84
+ <return>
85
+ <success>
86
+ Hello World!
87
+ </success>
88
+ </return>
89
+ </server>
90
+ )
91
+ ```
92
+
93
+ *Use `npm start` to run this server.*
94
+
95
+ Open http://localhost
96
+ You will see the `Hello Word!` string.
97
+
98
+ ---
99
+
100
+ Here is the simplest [api](#api) example:
101
+
80
102
  *src/app.tsx*
81
103
  ```typescript jsx
82
104
  export default (
@@ -88,7 +110,7 @@ export default (
88
110
 
89
111
  *Use `npm start` to run this server.*
90
112
 
91
- Open http://localhost:80
113
+ Open http://localhost
92
114
  You will see a base Open API JSON structure.
93
115
 
94
116
  ```json
@@ -107,7 +129,9 @@ You will see a base Open API JSON structure.
107
129
  [← back](#index)
108
130
 
109
131
  [\<server>](#server)
110
- [\<api>](#api)
132
+ [\<api>](#api)
133
+ [\<return>](#return)
134
+ [\<preset>](#preset)
111
135
 
112
136
  ---
113
137
 
@@ -135,9 +159,9 @@ export default (
135
159
  )
136
160
  ```
137
161
 
138
- - By default, it uses port `80` for `http` and port `442` for `https`.
139
- - You can use `PORT` environment variable to set it up on CI level.
140
- - [innetjs](https://www.npmjs.com/package/innetjs) allows you to use `PORT` in `.env` file of local environment.
162
+ - By default, it uses port `80` for `http` and port `443` for `https`.
163
+ - You can use `INNET_PORT` environment variable to set it up on CI level.
164
+ - [innetjs](https://www.npmjs.com/package/innetjs) allows you to use `INNET_PORT` in `.env` file of local environment.
141
165
 
142
166
  #### ssl
143
167
 
@@ -155,8 +179,8 @@ export default (
155
179
  )
156
180
  ```
157
181
 
158
- - You can use `SSL_KEY` and `SSL_CRT` environment variables to set it up on CI level.
159
- - [innetjs](https://www.npmjs.com/package/innetjs) allows you to use `SSL_KEY` and `SSL_CRT` in `.env` file.
182
+ - You can use `INNET_SSL_KEY` and `INNET_SSL_CRT` environment variables to set it up on CI level.
183
+ - [innetjs](https://www.npmjs.com/package/innetjs) allows you to use `INNET_SSL_KEY` and `INNET_SSL_CRT` in `.env` file.
160
184
  - You can add `localhost.key` and `localhost.crt` files in your project folder.
161
185
 
162
186
  #### onStart
@@ -206,12 +230,25 @@ export default (
206
230
  )
207
231
  ```
208
232
 
233
+ #### onClose
234
+
235
+ Use `onClose` to handle server close action.
236
+
237
+ *src/app.tsx*
238
+ ```typescript jsx
239
+ export default (
240
+ <server
241
+ onClose={() => console.log('Close')}
242
+ />
243
+ )
244
+ ```
245
+
209
246
  ### \<api>
210
247
 
211
248
  [← back](#main)
212
249
 
213
- `<api>` element MUST be placed in `<server>` element.
214
250
  This element defines a REST API on the server.
251
+ This element MUST be placed in [\<server>](#server) element.
215
252
 
216
253
  #### title
217
254
 
@@ -292,7 +329,7 @@ export default (
292
329
  )
293
330
  ```
294
331
 
295
- *default: 0.0.0*
332
+ *default: `INNET_API_VERSION` || `'0.0.0'`*
296
333
 
297
334
  #### prefix
298
335
 
@@ -308,6 +345,235 @@ export default (
308
345
  </server>
309
346
  )
310
347
  ```
348
+ *default: `INNET_API_PREFIX` || `''`*
349
+
350
+ #### include
351
+
352
+ A regular expression scopes the API.
353
+
354
+ *src/app.tsx*
355
+ ```typescript jsx
356
+ export default (
357
+ <server>
358
+ <api
359
+ include={/^\/(api|openapi)/}
360
+ />
361
+ </server>
362
+ )
363
+ ```
364
+
365
+ #### exclude
366
+
367
+ A regular expression does not scope the API.
368
+
369
+ *src/app.tsx*
370
+ ```typescript jsx
371
+ export default (
372
+ <server>
373
+ <api prefix='/api' />
374
+ <api prefix='/openapi' />
375
+ <api exclude={/^\/(api|openapi)/} />
376
+ </server>
377
+ )
378
+ ```
379
+
380
+ ### \<return>
381
+
382
+ [← back](#main)
383
+
384
+ This element MUST be placed in [\<server>](#server) element.
385
+ It defines a run-time call handler for parent element.
386
+
387
+ *src/app.tsx*
388
+ ```typescript jsx
389
+ export default (
390
+ <server>
391
+ <return>
392
+ <error status={404} />
393
+ </return>
394
+ </server>
395
+ )
396
+ ```
397
+ *Any request returns 404*
398
+
399
+ The code runs from top to bottom and from left to right.
400
+ You cannot use two [\<return>](#return) elements one by one,
401
+ the same as you cannot use two `return` one by one for a JS `function`.
402
+
403
+ *src/app.tsx*
404
+ ```typescript jsx
405
+ export default (
406
+ <server>
407
+ <return>
408
+ <error status={404} />
409
+ </return>
410
+ <return>
411
+ <success />
412
+ </return>
413
+ </server>
414
+ )
415
+ ```
416
+
417
+ like
418
+
419
+ ```javascript
420
+ function server () {
421
+ return 'error'
422
+ return 'success'
423
+ }
424
+ ```
425
+
426
+ *The second [\<return>](#return) will newer run.*
427
+
428
+ You can use [\<return>](#return) in some elements like you use `return` in `if` or `while`.
429
+
430
+ *src/app.tsx*
431
+ ```typescript jsx
432
+ export default (
433
+ <server>
434
+ <env is='dev'>
435
+ <return>
436
+ <error status={404} />
437
+ </return>
438
+ </env>
439
+ <return>
440
+ <success />
441
+ </return>
442
+ </server>
443
+ )
444
+ ```
445
+
446
+ like
447
+
448
+ ```javascript
449
+ function server () {
450
+ if (process.env.NODE_ENV === 'dev') {
451
+ return 'error'
452
+ }
453
+
454
+ return 'success'
455
+ }
456
+ ```
457
+
458
+ Place [\<return>](#return) in [\<api>](#api) to handle any unknown request in the [\<api>](#api).
459
+
460
+ *src/app.tsx*
461
+ ```typescript jsx
462
+ export default (
463
+ <server>
464
+ <api>
465
+ <return>
466
+ <error status={404} />
467
+ </return>
468
+ </api>
469
+ </server>
470
+ )
471
+ ```
472
+
473
+ Place [\<return>](#return) in [\<endpoint>](#endpoint) to handle the [\<endpoint>](#endpoint) request.
474
+
475
+ *src/app.tsx*
476
+ ```typescript jsx
477
+ export default (
478
+ <server>
479
+ <api>
480
+ <endpoint method='get' path='/my-endpoint'>
481
+ <return>
482
+ <success>
483
+ My Endpoint
484
+ </success>
485
+ </return>
486
+ </endpoint>
487
+ </api>
488
+ <return>
489
+ <success>
490
+ Any other request
491
+ </success>
492
+ </return>
493
+ </server>
494
+ )
495
+ ```
496
+
497
+ You can place a component inside [\<return>](#return).
498
+ The component will run when the request will be triggered.
499
+
500
+ *src/app.tsx*
501
+ ```typescript jsx
502
+ import { GetPartners } from './GetPartners'
503
+
504
+ export default (
505
+ <server>
506
+ <api>
507
+ <endpoint method='get' path='/partners'>
508
+ <return>
509
+ <GetPartners />
510
+ </return>
511
+ </endpoint>
512
+ </api>
513
+ </server>
514
+ )
515
+ ```
516
+
517
+ *src/GetPartners.tsx*
518
+ ```typescript jsx
519
+ export const GetPartners = () => (
520
+ <success>
521
+ {{partners: []}}
522
+ </success>
523
+ )
524
+ ```
525
+
526
+ ### \<preset>
527
+
528
+ [← back](#main)
529
+
530
+ `<preset>` element MUST be placed in `<server>` element.
531
+ This element adds handling of each request.
532
+ It works the same as [\<return>](#return), but do not interrupt the running.
533
+ You can use it to add a `header` or `cookie` or some setup of a parent element.
534
+
535
+ *src/app.tsx*
536
+ ```typescript jsx
537
+ export default (
538
+ <server>
539
+ <preset>
540
+ <header
541
+ key='Test'
542
+ value='Ok'
543
+ />
544
+ </preset>
545
+ </server>
546
+ )
547
+ ```
548
+
549
+ Place the element inside [\<api>](#api) to preset it on the api requests scope.
550
+
551
+ *src/app.tsx*
552
+ ```typescript jsx
553
+ export default (
554
+ <server>
555
+ <api prefix='/api'>
556
+ <preset>
557
+ <header
558
+ key='Cache-Control'
559
+ value='no-cache, no-store, must-revalidate'
560
+ />
561
+ </preset>
562
+ ...Endpoints
563
+ <return>
564
+ <success>
565
+ Header contains `Cache-Control`
566
+ </success>
567
+ </return>
568
+ </api>
569
+ <return>
570
+ <success>
571
+ Header do not contain `Cache-Control`
572
+ </success>
573
+ </return>
574
+ </server>
575
+ )
576
+ ```
311
577
 
312
578
  ## Utils
313
579
 
@@ -316,9 +582,10 @@ This section contains elements of utils.
316
582
  [← back](#index)
317
583
 
318
584
  [\<swagger>](#swagger)
319
- [\<dev>](#dev)
320
- [\<prod>](#prod)
321
- [\<dts>](#dts)
585
+ [\<env>](#env)
586
+ [\<dts>](#dts)
587
+ [\<blacklist>](#blacklist)
588
+ [\<whitelist>](#whitelist)
322
589
  [\<protection>](#protection)
323
590
 
324
591
  ---
@@ -357,39 +624,48 @@ export default (
357
624
  )
358
625
  ```
359
626
 
360
- ### \<dev>
627
+ ### \<env>
361
628
 
362
629
  [← back](#utils)
363
630
 
364
- Everything inside <dev> will work when `NODE_ENV` equals `development`.
631
+ This element helps to control content by `process.env`.
632
+
633
+ There are a required field of `is`.
634
+ If it's a `string` then an environment variable must be equal to the `string`.
635
+ If it's an `array of string` then an environment variable must be included into the `array of string`.
365
636
 
366
637
  *src/app.tsx*
367
638
  ```typescript jsx
368
639
  export default (
369
640
  <server>
370
641
  <api>
371
- <dev>
642
+ <env is='dev'>
372
643
  <swagger />
373
- </dev>
644
+ </env>
374
645
  </api>
375
646
  </server>
376
647
  )
377
648
  ```
378
649
 
379
- ### \<prod>
650
+ *The `<swagger />` will work only if `NODE_ENV` equals `dev`*
380
651
 
381
- [← back](#utils)
652
+ #### of
382
653
 
383
- Everything inside <prod> will work when `NODE_ENV` equals `production`.
654
+ By default `of` equals `NODE_ENV`. You can check eny other environment variable.
384
655
 
385
656
  *src/app.tsx*
386
657
  ```typescript jsx
387
658
  export default (
388
659
  <server>
389
660
  <api>
390
- <prod>
661
+ <env
662
+ of='PORT'
663
+ is={[
664
+ '3000',
665
+ '8080',
666
+ ]}>
391
667
  <swagger />
392
- </prod>
668
+ </env>
393
669
  </api>
394
670
  </server>
395
671
  )
@@ -402,16 +678,12 @@ export default (
402
678
  Use `<dts>` element to add types generation.
403
679
  `<dts>` element MUST be placed in `<api>` element.
404
680
 
405
- `<dts>` has a required prop of `path`. This is a path of api TypeScript types file, `<dts>` generates it.
406
-
407
681
  *src/app.tsx*
408
682
  ```typescript jsx
409
683
  export default (
410
684
  <server>
411
685
  <api>
412
- <dev>
413
- <dts path='src/api.d.ts' />
414
- </dev>
686
+ <dts />
415
687
  </api>
416
688
  </server>
417
689
  )
@@ -440,29 +712,141 @@ export function DeleteTodo () {
440
712
  }
441
713
  ```
442
714
 
715
+ #### path
716
+
717
+ This is a path of api TypeScript types file, `<dts>` generates it.
718
+ `'src/api.d.ts'` by default.
719
+
720
+ *src/app.tsx*
721
+ ```typescript jsx
722
+ export default (
723
+ <server>
724
+ <api>
725
+ <dts path='src/types.d.ts' />
726
+ </api>
727
+ </server>
728
+ )
729
+ ```
730
+
731
+ #### namespace
732
+
733
+ This prop changes namespace for generated types. `'Api'` by default.
734
+
735
+ *src/app.tsx*
736
+ ```typescript jsx
737
+ export default (
738
+ <server>
739
+ <api>
740
+ <dts namespace='API' />
741
+ </api>
742
+ </server>
743
+ )
744
+ ```
745
+
746
+ ### \<blacklist>
747
+
748
+ This element MUST be placed in `<api>` element.
749
+
750
+ [← back](#utils)
751
+
752
+ This element returns own content for a user from IPs list.
753
+
754
+ *src/app.tsx*
755
+ ```typescript jsx
756
+ export default (
757
+ <server>
758
+ <api>
759
+ <blacklist>
760
+ <error />
761
+ </blacklist>
762
+ </api>
763
+ </server>
764
+ )
765
+ ```
766
+
767
+ #### ip
768
+
769
+ `ip` prop sets black IPs. By default, it equals `INNET_BLACKLIST_IP` node environment variable.
770
+
771
+ You can split IPs by `,` char.
772
+
773
+ *src/app.tsx*
774
+ ```typescript jsx
775
+ export default (
776
+ <server>
777
+ <api>
778
+ <blacklist
779
+ ip='0.1.2.3,3.2.1.0'>
780
+ <error />
781
+ </blacklist>
782
+ </api>
783
+ </server>
784
+ )
785
+ ```
786
+
787
+ ### \<whitelist>
788
+
789
+ This element MUST be placed in `<api>` element.
790
+
791
+ [← back](#utils)
792
+
793
+ This element returns own content for a user IP, which is not in a list.
794
+
795
+ *src/app.tsx*
796
+ ```typescript jsx
797
+ export default (
798
+ <server>
799
+ <api>
800
+ <whitelist>
801
+ <error />
802
+ </whitelist>
803
+ </api>
804
+ </server>
805
+ )
806
+ ```
807
+
808
+ #### ip
809
+
810
+ `ip` prop sets white IPs. By default, it equals `INNET_WHITELIST_IP` node environment variable.
811
+
812
+ You can split IPs by `,` char.
813
+
814
+ *src/app.tsx*
815
+ ```typescript jsx
816
+ export default (
817
+ <server>
818
+ <api>
819
+ <whitelist
820
+ ip='0.1.2.3,3.2.1.0'>
821
+ <error />
822
+ </whitelist>
823
+ </api>
824
+ </server>
825
+ )
826
+ ```
827
+
443
828
  ### \<protection>
444
829
 
830
+ This element MUST be placed in `<api>` element.
831
+
445
832
  [← back](#utils)
446
833
 
447
834
  This element adds protection page.
448
835
  You can use it when you want to protect your application.
449
- This element MUST be placed in `<api>` element.
450
-
451
- #### html
452
836
 
453
- `<protection>` has a required prop of `html`.
454
- This is a `string` of HTML a user will see if they have no protection.
837
+ If protection failed content of the element should be used.
455
838
 
456
839
  *src/app.tsx*
457
840
  ```typescript jsx
458
- import html from './protection.html'
459
-
460
841
  export default (
461
842
  <server>
462
843
  <api>
463
- <protection
464
- html={html}
465
- />
844
+ <protection>
845
+ <error
846
+ code='protection'
847
+ status='forbidden'
848
+ />
849
+ </protection>
466
850
  </api>
467
851
  </server>
468
852
  )
@@ -478,15 +862,15 @@ You can use `PROTECTION` env to set default protection `value`.
478
862
 
479
863
  *src/app.tsx*
480
864
  ```typescript jsx
481
- import html from './protection.html'
482
-
483
865
  export default (
484
866
  <server>
485
867
  <api>
486
- <protection
487
- value='secret'
488
- html={html}
489
- />
868
+ <protection value='secret'>
869
+ <error
870
+ code='protection'
871
+ status='forbidden'
872
+ />
873
+ </protection>
490
874
  </api>
491
875
  </server>
492
876
  )
@@ -497,19 +881,21 @@ export default (
497
881
  This prop sets how much time protection is qualified.
498
882
 
499
883
  By default, the prop equals a year.
500
- You can use `PROTECTION_MAX_AGE` env to set default `maxAge`.
884
+ You can use `INNET_PROTECTION_MAX_AGE` env to set default `maxAge`.
501
885
 
502
886
  *src/app.tsx*
503
887
  ```typescript jsx
504
- import html from './protection.html'
505
-
506
888
  export default (
507
889
  <server>
508
890
  <api>
509
891
  <protection
510
892
  maxAge={24 * 60 * 60}
511
- html={html}
512
- />
893
+ value='secret'>
894
+ <error
895
+ code='protection'
896
+ status='forbidden'
897
+ />
898
+ </protection>
513
899
  </api>
514
900
  </server>
515
901
  )
@@ -519,19 +905,21 @@ export default (
519
905
 
520
906
  This prop sets a list of IP addresses (split by `,`) to ignore the protection.
521
907
 
522
- You can use `PROTECTED_IP` env to set default `excludeIp`.
908
+ You can use `INNET_PROTECTED_IP` env to set default `excludeIp`.
523
909
 
524
910
  *src/app.tsx*
525
911
  ```typescript jsx
526
- import html from './protection.html'
527
-
528
912
  export default (
529
913
  <server>
530
914
  <api>
531
915
  <protection
532
916
  excludeIp='0.0.0.0,127.0.0.0'
533
- html={html}
534
- />
917
+ value='secret'>
918
+ <error
919
+ code='protection'
920
+ status='forbidden'
921
+ />
922
+ </protection>
535
923
  </api>
536
924
  </server>
537
925
  )
@@ -542,19 +930,21 @@ export default (
542
930
  This prop sets a cookie field name used to store protection of a user.
543
931
 
544
932
  By default, it equals `protection`.
545
- You can use `PROTECTION_COOKIE_KEY` env to set default `cookieKey`.
933
+ You can use `INNET_PROTECTION_COOKIE_KEY` env to set default `cookieKey`.
546
934
 
547
935
  *src/app.tsx*
548
936
  ```typescript jsx
549
- import html from './protection.html'
550
-
551
937
  export default (
552
938
  <server>
553
939
  <api>
554
940
  <protection
555
941
  cookieKey='secret'
556
- html={html}
557
- />
942
+ value='secret'>
943
+ <error
944
+ code='protection'
945
+ status='forbidden'
946
+ />
947
+ </protection>
558
948
  </api>
559
949
  </server>
560
950
  )
@@ -565,19 +955,21 @@ export default (
565
955
  This prop sets a search query field name used to check protection.
566
956
 
567
957
  By default, it equals `protection`.
568
- You can use `PROTECTION_SEARCH_KEY` env to set default `searchKey`.
958
+ You can use `INNET_PROTECTION_SEARCH_KEY` env to set default `searchKey`.
569
959
 
570
960
  *src/app.tsx*
571
961
  ```typescript jsx
572
- import html from './protection.html'
573
-
574
962
  export default (
575
963
  <server>
576
964
  <api>
577
965
  <protection
578
966
  searchKey='secret'
579
- html={html}
580
- />
967
+ value='secret'>
968
+ <error
969
+ code='protection'
970
+ status='forbidden'
971
+ />
972
+ </protection>
581
973
  </api>
582
974
  </server>
583
975
  )
@@ -1004,6 +1396,28 @@ export default (
1004
1396
  )
1005
1397
  ```
1006
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
+
1007
1421
  ### \<tag>
1008
1422
 
1009
1423
  [← back](#endpoints)
@@ -1151,6 +1565,7 @@ This element MUST be placed inside `<endpoint>`.
1151
1565
  It defines request body for the endpoint.
1152
1566
  `@innet/server` formats and validate the value automatically (real-time).
1153
1567
 
1568
+ *src/app.tsx*
1154
1569
  ```typescript jsx
1155
1570
  return (
1156
1571
  <server>
@@ -1177,25 +1592,283 @@ return (
1177
1592
  )
1178
1593
  ```
1179
1594
 
1180
- ### \<response>
1181
-
1182
- [← back](#endpoints)
1183
-
1184
- This element MUST be placed inside `<endpoint>`.
1185
- It defines response body for the endpoint.
1186
-
1187
- ## Primitive Data
1595
+ ### \<response>
1596
+
1597
+ [← back](#endpoints)
1598
+
1599
+ This element MUST be placed inside `<endpoint>`.
1600
+ It defines response body for the endpoint.
1601
+
1602
+ *src/app.tsx*
1603
+ ```typescript jsx
1604
+ return (
1605
+ <server>
1606
+ <api>
1607
+ <endpoint method='get' path='/settings'>
1608
+ <response>
1609
+ <object />
1610
+ </response>
1611
+ </endpoint>
1612
+ </api>
1613
+ </server>
1614
+ )
1615
+ ```
1616
+
1617
+ #### status
1618
+ A status of the `<response>`.
1619
+ Any [HTTP status code](https://swagger.io/specification/#http-codes) can be used as a number of the property.
1620
+
1621
+ By default, `status` equals `'default'`.
1622
+
1623
+ *src/app.tsx*
1624
+ ```typescript jsx
1625
+ return (
1626
+ <server>
1627
+ <api>
1628
+ <endpoint method='get' path='/settings'>
1629
+ <response status={200}>
1630
+ <object />
1631
+ </response>
1632
+ </endpoint>
1633
+ </api>
1634
+ </server>
1635
+ )
1636
+ ```
1637
+
1638
+ To define a range of response codes, this field MAY contain the uppercase wildcard character `X`.
1639
+ For example, `2XX` represents all response codes between \[200-299].
1640
+ Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX` and `5XX`.
1641
+
1642
+ *src/app.tsx*
1643
+ ```typescript jsx
1644
+ return (
1645
+ <server>
1646
+ <api>
1647
+ <endpoint method='get' path='/settings'>
1648
+ <response status='2XX'>
1649
+ <object />
1650
+ </response>
1651
+ </endpoint>
1652
+ </api>
1653
+ </server>
1654
+ )
1655
+ ```
1656
+
1657
+ Many number statuses have a string id you can use on the property.
1658
+
1659
+ *src/app.tsx*
1660
+ ```typescript jsx
1661
+ return (
1662
+ <server>
1663
+ <api>
1664
+ <endpoint method='get' path='/settings'>
1665
+ <response status='notFound'>
1666
+ <object />
1667
+ </response>
1668
+ </endpoint>
1669
+ </api>
1670
+ </server>
1671
+ )
1672
+ ```
1673
+
1674
+ You can use many `<response>` elements in an endpoint.
1675
+
1676
+ *src/app.tsx*
1677
+ ```typescript jsx
1678
+ return (
1679
+ <server>
1680
+ <api>
1681
+ <endpoint method='get' path='/settings'>
1682
+ <response status='2XX'>
1683
+ <object />
1684
+ </response>
1685
+ <response status='4XX'>
1686
+ <object>
1687
+ <field key='error'>
1688
+ <string />
1689
+ </field>
1690
+ <field optional key='data'>
1691
+ <object />
1692
+ </field>
1693
+ </object>
1694
+ </response>
1695
+ </endpoint>
1696
+ </api>
1697
+ </server>
1698
+ )
1699
+ ```
1700
+
1701
+ #### type
1702
+ A media type of the `<response>`.
1703
+
1704
+ By default, `type` equals `'application/json'`.
1705
+
1706
+ *src/app.tsx*
1707
+ ```typescript jsx
1708
+ return (
1709
+ <server>
1710
+ <api>
1711
+ <endpoint method='get' path='/hello'>
1712
+ <response type='text/html'>
1713
+ Hello World!
1714
+ </response>
1715
+ </endpoint>
1716
+ </api>
1717
+ </server>
1718
+ )
1719
+ ```
1720
+
1721
+ ## Primitive Data
1722
+
1723
+ [← back](#index)
1724
+
1725
+ [\<any>](#any)
1726
+ [\<null>](#null)
1727
+ [\<boolean>](#boolean)
1728
+ [\<string>](#string)
1729
+ [\<number>](#number)
1730
+ [\<integer>](#integer)
1731
+ [\<date>](#date)
1732
+ [\<uuid>](#uuid)
1733
+ [\<binary>](#binary)
1734
+
1735
+ ---
1736
+
1737
+ ### \<any>
1738
+
1739
+ [← back](#primitive-data)
1740
+
1741
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1742
+ It defines `any` value for a parent element.
1743
+ `@innet/server` formats and validate the value automatically (real-time).
1744
+
1745
+ *src/app.tsx*
1746
+ ```typescript jsx
1747
+ export default (
1748
+ <server>
1749
+ <api>
1750
+ <endpoint method='get' path='/todos'>
1751
+ <param
1752
+ in='query'
1753
+ name='search'>
1754
+ <any />
1755
+ </param>
1756
+ </endpoint>
1757
+ </api>
1758
+ </server>
1759
+ )
1760
+ ```
1761
+
1762
+ #### default
1763
+
1764
+ A default value for the `any`.
1765
+
1766
+ *src/app.tsx*
1767
+ ```typescript jsx
1768
+ export default (
1769
+ <server>
1770
+ <api>
1771
+ <endpoint method='get' path='/users'>
1772
+ <param
1773
+ in='query'
1774
+ name='search'>
1775
+ <any default={null} />
1776
+ </param>
1777
+ </endpoint>
1778
+ </api>
1779
+ </server>
1780
+ )
1781
+ ```
1782
+
1783
+ #### example
1784
+
1785
+ An example value.
1786
+
1787
+ *src/app.tsx*
1788
+ ```typescript jsx
1789
+ export default (
1790
+ <server>
1791
+ <api>
1792
+ <endpoint method='get' path='/products'>
1793
+ <param
1794
+ in='query'
1795
+ name='active'>
1796
+ <any example={false} />
1797
+ </param>
1798
+ </endpoint>
1799
+ </api>
1800
+ </server>
1801
+ )
1802
+ ```
1803
+
1804
+ #### description
1805
+
1806
+ A description of the `any`.
1807
+
1808
+ *src/app.tsx*
1809
+ ```typescript jsx
1810
+ export default (
1811
+ <server>
1812
+ <api>
1813
+ <endpoint method='get' path='/products'>
1814
+ <param
1815
+ in='query'
1816
+ name='active'>
1817
+ <any
1818
+ description='Active products param'
1819
+ />
1820
+ </param>
1821
+ </endpoint>
1822
+ </api>
1823
+ </server>
1824
+ )
1825
+ ```
1826
+
1827
+ ### \<null>
1828
+
1829
+ [← back](#primitive-data)
1830
+
1831
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1832
+ It defines `null` value for a parent element.
1833
+ `@innet/server` formats and validate the value automatically (real-time).
1834
+
1835
+ *src/app.tsx*
1836
+ ```typescript jsx
1837
+ export default (
1838
+ <server>
1839
+ <api>
1840
+ <endpoint method='get' path='/todos'>
1841
+ <param
1842
+ in='query'
1843
+ name='search'>
1844
+ <null />
1845
+ </param>
1846
+ </endpoint>
1847
+ </api>
1848
+ </server>
1849
+ )
1850
+ ```
1851
+
1852
+ #### description
1188
1853
 
1189
- [← back](#index)
1854
+ A description of the `null`.
1190
1855
 
1191
- [\<null>](#null)
1192
- [\<boolean>](#boolean)
1193
- [\<string>](#string)
1194
- [\<number>](#number)
1195
- [\<integer>](#integer)
1196
- [\<date>](#date)
1197
- [\<uuid>](#uuid)
1198
- [\<binary>](#binary)
1856
+ *src/app.tsx*
1857
+ ```typescript jsx
1858
+ export default (
1859
+ <server>
1860
+ <api>
1861
+ <endpoint method='get' path='/products'>
1862
+ <param
1863
+ in='query'
1864
+ name='active'>
1865
+ <null description='FIXME!' />
1866
+ </param>
1867
+ </endpoint>
1868
+ </api>
1869
+ </server>
1870
+ )
1871
+ ```
1199
1872
 
1200
1873
  ### \<boolean>
1201
1874
 
@@ -2477,7 +3150,9 @@ export default (
2477
3150
  <api>
2478
3151
  <endpoint method='post' path='/users'>
2479
3152
  <body>
2480
- <object />
3153
+ <object>
3154
+ <string />
3155
+ </object>
2481
3156
  </body>
2482
3157
  </endpoint>
2483
3158
  </api>
@@ -2538,9 +3213,9 @@ export default (
2538
3213
  <api>
2539
3214
  <endpoint method='post' path='/users'>
2540
3215
  <body>
2541
- <object
2542
- description='The object of a user'
2543
- />
3216
+ <object
3217
+ description='The object of a user'
3218
+ />
2544
3219
  </body>
2545
3220
  </endpoint>
2546
3221
  </api>
@@ -2556,7 +3231,7 @@ The element MUST be placed inside [\<object>](#object).
2556
3231
  It defines a `field` of an `object` value for a parent element.
2557
3232
  `@innet/server` formats and validate the value automatically (real-time).
2558
3233
 
2559
- `key` is REQUIRED prop of `<field>`, it defines a field name of the `<object>`.
3234
+ `key` is REQUIRED prop of `<field>`, it defines a field name of the [\<object>](#object).
2560
3235
 
2561
3236
  *src/app.tsx*
2562
3237
  ```typescript jsx
@@ -2600,116 +3275,46 @@ export default (
2600
3275
  )
2601
3276
  ```
2602
3277
 
2603
- ## Run-Time
2604
-
2605
- Next elements relate to run-time action.
2606
- This action calls on user request.
2607
-
2608
- [← back](#index)
2609
-
2610
- Parent
2611
- [\<fallback>](#fallback)
2612
- [\<request>](#request)
2613
-
2614
- Children
2615
- [\<success>](#success)
2616
- [\<error>](#error)
2617
- [\<proxy>](#proxy)
2618
- [\<redirect>](#redirect)
2619
- [\<cms>](#cms)
2620
- [\<file>](#file)
2621
- [\<header>](#header)
2622
- [\<cookie>](#cookie)
2623
-
2624
- ---
2625
-
2626
- ### \<fallback>
2627
-
2628
- [← back](#run-time)
2629
-
2630
- By default, `<api>` server returns 404 with empty body.
2631
- [\<fallback>](#fallback) element defines default server response.
2632
- This element MUST be placed in `<api>`.
2633
- You MUST use one [\<fallback>](#fallback) per `<api>`.
2634
- Can contain elements available inside [\<request>](#request).
2635
-
2636
- *src/app.tsx*
2637
- ```typescript jsx
2638
- export default (
2639
- <server>
2640
- <api>
2641
- <fallback>
2642
- <error
2643
- code='unknownEndpoint'
2644
- />
2645
- </fallback>
2646
- </api>
2647
- </server>
2648
- )
2649
- ```
2650
-
2651
- If you open the application on any URL except for `/`, you can see the next response.
2652
-
2653
- ```json
2654
- {
2655
- "error": "unknownEndpoint"
2656
- }
2657
- ```
2658
-
2659
- The next elements are placed in [\<request>](#request) or [\<fallback>](#fallback)
2660
-
2661
- ### \<request>
2662
-
2663
- [← back](#run-time)
3278
+ #### deprecated
2664
3279
 
2665
- This element MUST be placed in `<endpoint>` element.
2666
- It defines run-time call handler for the endpoint.
3280
+ You can deprecate a field.
2667
3281
 
2668
3282
  *src/app.tsx*
2669
3283
  ```typescript jsx
2670
3284
  export default (
2671
3285
  <server>
2672
3286
  <api>
2673
- <endpoint method='get' path='/partners'>
2674
- <request>
2675
- <success>
2676
- {{partners: []}}
2677
- </success>
2678
- </request>
3287
+ <endpoint method='post' path='/users'>
3288
+ <body>
3289
+ <object>
3290
+ <field key='name' />
3291
+ <field key='surname' />
3292
+ <field deprecated optional key='birthbay' />
3293
+ </object>
3294
+ </body>
2679
3295
  </endpoint>
2680
3296
  </api>
2681
3297
  </server>
2682
3298
  )
2683
3299
  ```
2684
3300
 
2685
- You can place a component inside it.
2686
- The component will run when the endpoint will be triggered.
3301
+ ## Run-Time
2687
3302
 
2688
- *src/app.tsx*
2689
- ```typescript jsx
2690
- import { GetPartners } from './GetPartners'
3303
+ Next elements relate to run-time action.
3304
+ This action calls on user request.
2691
3305
 
2692
- export default (
2693
- <server>
2694
- <api>
2695
- <endpoint method='get' path='/partners'>
2696
- <request>
2697
- <GetPartners />
2698
- </request>
2699
- </endpoint>
2700
- </api>
2701
- </server>
2702
- )
2703
- ```
3306
+ [← back](#index)
3307
+
3308
+ [\<success>](#success)
3309
+ [\<error>](#error)
3310
+ [\<proxy>](#proxy)
3311
+ [\<redirect>](#redirect)
3312
+ [\<cms>](#cms)
3313
+ [\<file>](#file)
3314
+ [\<header>](#header)
3315
+ [\<cookie>](#cookie)
2704
3316
 
2705
- *src/GetPartners.tsx*
2706
- ```typescript jsx
2707
- export const GetPartners = () => (
2708
- <success>
2709
- {{partners: []}}
2710
- </success>
2711
- )
2712
- ```
3317
+ ---
2713
3318
 
2714
3319
  ### \<success>
2715
3320
 
@@ -2721,11 +3326,9 @@ This is a base element to return a success data.
2721
3326
  ```typescript jsx
2722
3327
  export default (
2723
3328
  <server>
2724
- <api>
2725
- <fallback>
2726
- <success />
2727
- </fallback>
2728
- </api>
3329
+ <return>
3330
+ <success />
3331
+ </return>
2729
3332
  </server>
2730
3333
  )
2731
3334
  ```
@@ -2740,13 +3343,11 @@ const data = {...}
2740
3343
 
2741
3344
  export default (
2742
3345
  <server>
2743
- <api>
2744
- <fallback>
2745
- <success>
2746
- {data}
2747
- </success>
2748
- </fallback>
2749
- </api>
3346
+ <return>
3347
+ <success>
3348
+ {data}
3349
+ </success>
3350
+ </return>
2750
3351
  </server>
2751
3352
  )
2752
3353
  ```
@@ -2763,13 +3364,11 @@ const data = {...}
2763
3364
 
2764
3365
  export default (
2765
3366
  <server>
2766
- <api>
2767
- <fallback>
2768
- <success status='created'>
2769
- {data}
2770
- </success>
2771
- </fallback>
2772
- </api>
3367
+ <return>
3368
+ <success status='created'>
3369
+ {data}
3370
+ </success>
3371
+ </return>
2773
3372
  </server>
2774
3373
  )
2775
3374
  ```
@@ -2784,13 +3383,29 @@ const data = {...}
2784
3383
 
2785
3384
  export default (
2786
3385
  <server>
2787
- <api>
2788
- <fallback>
2789
- <success status={201}>
2790
- {data}
2791
- </success>
2792
- </fallback>
2793
- </api>
3386
+ <return>
3387
+ <success status={201}>
3388
+ {data}
3389
+ </success>
3390
+ </return>
3391
+ </server>
3392
+ )
3393
+ ```
3394
+
3395
+ #### contentType
3396
+
3397
+ This props sets response content type.
3398
+ By default, it checks children element to define the prop.
3399
+
3400
+ *src/app.tsx*
3401
+ ```typescript jsx
3402
+ export default (
3403
+ <server>
3404
+ <return>
3405
+ <success contentType='text/html'>
3406
+ Hello World!
3407
+ </success>
3408
+ </return>
2794
3409
  </server>
2795
3410
  )
2796
3411
  ```
@@ -2800,17 +3415,15 @@ export default (
2800
3415
  [← back](#run-time)
2801
3416
 
2802
3417
  Returns an error.
2803
- This element MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3418
+ This element MUST be placed in [\<return>](#return).
2804
3419
 
2805
3420
  *src/app.tsx*
2806
3421
  ```typescript jsx
2807
3422
  export default (
2808
3423
  <server>
2809
- <api>
2810
- <fallback>
2811
- <error />
2812
- </fallback>
2813
- </api>
3424
+ <return>
3425
+ <error />
3426
+ </return>
2814
3427
  </server>
2815
3428
  )
2816
3429
  ```
@@ -2823,13 +3436,11 @@ const data = {...}
2823
3436
 
2824
3437
  export default (
2825
3438
  <server>
2826
- <api>
2827
- <fallback>
2828
- <error>
2829
- {data}
2830
- </error>
2831
- </fallback>
2832
- </api>
3439
+ <return>
3440
+ <error>
3441
+ {data}
3442
+ </error>
3443
+ </return>
2833
3444
  </server>
2834
3445
  )
2835
3446
  ```
@@ -2845,13 +3456,11 @@ const data = {
2845
3456
 
2846
3457
  export default (
2847
3458
  <server>
2848
- <api>
2849
- <fallback>
2850
- <error status='notFound'>
2851
- {data}
2852
- </error>
2853
- </fallback>
2854
- </api>
3459
+ <return>
3460
+ <error status='notFound'>
3461
+ {data}
3462
+ </error>
3463
+ </return>
2855
3464
  </server>
2856
3465
  )
2857
3466
  ```
@@ -2866,13 +3475,11 @@ const data = {
2866
3475
 
2867
3476
  export default (
2868
3477
  <server>
2869
- <api>
2870
- <fallback>
2871
- <error status={404}>
2872
- {data}
2873
- </error>
2874
- </fallback>
2875
- </api>
3478
+ <return>
3479
+ <error status={404}>
3480
+ {data}
3481
+ </error>
3482
+ </return>
2876
3483
  </server>
2877
3484
  )
2878
3485
  ```
@@ -2900,15 +3507,13 @@ const data = {
2900
3507
 
2901
3508
  export default (
2902
3509
  <server>
2903
- <api>
2904
- <fallback>
2905
- <error
2906
- code='noUser'
2907
- status='notFound'>
2908
- {data}
2909
- </error>
2910
- </fallback>
2911
- </api>
3510
+ <return>
3511
+ <error
3512
+ code='noUser'
3513
+ status='notFound'>
3514
+ {data}
3515
+ </error>
3516
+ </return>
2912
3517
  </server>
2913
3518
  )
2914
3519
  ```
@@ -2936,7 +3541,7 @@ There are some default errors:
2936
3541
 
2937
3542
  [← back](#run-time)
2938
3543
 
2939
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3544
+ MUST be placed in [\<return>](#return).
2940
3545
 
2941
3546
  You can easy proxy endpoints to another server/service.
2942
3547
 
@@ -2948,14 +3553,14 @@ export default (
2948
3553
  <endpoint
2949
3554
  path='/test'
2950
3555
  method='get'>
2951
- <request>
3556
+ <return>
2952
3557
  <proxy to='https://...' />
2953
- </request>
3558
+ </return>
2954
3559
  </endpoint>
2955
- <fallback>
2956
- <proxy to='https://...' />
2957
- </fallback>
2958
3560
  </api>
3561
+ <return>
3562
+ <proxy to='https://...' />
3563
+ </return>
2959
3564
  </server>
2960
3565
  )
2961
3566
  ```
@@ -2964,7 +3569,7 @@ export default (
2964
3569
 
2965
3570
  [← back](#run-time)
2966
3571
 
2967
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3572
+ MUST be placed in [\<return>](#return).
2968
3573
 
2969
3574
  You can redirect users to another resource. It adds `Cache-Control` header by default.
2970
3575
 
@@ -2976,14 +3581,14 @@ export default (
2976
3581
  <endpoint
2977
3582
  path='/test'
2978
3583
  method='get'>
2979
- <request>
3584
+ <return>
2980
3585
  <redirect to='https://...' />
2981
- </request>
3586
+ </return>
2982
3587
  </endpoint>
2983
- <fallback>
2984
- <redirect to='https://...' />
2985
- </fallback>
2986
3588
  </api>
3589
+ <return>
3590
+ <redirect to='https://...' />
3591
+ </return>
2987
3592
  </server>
2988
3593
  )
2989
3594
  ```
@@ -3001,20 +3606,20 @@ export default (
3001
3606
  <endpoint
3002
3607
  path='/test'
3003
3608
  method='get'>
3004
- <request>
3609
+ <return>
3005
3610
  <redirect
3006
3611
  status='found'
3007
3612
  to='https://...'
3008
3613
  />
3009
- </request>
3614
+ </return>
3010
3615
  </endpoint>
3011
- <fallback>
3012
- <redirect
3013
- status={303}
3014
- to='https://...'
3015
- />
3016
- </fallback>
3017
3616
  </api>
3617
+ <return>
3618
+ <redirect
3619
+ status={303}
3620
+ to='https://...'
3621
+ />
3622
+ </return>
3018
3623
  </server>
3019
3624
  )
3020
3625
  ```
@@ -3023,7 +3628,7 @@ export default (
3023
3628
 
3024
3629
  [← back](#run-time)
3025
3630
 
3026
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3631
+ MUST be placed in [\<return>](#return).
3027
3632
 
3028
3633
  `<cms>` helps to return files from a folder by path. It checks files run-time on the server.
3029
3634
 
@@ -3031,18 +3636,16 @@ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3031
3636
  ```typescript jsx
3032
3637
  export default (
3033
3638
  <server>
3034
- <api>
3035
- <fallback>
3036
- <cms />
3037
- </fallback>
3038
- </api>
3639
+ <return>
3640
+ <cms />
3641
+ </return>
3039
3642
  </server>
3040
3643
  )
3041
3644
  ```
3042
3645
 
3043
3646
  #### dir
3044
3647
 
3045
- By default, it looks at project folder.
3648
+ By default, it equals `INNET_CMS_DIR` node env variable or the project folder.
3046
3649
  If you try the previous example on [http://localhost/package.json](http://localhost/package.json)
3047
3650
  you get the project `package.json` file.
3048
3651
 
@@ -3052,11 +3655,9 @@ You can change root folder by `dir` property.
3052
3655
  ```typescript jsx
3053
3656
  export default (
3054
3657
  <server>
3055
- <api>
3056
- <fallback>
3057
- <cms dir='src' />
3058
- </fallback>
3059
- </api>
3658
+ <return>
3659
+ <cms dir='src' />
3660
+ </return>
3060
3661
  </server>
3061
3662
  )
3062
3663
  ```
@@ -3067,15 +3668,16 @@ you get the index file in `src` folder.
3067
3668
  #### prefix
3068
3669
 
3069
3670
  `<cms>` matches full `path`, you should take it into account if you add `prefix` on `<api>`.
3671
+ By default, it equals `INNET_CMS_PREFIX` node env variable or `/`.
3070
3672
 
3071
3673
  *src/app.tsx*
3072
3674
  ```typescript jsx
3073
3675
  export default (
3074
3676
  <server>
3075
3677
  <api prefix='/src'>
3076
- <fallback>
3678
+ <return>
3077
3679
  <cms />
3078
- </fallback>
3680
+ </return>
3079
3681
  </api>
3080
3682
  </server>
3081
3683
  )
@@ -3091,9 +3693,9 @@ You can reduce the path for matching by prefix property of `<cms>`.
3091
3693
  export default (
3092
3694
  <server>
3093
3695
  <api prefix='/api'>
3094
- <fallback>
3696
+ <return>
3095
3697
  <cms prefix='/api' />
3096
- </fallback>
3698
+ </return>
3097
3699
  </api>
3098
3700
  </server>
3099
3701
  )
@@ -3109,13 +3711,11 @@ You can handle if a file was not found by children elements of `<cms>`.
3109
3711
  ```typescript jsx
3110
3712
  export default (
3111
3713
  <server>
3112
- <api prefix='/src'>
3113
- <fallback>
3114
- <cms>
3115
- <error status={404} />
3116
- </cms>
3117
- </fallback>
3118
- </api>
3714
+ <return>
3715
+ <cms>
3716
+ <error status={404} />
3717
+ </cms>
3718
+ </return>
3119
3719
  </server>
3120
3720
  )
3121
3721
  ```
@@ -3124,7 +3724,7 @@ export default (
3124
3724
 
3125
3725
  [← back](#run-time)
3126
3726
 
3127
- It returns a file. MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3727
+ It returns a file. MUST be placed in [\<return>](#return).
3128
3728
 
3129
3729
  It adds `Content-Length` and `Content-Type` automatically.
3130
3730
 
@@ -3134,13 +3734,9 @@ It has a REQUIRED property of `path`.
3134
3734
  ```typescript jsx
3135
3735
  export default (
3136
3736
  <server>
3137
- <api>
3138
- <fallback>
3139
- <file
3140
- path='package.json'
3141
- />
3142
- </fallback>
3143
- </api>
3737
+ <return>
3738
+ <file path='package.json' />
3739
+ </return>
3144
3740
  </server>
3145
3741
  )
3146
3742
  ```
@@ -3155,20 +3751,18 @@ You can handle if a file was not found by children elements of `<file>`.
3155
3751
  ```typescript jsx
3156
3752
  export default (
3157
3753
  <server>
3158
- <api prefix='/src'>
3159
- <fallback>
3160
- <file path='file_is_not_exist.txt'>
3161
- <error status={404} />
3162
- </file>
3163
- </fallback>
3164
- </api>
3754
+ <return>
3755
+ <file path='file_is_not_exist.txt'>
3756
+ <error status={404} />
3757
+ </file>
3758
+ </return>
3165
3759
  </server>
3166
3760
  )
3167
3761
  ```
3168
3762
 
3169
3763
  ### \<header>
3170
3764
 
3171
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3765
+ MUST be placed in [\<return>](#return).
3172
3766
 
3173
3767
  [← back](#run-time)
3174
3768
 
@@ -3178,22 +3772,20 @@ You can add an HTTP header into response by `<header>` element.
3178
3772
  ```typescript jsx
3179
3773
  export default (
3180
3774
  <server>
3181
- <api prefix='/src'>
3182
- <fallback>
3183
- <header
3184
- key='Cache-Control'
3185
- value='no-cache, no-store, must-revalidate'
3186
- />
3187
- <success />
3188
- </fallback>
3189
- </api>
3775
+ <return>
3776
+ <header
3777
+ key='Cache-Control'
3778
+ value='no-cache, no-store, must-revalidate'
3779
+ />
3780
+ <success />
3781
+ </return>
3190
3782
  </server>
3191
3783
  )
3192
3784
  ```
3193
3785
 
3194
3786
  ### \<cookie>
3195
3787
 
3196
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3788
+ MUST be placed in [\<return>](#return).
3197
3789
 
3198
3790
  [← back](#run-time)
3199
3791
 
@@ -3203,18 +3795,16 @@ You can add/remove a cookie into response by `<cookie>` element.
3203
3795
  ```typescript jsx
3204
3796
  export default (
3205
3797
  <server>
3206
- <api prefix='/src'>
3207
- <fallback>
3208
- <cookie
3209
- key='token'
3210
- value='...'
3211
- />
3212
- <cookie
3213
- key='removedCookie'
3214
- />
3215
- <success />
3216
- </fallback>
3217
- </api>
3798
+ <return>
3799
+ <cookie
3800
+ key='token'
3801
+ value='...'
3802
+ />
3803
+ <cookie
3804
+ key='removedCookie'
3805
+ />
3806
+ <success />
3807
+ </return>
3218
3808
  </server>
3219
3809
  )
3220
3810
  ```
@@ -3228,16 +3818,14 @@ By default, no domain is set, and most clients will consider the cookie to apply
3228
3818
  ```typescript jsx
3229
3819
  export default (
3230
3820
  <server>
3231
- <api prefix='/src'>
3232
- <fallback>
3233
- <cookie
3234
- domain='.example.com'
3235
- key='token'
3236
- value='...'
3237
- />
3238
- <success />
3239
- </fallback>
3240
- </api>
3821
+ <return>
3822
+ <cookie
3823
+ domain='.example.com'
3824
+ key='token'
3825
+ value='...'
3826
+ />
3827
+ <success />
3828
+ </return>
3241
3829
  </server>
3242
3830
  )
3243
3831
  ```
@@ -3256,16 +3844,14 @@ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/h
3256
3844
  ```typescript jsx
3257
3845
  export default (
3258
3846
  <server>
3259
- <api prefix='/src'>
3260
- <fallback>
3261
- <cookie
3262
- expires={new Date('2050-01-01')}
3263
- key='token'
3264
- value='...'
3265
- />
3266
- <success />
3267
- </fallback>
3268
- </api>
3847
+ <return>
3848
+ <cookie
3849
+ expires={new Date('2050-01-01')}
3850
+ key='token'
3851
+ value='...'
3852
+ />
3853
+ <success />
3854
+ </return>
3269
3855
  </server>
3270
3856
  )
3271
3857
  ```
@@ -3279,16 +3865,14 @@ Note be careful when setting this to true, as compliant clients will not allow c
3279
3865
  ```typescript jsx
3280
3866
  export default (
3281
3867
  <server>
3282
- <api prefix='/src'>
3283
- <fallback>
3284
- <cookie
3285
- httpOnly
3286
- key='token'
3287
- value='...'
3288
- />
3289
- <success />
3290
- </fallback>
3291
- </api>
3868
+ <return>
3869
+ <cookie
3870
+ httpOnly
3871
+ key='token'
3872
+ value='...'
3873
+ />
3874
+ <success />
3875
+ </return>
3292
3876
  </server>
3293
3877
  )
3294
3878
  ```
@@ -3302,17 +3886,15 @@ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/h
3302
3886
  ```typescript jsx
3303
3887
  export default (
3304
3888
  <server>
3305
- <api prefix='/src'>
3306
- <fallback>
3307
- <cookie
3308
- httpOnly
3309
- maxAge={9999}
3310
- key='token'
3311
- value='...'
3312
- />
3313
- <success />
3314
- </fallback>
3315
- </api>
3889
+ <return>
3890
+ <cookie
3891
+ httpOnly
3892
+ maxAge={9999}
3893
+ key='token'
3894
+ value='...'
3895
+ />
3896
+ <success />
3897
+ </return>
3316
3898
  </server>
3317
3899
  )
3318
3900
  ```
@@ -3326,18 +3908,16 @@ By default, the path is considered the “default path”.
3326
3908
  ```typescript jsx
3327
3909
  export default (
3328
3910
  <server>
3329
- <api prefix='/src'>
3330
- <fallback>
3331
- <cookie
3332
- httpOnly
3333
- maxAge={9999}
3334
- path='/src'
3335
- key='token'
3336
- value='...'
3337
- />
3338
- <success />
3339
- </fallback>
3340
- </api>
3911
+ <return>
3912
+ <cookie
3913
+ httpOnly
3914
+ maxAge={9999}
3915
+ path='/src'
3916
+ key='token'
3917
+ value='...'
3918
+ />
3919
+ <success />
3920
+ </return>
3341
3921
  </server>
3342
3922
  )
3343
3923
  ```
@@ -3356,18 +3936,16 @@ note This is an attribute that has not yet been fully standardized, and may chan
3356
3936
  ```typescript jsx
3357
3937
  export default (
3358
3938
  <server>
3359
- <api prefix='/src'>
3360
- <fallback>
3361
- <cookie
3362
- httpOnly
3363
- priority='high'
3364
- path='/src'
3365
- key='token'
3366
- value='...'
3367
- />
3368
- <success />
3369
- </fallback>
3370
- </api>
3939
+ <return>
3940
+ <cookie
3941
+ httpOnly
3942
+ priority='high'
3943
+ path='/src'
3944
+ key='token'
3945
+ value='...'
3946
+ />
3947
+ <success />
3948
+ </return>
3371
3949
  </server>
3372
3950
  )
3373
3951
  ```
@@ -3389,19 +3967,17 @@ This also means many clients may ignore this attribute until they understand it.
3389
3967
  ```typescript jsx
3390
3968
  export default (
3391
3969
  <server>
3392
- <api prefix='/src'>
3393
- <fallback>
3394
- <cookie
3395
- httpOnly
3396
- sameSite
3397
- priority='high'
3398
- path='/src'
3399
- key='token'
3400
- value='...'
3401
- />
3402
- <success />
3403
- </fallback>
3404
- </api>
3970
+ <return>
3971
+ <cookie
3972
+ httpOnly
3973
+ sameSite
3974
+ priority='high'
3975
+ path='/src'
3976
+ key='token'
3977
+ value='...'
3978
+ />
3979
+ <success />
3980
+ </return>
3405
3981
  </server>
3406
3982
  )
3407
3983
  ```
@@ -3418,17 +3994,15 @@ Note be careful when setting this to true, as compliant clients will not send th
3418
3994
  ```typescript jsx
3419
3995
  export default (
3420
3996
  <server>
3421
- <api prefix='/src'>
3422
- <fallback>
3423
- <cookie
3424
- httpOnly
3425
- secure
3426
- key='token'
3427
- value='...'
3428
- />
3429
- <success />
3430
- </fallback>
3431
- </api>
3997
+ <return>
3998
+ <cookie
3999
+ httpOnly
4000
+ secure
4001
+ key='token'
4002
+ value='...'
4003
+ />
4004
+ <success />
4005
+ </return>
3432
4006
  </server>
3433
4007
  )
3434
4008
  ```
@@ -3461,14 +4035,12 @@ import { SetToken } from './SetToken'
3461
4035
 
3462
4036
  export default (
3463
4037
  <server>
3464
- <api prefix='/src'>
3465
- <fallback>
3466
- <SetToken
3467
- value='...'
3468
- />
3469
- <success />
3470
- </fallback>
3471
- </api>
4038
+ <return>
4039
+ <SetToken
4040
+ value='...'
4041
+ />
4042
+ <success />
4043
+ </return>
3472
4044
  </server>
3473
4045
  )
3474
4046
  ```
@@ -3493,10 +4065,12 @@ Real-time
3493
4065
  [useClientIp](#useclientip)
3494
4066
 
3495
4067
  Server start
3496
- [useRequestPlugin](#userequestplugin)
4068
+ [useServerPlugin](#useserverplugin)
3497
4069
 
3498
4070
  Both
3499
4071
  [useServer](#useserver)
4072
+ [usePort](#useport)
4073
+ [useIsServerHttps](#useisserverhttps)
3500
4074
  [useComponentName](#usecomponentname)
3501
4075
 
3502
4076
  ---
@@ -3505,7 +4079,7 @@ Both
3505
4079
 
3506
4080
  [← back](#hooks)
3507
4081
 
3508
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4082
+ This hook MUST be used in a component placed in [\<return>](#return).
3509
4083
  This hook returns current request instance.
3510
4084
 
3511
4085
  *src/Component.tsx*
@@ -3526,7 +4100,7 @@ export function Component () {
3526
4100
 
3527
4101
  [← back](#hooks)
3528
4102
 
3529
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4103
+ This hook MUST be used in a component placed in [\<return>](#return).
3530
4104
  This hook returns current response instance.
3531
4105
 
3532
4106
  *src/Component.tsx*
@@ -3547,7 +4121,7 @@ export function Component () {
3547
4121
 
3548
4122
  [← back](#hooks)
3549
4123
 
3550
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4124
+ This hook MUST be used in a component placed in [\<return>](#return).
3551
4125
  This hook returns current request headers object.
3552
4126
 
3553
4127
  *src/Component.tsx*
@@ -3566,7 +4140,7 @@ export function Component () {
3566
4140
 
3567
4141
  [← back](#hooks)
3568
4142
 
3569
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4143
+ This hook MUST be used in a component placed in [\<return>](#return).
3570
4144
  This hook returns current request cookies object.
3571
4145
 
3572
4146
  *src/Component.tsx*
@@ -3585,7 +4159,7 @@ export function Component () {
3585
4159
 
3586
4160
  [← back](#hooks)
3587
4161
 
3588
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4162
+ This hook MUST be used in a component placed in [\<return>](#return).
3589
4163
  This hook returns current request URL path as a `string`.
3590
4164
 
3591
4165
  *src/Component.tsx*
@@ -3604,7 +4178,7 @@ export function Component () {
3604
4178
 
3605
4179
  [← back](#hooks)
3606
4180
 
3607
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4181
+ This hook MUST be used in a component placed in [\<return>](#return).
3608
4182
  This hook returns an object of URL params you set by [\<param>](#param).
3609
4183
 
3610
4184
  *src/Component.tsx*
@@ -3622,7 +4196,7 @@ export function Component () {
3622
4196
 
3623
4197
  [← back](#hooks)
3624
4198
 
3625
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4199
+ This hook MUST be used in a component placed in [\<return>](#return).
3626
4200
  This hook returns an object of URL query params.
3627
4201
 
3628
4202
  *src/Component.tsx*
@@ -3640,7 +4214,7 @@ export function Component () {
3640
4214
 
3641
4215
  [← back](#hooks)
3642
4216
 
3643
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4217
+ This hook MUST be used in a component placed in [\<return>](#return).
3644
4218
  This hook returns current request body.
3645
4219
 
3646
4220
  *src/Component.tsx*
@@ -3659,7 +4233,7 @@ export function Component () {
3659
4233
  [← back](#hooks)
3660
4234
 
3661
4235
  This hook returns request user IP.
3662
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4236
+ This hook MUST be used in a component placed in [\<return>](#return).
3663
4237
 
3664
4238
  *src/Component.tsx*
3665
4239
  ```typescript jsx
@@ -3672,7 +4246,7 @@ export function Component () {
3672
4246
  }
3673
4247
  ```
3674
4248
 
3675
- ### useRequestPlugin
4249
+ ### useServerPlugin
3676
4250
 
3677
4251
  [← back](#hooks)
3678
4252
 
@@ -3680,25 +4254,24 @@ This hook adds a request plugin function.
3680
4254
  The function runs before check endpoints.
3681
4255
  If the function returns `true` the request handling stops, and you get full control over the request.
3682
4256
 
3683
- This hook MUST be used in a component placed in [\<api>](#api).
4257
+ This hook MUST be used in a component placed in [\<server>](#server).
3684
4258
 
3685
4259
  *src/SecretEndpoint.tsx*
3686
4260
  ```typescript jsx
3687
- import { useRequestPlugin } from '@innet/sever'
4261
+ import { useRequestPlugin, useAction } from '@innet/sever'
3688
4262
 
3689
4263
  export function SecretEndpoint () {
3690
- useRequestPlugin((req, res) => {
3691
- if (req.url.startsWith('/secret-endpoint')) {
3692
- res.statusCode = 200
3693
- res.write('A secret message')
3694
- res.end()
3695
- return true
4264
+ useServerPlugin(() => {
4265
+ const action = useAction()
4266
+
4267
+ if (action.path.startsWith('/secret-endpoint')) {
4268
+ return <success>A secret message</success>
3696
4269
  }
3697
4270
  })
3698
4271
  }
3699
4272
  ```
3700
4273
 
3701
- Then use the plugin in [\<api>](#api).
4274
+ Then use the plugin in [\<server>](#server) or [\<api>](#api).
3702
4275
 
3703
4276
  *src/app.tsx*
3704
4277
  ```typescript jsx
@@ -3706,12 +4279,10 @@ import { SecretEndpoint } from './SecretEndpoint'
3706
4279
 
3707
4280
  export default (
3708
4281
  <server>
3709
- <api>
3710
- <fallback>
3711
- <error />
3712
- </fallback>
3713
- <SecretEndpoint />
3714
- </api>
4282
+ <SecretEndpoint />
4283
+ <return>
4284
+ <error />
4285
+ </return>
3715
4286
  </server>
3716
4287
  )
3717
4288
  ```
@@ -3739,6 +4310,53 @@ export function Component () {
3739
4310
  }
3740
4311
  ```
3741
4312
 
4313
+ ### usePort
4314
+
4315
+ [← back](#hooks)
4316
+
4317
+ This hook MUST be used in a component placed in [\<server>](#server).
4318
+ This hook returns current http(s) server port.
4319
+
4320
+ *src/LocalHost.tsx*
4321
+ ```typescript jsx
4322
+ import { usePort } from '@innet/sever'
4323
+
4324
+ export function LocalHost () {
4325
+ const port = usePort()
4326
+
4327
+ return (
4328
+ <host
4329
+ description='Development'
4330
+ url={`http://localhost:${port}/api`}
4331
+ />
4332
+ )
4333
+ }
4334
+ ```
4335
+
4336
+ ### useIsServerHttps
4337
+
4338
+ [← back](#hooks)
4339
+
4340
+ This hook MUST be used in a component placed in [\<server>](#server).
4341
+ This hook returns `true` if it is https server and `false` if not.
4342
+
4343
+ *src/LocalHost.tsx*
4344
+ ```typescript jsx
4345
+ import { usePort, useIsServerHttps } from '@innet/sever'
4346
+
4347
+ export function LocalHost () {
4348
+ const https = useIsServerHttps() ? 'https' : 'http'
4349
+ const port = usePort()
4350
+
4351
+ return (
4352
+ <host
4353
+ description='Development'
4354
+ url={`${https}://localhost:${port}/api`}
4355
+ />
4356
+ )
4357
+ }
4358
+ ```
4359
+
3742
4360
  ### useComponentName
3743
4361
 
3744
4362
  [← back](#hooks)