@innet/server 2.0.0-alpha.9 → 2.0.0-beta.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/README.md +1771 -799
  2. package/handler/handler.d.ts +26 -18
  3. package/handler/handler.es6.js +17 -14
  4. package/handler/handler.js +16 -13
  5. package/hooks/index.d.ts +26 -20
  6. package/hooks/index.es6.js +26 -20
  7. package/hooks/index.js +26 -20
  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/useEffect/index.d.ts +1 -0
  13. package/hooks/useEffect/index.es6.js +1 -0
  14. package/hooks/useEffect/index.js +9 -0
  15. package/hooks/useEffect/useEffect.d.ts +2 -0
  16. package/hooks/useEffect/useEffect.es6.js +8 -0
  17. package/hooks/useEffect/useEffect.js +12 -0
  18. package/hooks/useEndpoint/useEndpoint.d.ts +1 -1
  19. package/hooks/useEndpoint/useEndpoint.es6.js +3 -1
  20. package/hooks/useEndpoint/useEndpoint.js +3 -1
  21. package/hooks/useHeaders/useHeaders.d.ts +0 -1
  22. package/hooks/useIsServerHttps/index.d.ts +1 -0
  23. package/hooks/useIsServerHttps/index.es6.js +1 -0
  24. package/hooks/useIsServerHttps/index.js +10 -0
  25. package/hooks/useIsServerHttps/useIsServerHttps.d.ts +3 -0
  26. package/hooks/useIsServerHttps/useIsServerHttps.es6.js +14 -0
  27. package/hooks/useIsServerHttps/useIsServerHttps.js +19 -0
  28. package/hooks/useNewSchema/useNewSchema.es6.js +2 -2
  29. package/hooks/useNewSchema/useNewSchema.js +2 -2
  30. package/hooks/useObjectSchemaContext/index.d.ts +1 -0
  31. package/hooks/useObjectSchemaContext/index.es6.js +1 -0
  32. package/hooks/useObjectSchemaContext/index.js +10 -0
  33. package/hooks/useObjectSchemaContext/useObjectSchemaContext.d.ts +3 -0
  34. package/hooks/useObjectSchemaContext/useObjectSchemaContext.es6.js +14 -0
  35. package/hooks/useObjectSchemaContext/useObjectSchemaContext.js +19 -0
  36. package/hooks/useRequest/index.es6.js +1 -1
  37. package/hooks/useRequest/index.js +0 -1
  38. package/hooks/useRequest/useRequest.d.ts +1 -5
  39. package/hooks/useRequest/useRequest.es6.js +4 -4
  40. package/hooks/useRequest/useRequest.js +3 -4
  41. package/hooks/useRequestHandler/index.d.ts +1 -0
  42. package/hooks/useRequestHandler/index.es6.js +1 -0
  43. package/hooks/useRequestHandler/index.js +10 -0
  44. package/hooks/useRequestHandler/useRequestHandler.d.ts +4 -0
  45. package/hooks/useRequestHandler/useRequestHandler.es6.js +14 -0
  46. package/hooks/useRequestHandler/useRequestHandler.js +19 -0
  47. package/hooks/useResponse/index.es6.js +1 -1
  48. package/hooks/useResponse/index.js +0 -1
  49. package/hooks/useResponse/useResponse.d.ts +1 -5
  50. package/hooks/useResponse/useResponse.es6.js +4 -4
  51. package/hooks/useResponse/useResponse.js +3 -4
  52. package/hooks/useSchemaType/useSchemaType.d.ts +3 -2
  53. package/hooks/useSchemaType/useSchemaType.es6.js +16 -9
  54. package/hooks/useSchemaType/useSchemaType.js +16 -9
  55. package/hooks/useServer/useServer.d.ts +2 -3
  56. package/hooks/useServer/useServer.es6.js +3 -1
  57. package/hooks/useServer/useServer.js +3 -1
  58. package/hooks/useServerPlugin/index.d.ts +1 -0
  59. package/hooks/useServerPlugin/index.es6.js +1 -0
  60. package/hooks/useServerPlugin/index.js +9 -0
  61. package/hooks/useServerPlugin/useServerPlugin.d.ts +2 -0
  62. package/hooks/useServerPlugin/useServerPlugin.es6.js +13 -0
  63. package/hooks/useServerPlugin/useServerPlugin.js +17 -0
  64. package/hooks/useServerPlugins/index.d.ts +1 -0
  65. package/hooks/useServerPlugins/index.es6.js +1 -0
  66. package/hooks/useServerPlugins/index.js +10 -0
  67. package/hooks/useServerPlugins/useServerPlugins.d.ts +4 -0
  68. package/hooks/useServerPlugins/useServerPlugins.es6.js +14 -0
  69. package/hooks/useServerPlugins/useServerPlugins.js +19 -0
  70. package/hooks/useServerPort/index.d.ts +1 -0
  71. package/hooks/useServerPort/index.es6.js +1 -0
  72. package/hooks/useServerPort/index.js +10 -0
  73. package/hooks/useServerPort/useServerPort.d.ts +3 -0
  74. package/hooks/useServerPort/useServerPort.es6.js +14 -0
  75. package/hooks/useServerPort/useServerPort.js +19 -0
  76. package/index.d.ts +2 -2
  77. package/index.es6.js +91 -82
  78. package/index.js +208 -184
  79. package/package.json +16 -16
  80. package/plugins/handler/serverFn/serverFn.es6.js +2 -2
  81. package/plugins/handler/serverFn/serverFn.js +2 -6
  82. package/plugins/index.d.ts +2 -2
  83. package/plugins/index.es6.js +2 -2
  84. package/plugins/index.js +2 -2
  85. package/plugins/main/api/api.d.ts +11 -8
  86. package/plugins/main/api/api.es6.js +112 -113
  87. package/plugins/main/api/api.js +112 -117
  88. package/plugins/main/body/body.d.ts +1 -0
  89. package/plugins/main/body/body.es6.js +4 -4
  90. package/plugins/main/body/body.js +4 -8
  91. package/plugins/main/contact/contact.d.ts +2 -2
  92. package/plugins/main/endpoint/endpoint.d.ts +21 -15
  93. package/plugins/main/endpoint/endpoint.es6.js +12 -10
  94. package/plugins/main/endpoint/endpoint.js +11 -13
  95. package/plugins/main/host/host.d.ts +5 -5
  96. package/plugins/main/host/host.es6.js +4 -2
  97. package/plugins/main/host/host.js +4 -6
  98. package/plugins/main/index.d.ts +9 -9
  99. package/plugins/main/index.es6.js +9 -9
  100. package/plugins/main/index.js +9 -9
  101. package/plugins/main/license/license.d.ts +5 -5
  102. package/plugins/main/param/param.d.ts +12 -11
  103. package/plugins/main/param/param.es6.js +7 -8
  104. package/plugins/main/param/param.js +6 -11
  105. package/plugins/main/preset/index.d.ts +1 -0
  106. package/plugins/main/preset/index.es6.js +1 -0
  107. package/plugins/{utils/prod → main/preset}/index.js +2 -2
  108. package/plugins/main/preset/preset.d.ts +3 -0
  109. package/plugins/main/preset/preset.es6.js +13 -0
  110. package/plugins/main/preset/preset.js +17 -0
  111. package/plugins/main/response/index.es6.js +1 -1
  112. package/plugins/main/response/index.js +1 -0
  113. package/plugins/main/response/response.d.ts +6 -1
  114. package/plugins/main/response/response.es6.js +29 -13
  115. package/plugins/main/response/response.js +28 -15
  116. package/plugins/main/return/index.d.ts +1 -0
  117. package/plugins/main/return/index.es6.js +1 -0
  118. package/plugins/main/return/index.js +9 -0
  119. package/plugins/main/return/return.d.ts +4 -0
  120. package/plugins/main/return/return.es6.js +10 -0
  121. package/plugins/main/return/return.js +14 -0
  122. package/plugins/main/server/server.d.ts +6 -6
  123. package/plugins/main/server/server.es6.js +40 -16
  124. package/plugins/main/server/server.js +39 -16
  125. package/plugins/main/tag/index.es6.js +1 -1
  126. package/plugins/main/tag/index.js +1 -0
  127. package/plugins/main/tag/tag.d.ts +10 -2
  128. package/plugins/main/tag/tag.es6.js +25 -6
  129. package/plugins/main/tag/tag.js +24 -8
  130. package/plugins/main/variable/variable.d.ts +5 -5
  131. package/plugins/main/variable/variable.es6.js +4 -3
  132. package/plugins/main/variable/variable.js +4 -3
  133. package/plugins/request/cms/cms.d.ts +1 -0
  134. package/plugins/request/cms/cms.es6.js +4 -5
  135. package/plugins/request/cms/cms.js +3 -5
  136. package/plugins/request/cookie/cookie.d.ts +2 -2
  137. package/plugins/request/cookie/cookie.es6.js +1 -2
  138. package/plugins/request/cookie/cookie.js +1 -2
  139. package/plugins/request/error/error.d.ts +41 -40
  140. package/plugins/request/error/error.es6.js +47 -45
  141. package/plugins/request/error/error.js +46 -44
  142. package/plugins/request/file/file.d.ts +1 -0
  143. package/plugins/request/file/file.es6.js +5 -7
  144. package/plugins/request/file/file.js +3 -6
  145. package/plugins/request/header/header.es6.js +1 -1
  146. package/plugins/request/header/header.js +1 -1
  147. package/plugins/request/index.d.ts +5 -5
  148. package/plugins/request/index.es6.js +5 -5
  149. package/plugins/request/index.js +5 -5
  150. package/plugins/request/proxy/proxy.d.ts +3 -1
  151. package/plugins/request/proxy/proxy.es6.js +5 -2
  152. package/plugins/request/proxy/proxy.js +5 -2
  153. package/plugins/request/redirect/redirect.d.ts +8 -7
  154. package/plugins/request/redirect/redirect.es6.js +7 -7
  155. package/plugins/request/redirect/redirect.js +7 -7
  156. package/plugins/request/success/success.d.ts +8 -6
  157. package/plugins/request/success/success.es6.js +21 -11
  158. package/plugins/request/success/success.js +20 -10
  159. package/plugins/schema/any/any.d.ts +5 -0
  160. package/plugins/schema/any/any.es6.js +27 -0
  161. package/plugins/schema/any/any.js +31 -0
  162. package/plugins/schema/array/array.d.ts +4 -0
  163. package/plugins/schema/array/array.es6.js +15 -7
  164. package/plugins/schema/array/array.js +15 -11
  165. package/plugins/schema/binary/binary.d.ts +7 -3
  166. package/plugins/schema/boolean/boolean.d.ts +1 -0
  167. package/plugins/schema/date/date.d.ts +3 -2
  168. package/plugins/schema/date/date.es6.js +8 -4
  169. package/plugins/schema/date/date.js +8 -4
  170. package/plugins/schema/field/field.d.ts +6 -0
  171. package/plugins/schema/field/field.es6.js +22 -9
  172. package/plugins/schema/field/field.js +20 -11
  173. package/plugins/schema/index.d.ts +8 -7
  174. package/plugins/schema/index.es6.js +8 -7
  175. package/plugins/schema/index.js +8 -7
  176. package/plugins/schema/integer/integer.d.ts +40 -3
  177. package/plugins/schema/integer/integer.es6.js +29 -9
  178. package/plugins/schema/integer/integer.js +29 -9
  179. package/plugins/schema/number/number.d.ts +34 -2
  180. package/plugins/schema/number/number.es6.js +21 -6
  181. package/plugins/schema/number/number.js +21 -6
  182. package/plugins/schema/object/object.d.ts +1 -0
  183. package/plugins/schema/object/object.es6.js +22 -8
  184. package/plugins/schema/object/object.js +21 -11
  185. package/plugins/schema/string/string.d.ts +29 -2
  186. package/plugins/schema/string/string.es6.js +50 -31
  187. package/plugins/schema/string/string.js +50 -31
  188. package/plugins/schema/tuple/tuple.d.ts +1 -0
  189. package/plugins/schema/tuple/tuple.es6.js +8 -9
  190. package/plugins/schema/tuple/tuple.js +7 -12
  191. package/plugins/schema/uuid/uuid.es6.js +5 -3
  192. package/plugins/schema/uuid/uuid.js +5 -3
  193. package/plugins/utils/blacklist/blacklist.d.ts +5 -0
  194. package/plugins/utils/blacklist/blacklist.es6.js +17 -0
  195. package/plugins/utils/blacklist/blacklist.js +21 -0
  196. package/plugins/utils/blacklist/index.d.ts +1 -0
  197. package/plugins/utils/blacklist/index.es6.js +1 -0
  198. package/plugins/utils/blacklist/index.js +9 -0
  199. package/plugins/utils/dts/dts.d.ts +2 -1
  200. package/plugins/utils/dts/dts.es6.js +6 -3
  201. package/plugins/utils/dts/dts.js +6 -3
  202. package/plugins/utils/env/env.d.ts +7 -0
  203. package/plugins/utils/env/env.es6.js +11 -0
  204. package/plugins/utils/env/env.js +15 -0
  205. package/plugins/utils/env/index.d.ts +1 -0
  206. package/plugins/utils/env/index.es6.js +1 -0
  207. package/plugins/utils/{dev → env}/index.js +2 -2
  208. package/plugins/utils/index.d.ts +5 -3
  209. package/plugins/utils/index.es6.js +5 -3
  210. package/plugins/utils/index.js +5 -3
  211. package/plugins/utils/protection/protection.d.ts +4 -4
  212. package/plugins/utils/protection/protection.es6.js +13 -16
  213. package/plugins/utils/protection/protection.js +13 -16
  214. package/plugins/utils/swagger/swagger.d.ts +1 -0
  215. package/plugins/utils/swagger/swagger.es6.js +8 -5
  216. package/plugins/utils/swagger/swagger.js +8 -5
  217. package/plugins/utils/ui/index.d.ts +1 -0
  218. package/plugins/utils/ui/index.es6.js +1 -0
  219. package/plugins/utils/ui/index.js +10 -0
  220. package/plugins/utils/ui/rapidoc.html.es6.js +3 -0
  221. package/plugins/utils/ui/rapidoc.html.js +7 -0
  222. package/plugins/utils/ui/redoc.html.es6.js +3 -0
  223. package/plugins/utils/ui/redoc.html.js +7 -0
  224. package/plugins/utils/ui/scalar.html.es6.js +3 -0
  225. package/plugins/utils/ui/scalar.html.js +7 -0
  226. package/plugins/utils/ui/swagger.html.es6.js +3 -0
  227. package/plugins/utils/ui/swagger.html.js +7 -0
  228. package/plugins/utils/ui/ui.d.ts +13 -0
  229. package/plugins/utils/ui/ui.es6.js +45 -0
  230. package/plugins/utils/ui/ui.js +50 -0
  231. package/plugins/utils/whitelist/index.d.ts +1 -0
  232. package/plugins/utils/whitelist/index.es6.js +1 -0
  233. package/plugins/utils/whitelist/index.js +9 -0
  234. package/plugins/utils/whitelist/whitelist.d.ts +5 -0
  235. package/plugins/utils/whitelist/whitelist.es6.js +19 -0
  236. package/plugins/utils/whitelist/whitelist.js +23 -0
  237. package/types.d.ts +21 -22
  238. package/utils/FileData/Bin.d.ts +13 -13
  239. package/utils/FileData/Bin.es6.js +2 -2
  240. package/utils/FileData/Bin.js +2 -2
  241. package/utils/action/Action.d.ts +13 -14
  242. package/utils/action/Action.es6.js +92 -92
  243. package/utils/action/Action.js +91 -91
  244. package/utils/dateFormat/dateFormat.d.ts +1 -1
  245. package/utils/dateFormat/dateFormat.es6.js +1 -1
  246. package/utils/dateFormat/dateFormat.js +1 -1
  247. package/utils/decorators/once/once.es6.js +1 -1
  248. package/utils/decorators/once/once.js +1 -1
  249. package/utils/generateTypes/generateTypes.d.ts +2 -2
  250. package/utils/generateTypes/generateTypes.es6.js +85 -25
  251. package/utils/generateTypes/generateTypes.js +85 -25
  252. package/utils/getEndpoint/getEndpoint.es6.js +2 -2
  253. package/utils/getEndpoint/getEndpoint.js +2 -2
  254. package/utils/getOrAdd/getOrAdd.d.ts +1 -1
  255. package/utils/getSafeSchema/getSafeSchema.d.ts +2 -0
  256. package/utils/getSafeSchema/getSafeSchema.es6.js +5 -0
  257. package/utils/getSafeSchema/getSafeSchema.js +9 -0
  258. package/utils/getSafeSchema/index.d.ts +1 -0
  259. package/utils/getSafeSchema/index.es6.js +1 -0
  260. package/utils/getSafeSchema/index.js +9 -0
  261. package/utils/httpOnStart/httpOnStart.d.ts +1 -1
  262. package/utils/httpOnStart/httpOnStart.es6.js +1 -1
  263. package/utils/httpOnStart/httpOnStart.js +1 -1
  264. package/utils/index.d.ts +9 -8
  265. package/utils/index.es6.js +9 -8
  266. package/utils/index.js +9 -8
  267. package/utils/parseBody/parseBody.d.ts +0 -1
  268. package/utils/parseBody/parseBody.es6.js +13 -16
  269. package/utils/parseBody/parseBody.js +13 -16
  270. package/utils/parseFormBody/parseFormBody.d.ts +0 -1
  271. package/utils/parseFormBody/parseFormBody.es6.js +41 -41
  272. package/utils/parseFormBody/parseFormBody.js +41 -41
  273. package/utils/parseSearch/parseSearch.es6.js +4 -1
  274. package/utils/parseSearch/parseSearch.js +4 -1
  275. package/utils/rules/arrayOf/arrayOf.es6.js +1 -1
  276. package/utils/rules/arrayOf/arrayOf.js +1 -1
  277. package/utils/rules/bin/bin.es6.js +4 -1
  278. package/utils/rules/bin/bin.js +4 -1
  279. package/utils/rules/binaryAccept/binaryAccept.es6.js +5 -2
  280. package/utils/rules/binaryAccept/binaryAccept.js +5 -2
  281. package/utils/rules/dateTo/dateTo.d.ts +1 -1
  282. package/utils/rules/dateTo/dateTo.es6.js +4 -1
  283. package/utils/rules/dateTo/dateTo.js +4 -1
  284. package/utils/rules/helpers.d.ts +1 -1
  285. package/utils/rules/helpers.es6.js +4 -1
  286. package/utils/rules/helpers.js +4 -1
  287. package/utils/rules/index.d.ts +17 -18
  288. package/utils/rules/index.es6.js +17 -18
  289. package/utils/rules/index.js +18 -19
  290. package/utils/rules/int/int.es6.js +17 -4
  291. package/utils/rules/int/int.js +17 -4
  292. package/utils/rules/max/max.d.ts +1 -1
  293. package/utils/rules/max/max.es6.js +10 -4
  294. package/utils/rules/max/max.js +10 -4
  295. package/utils/rules/maxBin/maxBin.es6.js +5 -2
  296. package/utils/rules/maxBin/maxBin.js +5 -2
  297. package/utils/rules/maxDate/maxDate.es6.js +5 -1
  298. package/utils/rules/maxDate/maxDate.js +5 -1
  299. package/utils/rules/maxLength/maxLength.es6.js +5 -2
  300. package/utils/rules/maxLength/maxLength.js +5 -2
  301. package/utils/rules/min/min.d.ts +1 -1
  302. package/utils/rules/min/min.es6.js +10 -4
  303. package/utils/rules/min/min.js +10 -4
  304. package/utils/rules/minBin/minBin.es6.js +5 -2
  305. package/utils/rules/minBin/minBin.js +5 -2
  306. package/utils/rules/minDate/minDate.es6.js +5 -1
  307. package/utils/rules/minDate/minDate.js +5 -1
  308. package/utils/rules/minLength/minLength.es6.js +5 -2
  309. package/utils/rules/minLength/minLength.js +5 -2
  310. package/utils/rules/num/num.es6.js +4 -1
  311. package/utils/rules/num/num.js +4 -1
  312. package/utils/rules/objectOf/objectOf.d.ts +1 -1
  313. package/utils/rules/objectOf/objectOf.es6.js +16 -3
  314. package/utils/rules/objectOf/objectOf.js +16 -3
  315. package/utils/rules/pattern/pattern.d.ts +1 -1
  316. package/utils/rules/pattern/pattern.es6.js +6 -1
  317. package/utils/rules/pattern/pattern.js +6 -1
  318. package/utils/rules/tupleOf/tupleOf.es6.js +1 -1
  319. package/utils/rules/tupleOf/tupleOf.js +1 -1
  320. package/utils/rules/values/values.es6.js +5 -2
  321. package/utils/rules/values/values.js +5 -2
  322. package/utils/stringifySearch/stringifySearch.es6.js +4 -1
  323. package/utils/stringifySearch/stringifySearch.js +4 -1
  324. package/example/app/App/App.d.ts +0 -1
  325. package/example/app/App/index.d.ts +0 -1
  326. package/example/index.d.ts +0 -1
  327. package/example/requests/index.d.ts +0 -1
  328. package/example/requests/todo/AddTodo/AddTodo.d.ts +0 -1
  329. package/example/requests/todo/AddTodo/index.d.ts +0 -1
  330. package/example/requests/todo/DeleteTodo/DeleteTodo.d.ts +0 -1
  331. package/example/requests/todo/DeleteTodo/index.d.ts +0 -1
  332. package/example/requests/todo/EditTodo/EditTodo.d.ts +0 -1
  333. package/example/requests/todo/EditTodo/index.d.ts +0 -1
  334. package/example/requests/todo/GetTodo/GetTodo.d.ts +0 -1
  335. package/example/requests/todo/GetTodo/index.d.ts +0 -1
  336. package/example/requests/todo/GetTodos/GetTodos.d.ts +0 -1
  337. package/example/requests/todo/GetTodos/index.d.ts +0 -1
  338. package/example/requests/todo/index.d.ts +0 -5
  339. package/example/requests/todo/todos.d.ts +0 -1
  340. package/example/schemas/app/ListQueryParams/ListQueryParams.d.ts +0 -1
  341. package/example/schemas/app/ListQueryParams/index.d.ts +0 -1
  342. package/example/schemas/app/ListSchema/ListSchema.d.ts +0 -4
  343. package/example/schemas/app/ListSchema/index.d.ts +0 -1
  344. package/example/schemas/app/index.d.ts +0 -2
  345. package/example/schemas/index.d.ts +0 -2
  346. package/example/schemas/todo/TodoSchema/TodoSchema.d.ts +0 -4
  347. package/example/schemas/todo/TodoSchema/index.d.ts +0 -1
  348. package/example/schemas/todo/index.d.ts +0 -1
  349. package/example/tags/Todo/Todo.d.ts +0 -1
  350. package/example/tags/Todo/index.d.ts +0 -1
  351. package/example/tags/index.d.ts +0 -1
  352. package/hooks/useRequestPlugin/index.d.ts +0 -1
  353. package/hooks/useRequestPlugin/index.es6.js +0 -1
  354. package/hooks/useRequestPlugin/index.js +0 -9
  355. package/hooks/useRequestPlugin/useRequestPlugin.d.ts +0 -2
  356. package/hooks/useRequestPlugin/useRequestPlugin.es6.js +0 -13
  357. package/hooks/useRequestPlugin/useRequestPlugin.js +0 -17
  358. package/openApi.test.d.ts +0 -1
  359. package/plugins/main/fallback/fallback.d.ts +0 -4
  360. package/plugins/main/fallback/fallback.es6.js +0 -19
  361. package/plugins/main/fallback/fallback.js +0 -23
  362. package/plugins/main/fallback/index.d.ts +0 -1
  363. package/plugins/main/fallback/index.es6.js +0 -1
  364. package/plugins/main/fallback/index.js +0 -9
  365. package/plugins/main/request/index.d.ts +0 -1
  366. package/plugins/main/request/index.es6.js +0 -1
  367. package/plugins/main/request/index.js +0 -9
  368. package/plugins/main/request/request.d.ts +0 -4
  369. package/plugins/main/request/request.es6.js +0 -21
  370. package/plugins/main/request/request.js +0 -25
  371. package/plugins/utils/dev/dev.d.ts +0 -4
  372. package/plugins/utils/dev/dev.es6.js +0 -10
  373. package/plugins/utils/dev/dev.js +0 -18
  374. package/plugins/utils/dev/index.d.ts +0 -1
  375. package/plugins/utils/dev/index.es6.js +0 -1
  376. package/plugins/utils/prod/index.d.ts +0 -1
  377. package/plugins/utils/prod/index.es6.js +0 -1
  378. package/plugins/utils/prod/prod.d.ts +0 -4
  379. package/plugins/utils/prod/prod.es6.js +0 -10
  380. package/plugins/utils/prod/prod.js +0 -18
  381. package/utils/decorators/once/once.test.d.ts +0 -1
  382. package/utils/generateTypes/generateTypes.test.d.ts +0 -1
  383. package/utils/parseSearch/parseSearch.test.d.ts +0 -1
  384. package/utils/rules/any/any.d.ts +0 -1
  385. package/utils/rules/any/any.es6.js +0 -5
  386. package/utils/rules/any/any.js +0 -9
  387. /package/{utils/rules → plugins/schema}/any/index.d.ts +0 -0
  388. /package/{utils/rules → plugins/schema}/any/index.es6.js +0 -0
  389. /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,894 +345,1669 @@ export default (
308
345
  </server>
309
346
  )
310
347
  ```
348
+ *default: `INNET_API_PREFIX` || `''`*
311
349
 
312
- ## Utils
313
-
314
- This section contains elements of utils.
315
-
316
- [← back](#index)
317
-
318
- [\<swagger>](#swagger)
319
- [\<dev>](#dev)
320
- [\<prod>](#prod)
321
- [\<dts>](#dts)
322
- [\<protection>](#protection)
323
-
324
- ---
325
-
326
- ### \<swagger>
327
-
328
- [← back](#utils)
350
+ #### include
329
351
 
330
- Use `<swagger>` element to add Swagger UI documentation.
331
- `<swagger>` element MUST be placed in `<api>` element.
352
+ A regular expression scopes the API.
332
353
 
333
354
  *src/app.tsx*
334
355
  ```typescript jsx
335
356
  export default (
336
357
  <server>
337
- <api>
338
- <swagger />
339
- </api>
358
+ <api
359
+ include={/^\/(api|openapi)/}
360
+ />
340
361
  </server>
341
362
  )
342
363
  ```
343
364
 
344
- Open http://localhost:80/swagger-ui
345
- You will see Swagger UI documentation.
365
+ #### exclude
346
366
 
347
- You can change the Swagger UI URL path by `path` property of `<swagger>` element.
367
+ A regular expression does not scope the API.
348
368
 
349
369
  *src/app.tsx*
350
370
  ```typescript jsx
351
371
  export default (
352
372
  <server>
353
- <api>
354
- <swagger path='/swagger' />
355
- </api>
373
+ <api prefix='/api' />
374
+ <api prefix='/openapi' />
375
+ <api exclude={/^\/(api|openapi)/} />
356
376
  </server>
357
377
  )
358
378
  ```
359
379
 
360
- ### \<dev>
380
+ ### \<return>
361
381
 
362
- [← back](#utils)
382
+ [← back](#main)
363
383
 
364
- Everything inside <dev> will work when `NODE_ENV` equals `development`.
384
+ This element MUST be placed in [\<server>](#server) element.
385
+ It defines a run-time call handler for parent element.
365
386
 
366
387
  *src/app.tsx*
367
388
  ```typescript jsx
368
389
  export default (
369
390
  <server>
370
- <api>
371
- <dev>
372
- <swagger />
373
- </dev>
374
- </api>
391
+ <return>
392
+ <error status={404} />
393
+ </return>
375
394
  </server>
376
395
  )
377
396
  ```
397
+ *Any request returns 404*
378
398
 
379
- ### \<prod>
380
-
381
- [← back](#utils)
382
-
383
- Everything inside <prod> will work when `NODE_ENV` equals `production`.
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`.
384
402
 
385
403
  *src/app.tsx*
386
404
  ```typescript jsx
387
405
  export default (
388
406
  <server>
389
- <api>
390
- <prod>
391
- <swagger />
392
- </prod>
393
- </api>
407
+ <return>
408
+ <error status={404} />
409
+ </return>
410
+ <return>
411
+ <success />
412
+ </return>
394
413
  </server>
395
414
  )
396
415
  ```
397
416
 
398
- ### \<dts>
417
+ like
399
418
 
400
- [← back](#utils)
419
+ ```javascript
420
+ function server () {
421
+ return 'error'
422
+ return 'success'
423
+ }
424
+ ```
401
425
 
402
- Use `<dts>` element to add types generation.
403
- `<dts>` element MUST be placed in `<api>` element.
426
+ *The second [\<return>](#return) will newer run.*
404
427
 
405
- `<dts>` has a required prop of `path`. This is a path of api TypeScript types file, `<dts>` generates it.
428
+ You can use [\<return>](#return) in some elements like you use `return` in `if` or `while`.
406
429
 
407
430
  *src/app.tsx*
408
431
  ```typescript jsx
409
432
  export default (
410
433
  <server>
411
- <api>
412
- <dev>
413
- <dts path='src/api.d.ts' />
414
- </dev>
415
- </api>
434
+ <env is='dev'>
435
+ <return>
436
+ <error status={404} />
437
+ </return>
438
+ </env>
439
+ <return>
440
+ <success />
441
+ </return>
416
442
  </server>
417
443
  )
418
444
  ```
419
445
 
420
- You do not need to import types, use `Api` namespace everywhere.
421
- Here is an example of generated types usage.
422
-
423
- ```typescript jsx
424
- import { useParams } from '@innet/server'
425
-
426
- import { todos } from '../todos'
427
-
428
- export function DeleteTodo () {
429
- const { todoId } = useParams<Api.Endpoints['DELETE:/todos/{todoId}']['Params']>()
430
-
431
- const todoIndex = todos.findIndex(({ id }) => id === todoId)
446
+ like
432
447
 
433
- if (todoIndex === -1) {
434
- return <error code='todoNotFound' status={404} />
448
+ ```javascript
449
+ function server () {
450
+ if (process.env.NODE_ENV === 'dev') {
451
+ return 'error'
435
452
  }
436
453
 
437
- todos.splice(todoIndex, 1)
438
-
439
- return <success />
454
+ return 'success'
440
455
  }
441
456
  ```
442
457
 
443
- ### \<protection>
444
-
445
- [← back](#utils)
446
-
447
- This element adds protection page.
448
- You can use it when you want to protect your application.
449
- This element MUST be placed in `<api>` element.
450
-
451
- #### html
452
-
453
- `<protection>` has a required prop of `html`.
454
- This is a `string` of HTML a user will see if they have no protection.
458
+ Place [\<return>](#return) in [\<api>](#api) to handle any unknown request in the [\<api>](#api).
455
459
 
456
460
  *src/app.tsx*
457
461
  ```typescript jsx
458
- import html from './protection.html'
459
-
460
462
  export default (
461
463
  <server>
462
464
  <api>
463
- <protection
464
- html={html}
465
- />
465
+ <return>
466
+ <error status={404} />
467
+ </return>
466
468
  </api>
467
469
  </server>
468
470
  )
469
471
  ```
470
472
 
471
- #### value
472
-
473
- This prop is a secret string of protection value.
474
- User must provide a protection query param equals the `value`.
475
-
476
- By default, the value is `undefined` and protection does not work.
477
- You can use `PROTECTION` env to set default protection `value`.
473
+ Place [\<return>](#return) in [\<endpoint>](#endpoint) to handle the [\<endpoint>](#endpoint) request.
478
474
 
479
475
  *src/app.tsx*
480
476
  ```typescript jsx
481
- import html from './protection.html'
482
-
483
477
  export default (
484
478
  <server>
485
479
  <api>
486
- <protection
487
- value='secret'
488
- html={html}
489
- />
480
+ <endpoint method='get' path='/my-endpoint'>
481
+ <return>
482
+ <success>
483
+ My Endpoint
484
+ </success>
485
+ </return>
486
+ </endpoint>
490
487
  </api>
488
+ <return>
489
+ <success>
490
+ Any other request
491
+ </success>
492
+ </return>
491
493
  </server>
492
494
  )
493
495
  ```
494
496
 
495
- #### maxAge
496
-
497
- This prop sets how much time protection is qualified.
498
-
499
- By default, the prop equals a year.
500
- You can use `PROTECTION_MAX_AGE` env to set default `maxAge`.
497
+ You can place a component inside [\<return>](#return).
498
+ The component will run when the request will be triggered.
501
499
 
502
500
  *src/app.tsx*
503
501
  ```typescript jsx
504
- import html from './protection.html'
502
+ import { GetPartners } from './GetPartners'
505
503
 
506
504
  export default (
507
505
  <server>
508
506
  <api>
509
- <protection
510
- maxAge={24 * 60 * 60}
511
- html={html}
512
- />
507
+ <endpoint method='get' path='/partners'>
508
+ <return>
509
+ <GetPartners />
510
+ </return>
511
+ </endpoint>
513
512
  </api>
514
513
  </server>
515
514
  )
516
515
  ```
517
516
 
518
- #### excludeIp
519
-
520
- This prop sets a list of IP addresses (split by `,`) to ignore the protection.
521
-
522
- You can use `PROTECTED_IP` env to set default `excludeIp`.
523
-
524
- *src/app.tsx*
517
+ *src/GetPartners.tsx*
525
518
  ```typescript jsx
526
- import html from './protection.html'
527
-
528
- export default (
529
- <server>
530
- <api>
531
- <protection
532
- excludeIp='0.0.0.0,127.0.0.0'
533
- html={html}
534
- />
535
- </api>
536
- </server>
519
+ export const GetPartners = () => (
520
+ <success>
521
+ {{partners: []}}
522
+ </success>
537
523
  )
538
524
  ```
539
525
 
540
- #### cookieKey
526
+ ### \<preset>
541
527
 
542
- This prop sets a cookie field name used to store protection of a user.
528
+ [← back](#main)
543
529
 
544
- By default, it equals `protection`.
545
- You can use `PROTECTION_COOKIE_KEY` env to set default `cookieKey`.
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.
546
534
 
547
535
  *src/app.tsx*
548
536
  ```typescript jsx
549
- import html from './protection.html'
550
-
551
537
  export default (
552
538
  <server>
553
- <api>
554
- <protection
555
- cookieKey='secret'
556
- html={html}
539
+ <preset>
540
+ <header
541
+ key='Test'
542
+ value='Ok'
557
543
  />
558
- </api>
544
+ </preset>
559
545
  </server>
560
546
  )
561
547
  ```
562
548
 
563
- #### searchKey
564
-
565
- This prop sets a search query field name used to check protection.
566
-
567
- By default, it equals `protection`.
568
- You can use `PROTECTION_SEARCH_KEY` env to set default `searchKey`.
549
+ Place the element inside [\<api>](#api) to preset it on the api requests scope.
569
550
 
570
551
  *src/app.tsx*
571
552
  ```typescript jsx
572
- import html from './protection.html'
573
-
574
553
  export default (
575
554
  <server>
576
- <api>
577
- <protection
578
- searchKey='secret'
579
- html={html}
580
- />
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>
581
568
  </api>
569
+ <return>
570
+ <success>
571
+ Header do not contain `Cache-Control`
572
+ </success>
573
+ </return>
582
574
  </server>
583
575
  )
584
576
  ```
585
577
 
586
- ## API Info
578
+ ## Utils
587
579
 
588
- The API information elements are here.
580
+ This section contains elements of utils.
589
581
 
590
582
  [← back](#index)
591
583
 
592
- [\<license>](#license)
593
- [\<contact>](#contact)
594
- [\<host>](#host)
595
- [\<variable>](#variable)
584
+ [\<ui>](#ui)
585
+ [\<env>](#env)
586
+ [\<dts>](#dts)
587
+ [\<blacklist>](#blacklist)
588
+ [\<whitelist>](#whitelist)
589
+ [\<protection>](#protection)
596
590
 
597
591
  ---
598
592
 
599
- ### \<license>
600
-
601
- [← back](#api-info)
602
-
603
- `<license>` element MUST be placed in `<api>` element.
604
- Use `<license>` element to define the API license.
593
+ ### \<ui>
605
594
 
606
- #### name
595
+ [← back](#utils)
607
596
 
608
- REQUIRED prop. The license name used for the API.
597
+ Use `<ui>` element to add API documentation UI. This element supports multiple documentation viewers including Swagger UI, RapiDoc, ReDoc, and Scalar.
598
+ `<ui>` element MUST be placed in `<api>` element.
609
599
 
610
600
  *src/app.tsx*
611
601
  ```typescript jsx
612
602
  export default (
613
603
  <server>
614
604
  <api>
615
- <license
616
- name='Apache 2.0'
617
- />
605
+ <ui />
618
606
  </api>
619
607
  </server>
620
608
  )
621
609
  ```
622
610
 
623
- #### identifier
611
+ Open http://localhost:80/ui
612
+ You will see Swagger UI documentation by default.
624
613
 
625
- An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
626
- The `identifier` field is mutually exclusive of the `url` prop.
614
+ #### html
615
+
616
+ You can provide custom HTML template for the documentation viewer.
617
+ Built-in presets are available: `uiPresets.swagger`, `uiPresets.rapidoc`, `uiPresets.redoc`, `uiPresets.scalar`.
627
618
 
628
619
  *src/app.tsx*
629
620
  ```typescript jsx
621
+ import { uiPresets } from '@innet/server'
622
+
630
623
  export default (
631
624
  <server>
632
625
  <api>
633
- <license
634
- name='Apache 2.0'
635
- identifier='Apache-2.0'
636
- />
626
+ <ui html={uiPresets.rapidoc} />
637
627
  </api>
638
628
  </server>
639
629
  )
640
630
  ```
641
631
 
642
- #### url
632
+ #### params
643
633
 
644
- A URL to the license used for the API.
645
- This MUST be in the form of a URL.
646
- The `url` field is mutually exclusive of the `identifier` field.
634
+ You can pass additional parameters to the documentation viewer. Parameters depend on the selected UI library.
635
+
636
+ For **Swagger UI** (default):
647
637
 
648
638
  *src/app.tsx*
649
639
  ```typescript jsx
650
640
  export default (
651
641
  <server>
652
642
  <api>
653
- <license
654
- name='Apache 2.0'
655
- url='https://www.apache.org/licenses/LICENSE-2.0.html'
643
+ <ui
644
+ params={{
645
+ docExpansion: 'full',
646
+ filter: true,
647
+ showExtensions: true,
648
+ }}
656
649
  />
657
650
  </api>
658
651
  </server>
659
652
  )
660
653
  ```
661
654
 
662
- ### \<contact>
663
-
664
- [← back](#api-info)
655
+ For **Scalar**:
665
656
 
666
- `<contact>` element MUST be placed in `<api>` element.
667
- The contact information for the exposed API.
657
+ *src/app.tsx*
658
+ ```typescript jsx
659
+ import { uiPresets } from '@innet/server'
668
660
 
669
- #### name
661
+ export default (
662
+ <server>
663
+ <api>
664
+ <ui
665
+ html={uiPresets.scalar}
666
+ params={{
667
+ theme: 'moon',
668
+ layout: 'classic',
669
+ }}
670
+ />
671
+ </api>
672
+ </server>
673
+ )
674
+ ```
670
675
 
671
- The identifying name of the contact person/organization.
676
+ For **RapiDoc**:
672
677
 
673
678
  *src/app.tsx*
674
679
  ```typescript jsx
680
+ import { uiPresets } from '@innet/server'
681
+
675
682
  export default (
676
683
  <server>
677
684
  <api>
678
- <contact name='Mike' />
685
+ <ui
686
+ html={uiPresets.rapidoc}
687
+ params={{
688
+ theme: 'dark',
689
+ layout: 'row',
690
+ showHeader: 'false',
691
+ }}
692
+ />
679
693
  </api>
680
694
  </server>
681
695
  )
682
696
  ```
683
697
 
684
- #### email
685
-
686
- The email address of the contact person/organization.
687
- This MUST be in the form of an email address.
698
+ For **ReDoc**:
688
699
 
689
700
  *src/app.tsx*
690
701
  ```typescript jsx
702
+ import { uiPresets } from '@innet/server'
703
+
691
704
  export default (
692
705
  <server>
693
706
  <api>
694
- <contact
695
- email='d8@cantinc.com'
707
+ <ui
708
+ html={uiPresets.redoc}
709
+ params={{
710
+ disableSearch: 'true',
711
+ hideDownloadButton: 'true',
712
+ nativeScrollbars: 'true',
713
+ theme: '{"sidebar": {"backgroundColor": "#d1e5ef"}}',
714
+ }}
696
715
  />
697
716
  </api>
698
717
  </server>
699
718
  )
700
719
  ```
701
720
 
702
- #### url
721
+ #### path
703
722
 
704
- The URL pointing to the contact information.
705
- This MUST be in the form of a URL.
723
+ You can change the documentation UI URL path by `path` property of `<ui>` element.
706
724
 
707
725
  *src/app.tsx*
708
726
  ```typescript jsx
709
727
  export default (
710
728
  <server>
711
729
  <api>
712
- <contact
713
- url='https://...'
714
- />
730
+ <ui path='/docs' />
715
731
  </api>
716
732
  </server>
717
733
  )
718
734
  ```
719
735
 
720
- ### \<host>
721
-
722
- [← back](#api-info)
723
-
724
- `<host>` element MUST be placed in `<api>` element.
736
+ *default: `INNET_UI_PATH` || `'/ui'`*
725
737
 
726
- This element adds a link to related documentation API.
727
- You can provide many stands like dev, stage or prod.
738
+ ### \<env>
728
739
 
729
- #### url
740
+ [← back](#utils)
730
741
 
731
- REQUIRED prop of URL to the target host.
742
+ This element helps to control content by `process.env`.
732
743
 
733
- This URL supports Server Variables and MAY be relative,
734
- to indicate that the host location is relative to the location where the OpenAPI document is being served.
735
- Variable substitutions will be made when a variable is named in {brackets}.
744
+ There are a required field of `is`.
745
+ If it's a `string` then an environment variable must be equal to the `string`.
746
+ If it's an `array of string` then an environment variable must be included into the `array of string`.
736
747
 
737
748
  *src/app.tsx*
738
749
  ```typescript jsx
739
750
  export default (
740
751
  <server>
741
752
  <api>
742
- <host
743
- url='https://your.address/api'
744
- />
753
+ <env is='dev'>
754
+ <swagger />
755
+ </env>
745
756
  </api>
746
757
  </server>
747
758
  )
748
759
  ```
749
760
 
750
- #### description
761
+ *The `<swagger />` will work only if `NODE_ENV` equals `dev`*
751
762
 
752
- An optional string describing the host designated by the URL.
753
- [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
763
+ #### of
764
+
765
+ By default `of` equals `NODE_ENV`. You can check eny other environment variable.
754
766
 
755
767
  *src/app.tsx*
756
768
  ```typescript jsx
757
769
  export default (
758
770
  <server>
759
771
  <api>
760
- <host
761
- url='https://your.address/api'
762
- description='Production server'
763
- />
772
+ <env
773
+ of='PORT'
774
+ is={[
775
+ '3000',
776
+ '8080',
777
+ ]}>
778
+ <swagger />
779
+ </env>
764
780
  </api>
765
781
  </server>
766
782
  )
767
783
  ```
768
784
 
769
- ### \<variable>
785
+ ### \<dts>
770
786
 
771
- [← back](#api-info)
787
+ [← back](#utils)
772
788
 
773
- This element MUST be placed in `<host>` element and defines a variable from the `<host>`.
789
+ Use `<dts>` element to add types generation.
790
+ `<dts>` element MUST be placed in `<api>` element.
774
791
 
775
- #### key
792
+ *src/app.tsx*
793
+ ```typescript jsx
794
+ export default (
795
+ <server>
796
+ <api>
797
+ <dts />
798
+ </api>
799
+ </server>
800
+ )
801
+ ```
776
802
 
777
- REQUIRED props. `key` is a server url parameter.
803
+ You do not need to import types, use `Api` namespace everywhere.
804
+ Here is an example of generated types usage.
805
+
806
+ ```typescript jsx
807
+ import { useParams } from '@innet/server'
808
+
809
+ import { todos } from '../todos'
810
+
811
+ export function DeleteTodo () {
812
+ const { todoId } = useParams<Api.Endpoints['DELETE:/todos/{todoId}']['Params']>()
813
+
814
+ const todoIndex = todos.findIndex(({ id }) => id === todoId)
815
+
816
+ if (todoIndex === -1) {
817
+ return <error code='todoNotFound' status={404} />
818
+ }
819
+
820
+ todos.splice(todoIndex, 1)
821
+
822
+ return <success />
823
+ }
824
+ ```
825
+
826
+ #### path
827
+
828
+ This is a path of api TypeScript types file, `<dts>` generates it.
829
+ `'src/api.d.ts'` by default.
778
830
 
779
831
  *src/app.tsx*
780
832
  ```typescript jsx
781
833
  export default (
782
834
  <server>
783
835
  <api>
784
- <host
785
- url='https://{env}.your.address/api'
786
- description='Test servers'>
787
- <variable key='env' />
788
- </host>
836
+ <dts path='src/types.d.ts' />
789
837
  </api>
790
838
  </server>
791
839
  )
792
840
  ```
793
841
 
794
- #### value
842
+ #### namespace
795
843
 
796
- The `value` prop uses for substitution by default.
797
- If the `values` is defined, the `value` MUST exist in the `values`.
844
+ This prop changes namespace for generated types. `'Api'` by default.
798
845
 
799
846
  *src/app.tsx*
800
847
  ```typescript jsx
801
848
  export default (
802
849
  <server>
803
850
  <api>
804
- <host
805
- url='https://{env}.your.address/api'
806
- description='Test servers'>
807
- <variable
808
- key='env'
809
- value='stage'
810
- />
811
- </host>
851
+ <dts namespace='API' />
812
852
  </api>
813
853
  </server>
814
854
  )
815
855
  ```
816
856
 
817
- #### values
857
+ ### \<blacklist>
818
858
 
819
- An enumeration of string values to be used if the substitution options are from a limited set.
820
- The array MUST NOT be empty.
859
+ This element MUST be placed in `<api>` element.
860
+
861
+ [← back](#utils)
862
+
863
+ This element returns own content for a user from IPs list.
821
864
 
822
865
  *src/app.tsx*
823
866
  ```typescript jsx
824
867
  export default (
825
868
  <server>
826
869
  <api>
827
- <host
828
- url='https://{env}.your.address/api'
829
- description='Test servers'>
830
- <variable
831
- key='env'
832
- values={[
833
- 'stage',
834
- 'dev',
835
- 'qa',
836
- ]}
837
- />
838
- </host>
870
+ <blacklist>
871
+ <error />
872
+ </blacklist>
839
873
  </api>
840
874
  </server>
841
875
  )
842
876
  ```
843
877
 
844
- #### description
878
+ #### ip
845
879
 
846
- An optional description for the server variable.
847
- [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
880
+ `ip` prop sets black IPs. By default, it equals `INNET_BLACKLIST_IP` node environment variable.
881
+
882
+ You can split IPs by `,` char.
848
883
 
849
884
  *src/app.tsx*
850
885
  ```typescript jsx
851
886
  export default (
852
887
  <server>
853
888
  <api>
854
- <host
855
- url='https://{env}.your.address/api'
856
- description='Test servers'>
857
- <variable
858
- key='env'
859
- values={[
860
- 'stage',
861
- 'dev',
862
- 'qa',
863
- ]}
864
- description='Server environment'
865
- />
866
- </host>
889
+ <blacklist
890
+ ip='0.1.2.3,3.2.1.0'>
891
+ <error />
892
+ </blacklist>
867
893
  </api>
868
894
  </server>
869
895
  )
870
896
  ```
871
897
 
872
- ## Endpoints
898
+ ### \<whitelist>
873
899
 
874
- [← back](#index)
900
+ This element MUST be placed in `<api>` element.
875
901
 
876
- [\<endpoint>](#endpoint)
877
- [\<tag>](#tag)
878
- [\<param>](#param)
879
- [\<body>](#body)
880
- [\<response>](#response)
902
+ [← back](#utils)
881
903
 
882
- ---
904
+ This element returns own content for a user IP, which is not in a list.
883
905
 
884
- ### \<endpoint>
906
+ *src/app.tsx*
907
+ ```typescript jsx
908
+ export default (
909
+ <server>
910
+ <api>
911
+ <whitelist>
912
+ <error />
913
+ </whitelist>
914
+ </api>
915
+ </server>
916
+ )
917
+ ```
885
918
 
886
- [← back](#endpoints)
919
+ #### ip
887
920
 
888
- `<endpoint>` defines an endpoint of the API and MUST be placed in `<api>`.
921
+ `ip` prop sets white IPs. By default, it equals `INNET_WHITELIST_IP` node environment variable.
889
922
 
890
- `<api>` uses a specific algorithm to find expected endpoint.
923
+ You can split IPs by `,` char.
891
924
 
892
- It does no matter how many endpoints you have.
893
- It depends on the deep of path pieces.
894
- If you have the deep equals 1 (`/users`, `/user`, `/login`, `/logout`) the endpoint will be found immediately O(1).
925
+ *src/app.tsx*
926
+ ```typescript jsx
927
+ export default (
928
+ <server>
929
+ <api>
930
+ <whitelist
931
+ ip='0.1.2.3,3.2.1.0'>
932
+ <error />
933
+ </whitelist>
934
+ </api>
935
+ </server>
936
+ )
937
+ ```
895
938
 
896
- #### method
939
+ ### \<protection>
897
940
 
898
- A method of the endpoint.
941
+ This element MUST be placed in `<api>` element.
899
942
 
900
- MUST be one of `'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head' | 'trace'`
943
+ [← back](#utils)
901
944
 
902
- #### path
945
+ This element adds protection page.
946
+ You can use it when you want to protect your application.
903
947
 
904
- A relative path to an individual endpoint.
948
+ If protection failed content of the element should be used.
905
949
 
906
- The property MUST begin with a forward slash (/).
950
+ *src/app.tsx*
951
+ ```typescript jsx
952
+ export default (
953
+ <server>
954
+ <api>
955
+ <protection>
956
+ <error
957
+ code='protection'
958
+ status='forbidden'
959
+ />
960
+ </protection>
961
+ </api>
962
+ </server>
963
+ )
964
+ ```
907
965
 
908
- Path templating is allowed.
966
+ #### value
909
967
 
910
- When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
911
- Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
968
+ This prop is a secret string of protection value.
969
+ User must provide a protection query param equals the `value`.
970
+
971
+ By default, the value is `undefined` and protection does not work.
972
+ You can use `PROTECTION` env to set default protection `value`.
912
973
 
913
974
  *src/app.tsx*
914
975
  ```typescript jsx
915
976
  export default (
916
977
  <server>
917
978
  <api>
918
- <endpoint
919
- method='get'
920
- path='/users'
921
- />
979
+ <protection value='secret'>
980
+ <error
981
+ code='protection'
982
+ status='forbidden'
983
+ />
984
+ </protection>
922
985
  </api>
923
986
  </server>
924
987
  )
925
988
  ```
926
989
 
927
- #### summary
990
+ #### maxAge
928
991
 
929
- An optional, string summary, intended to apply to all operations in this path.
992
+ This prop sets how much time protection is qualified.
993
+
994
+ By default, the prop equals a year.
995
+ You can use `INNET_PROTECTION_MAX_AGE` env to set default `maxAge`.
930
996
 
931
997
  *src/app.tsx*
932
998
  ```typescript jsx
933
999
  export default (
934
1000
  <server>
935
1001
  <api>
936
- <endpoint
937
- method='get'
938
- path='/users'
939
- summary='Returns users'
940
- />
1002
+ <protection
1003
+ maxAge={24 * 60 * 60}
1004
+ value='secret'>
1005
+ <error
1006
+ code='protection'
1007
+ status='forbidden'
1008
+ />
1009
+ </protection>
941
1010
  </api>
942
1011
  </server>
943
1012
  )
944
1013
  ```
945
1014
 
946
- #### description
1015
+ #### excludeIp
947
1016
 
948
- An optional, string description, intended to apply to all operations in this path.
949
- [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
1017
+ This prop sets a list of IP addresses (split by `,`) to ignore the protection.
1018
+
1019
+ You can use `INNET_PROTECTED_IP` env to set default `excludeIp`.
950
1020
 
951
1021
  *src/app.tsx*
952
1022
  ```typescript jsx
953
1023
  export default (
954
1024
  <server>
955
1025
  <api>
956
- <endpoint
957
- method='get'
958
- path='/users'
959
- description='Users list query'
960
- />
1026
+ <protection
1027
+ excludeIp='0.0.0.0,127.0.0.0'
1028
+ value='secret'>
1029
+ <error
1030
+ code='protection'
1031
+ status='forbidden'
1032
+ />
1033
+ </protection>
961
1034
  </api>
962
1035
  </server>
963
1036
  )
964
1037
  ```
965
1038
 
966
- #### deprecated
1039
+ #### cookieKey
967
1040
 
968
- Declares this operation to be deprecated.
969
- Consumers SHOULD refrain from usage of the declared operation.
970
- Default value is `false`.
1041
+ This prop sets a cookie field name used to store protection of a user.
1042
+
1043
+ By default, it equals `protection`.
1044
+ You can use `INNET_PROTECTION_COOKIE_KEY` env to set default `cookieKey`.
971
1045
 
972
1046
  *src/app.tsx*
973
1047
  ```typescript jsx
974
1048
  export default (
975
1049
  <server>
976
1050
  <api>
977
- <endpoint
978
- method='get'
979
- path='/users'
980
- deprecated
981
- />
1051
+ <protection
1052
+ cookieKey='secret'
1053
+ value='secret'>
1054
+ <error
1055
+ code='protection'
1056
+ status='forbidden'
1057
+ />
1058
+ </protection>
982
1059
  </api>
983
1060
  </server>
984
1061
  )
985
1062
  ```
986
1063
 
987
- #### private
1064
+ #### searchKey
988
1065
 
989
- Declares this operation to make an endpoint private.
990
- That means the endpoint should not be described and will not be shown in the Open API documentation.
1066
+ This prop sets a search query field name used to check protection.
1067
+
1068
+ By default, it equals `protection`.
1069
+ You can use `INNET_PROTECTION_SEARCH_KEY` env to set default `searchKey`.
991
1070
 
992
1071
  *src/app.tsx*
993
1072
  ```typescript jsx
994
1073
  export default (
995
1074
  <server>
996
1075
  <api>
997
- <endpoint
998
- method='get'
999
- path='/users'
1000
- private
1001
- />
1076
+ <protection
1077
+ searchKey='secret'
1078
+ value='secret'>
1079
+ <error
1080
+ code='protection'
1081
+ status='forbidden'
1082
+ />
1083
+ </protection>
1002
1084
  </api>
1003
1085
  </server>
1004
1086
  )
1005
1087
  ```
1006
1088
 
1007
- ### \<tag>
1089
+ ## API Info
1008
1090
 
1009
- [← back](#endpoints)
1091
+ The API information elements are here.
1010
1092
 
1011
- You can wrap endpoints by `<tag>` element to group the endpoints.
1012
- You can see the changes in Swagger UI.
1093
+ [← back](#index)
1094
+
1095
+ [\<license>](#license)
1096
+ [\<contact>](#contact)
1097
+ [\<host>](#host)
1098
+ [\<variable>](#variable)
1099
+
1100
+ ---
1101
+
1102
+ ### \<license>
1103
+
1104
+ [← back](#api-info)
1105
+
1106
+ `<license>` element MUST be placed in `<api>` element.
1107
+ Use `<license>` element to define the API license.
1108
+
1109
+ #### name
1110
+
1111
+ REQUIRED prop. The license name used for the API.
1112
+
1113
+ *src/app.tsx*
1114
+ ```typescript jsx
1115
+ export default (
1116
+ <server>
1117
+ <api>
1118
+ <license
1119
+ name='Apache 2.0'
1120
+ />
1121
+ </api>
1122
+ </server>
1123
+ )
1124
+ ```
1125
+
1126
+ #### identifier
1127
+
1128
+ An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
1129
+ The `identifier` field is mutually exclusive of the `url` prop.
1130
+
1131
+ *src/app.tsx*
1132
+ ```typescript jsx
1133
+ export default (
1134
+ <server>
1135
+ <api>
1136
+ <license
1137
+ name='Apache 2.0'
1138
+ identifier='Apache-2.0'
1139
+ />
1140
+ </api>
1141
+ </server>
1142
+ )
1143
+ ```
1144
+
1145
+ #### url
1146
+
1147
+ A URL to the license used for the API.
1148
+ This MUST be in the form of a URL.
1149
+ The `url` field is mutually exclusive of the `identifier` field.
1150
+
1151
+ *src/app.tsx*
1152
+ ```typescript jsx
1153
+ export default (
1154
+ <server>
1155
+ <api>
1156
+ <license
1157
+ name='Apache 2.0'
1158
+ url='https://www.apache.org/licenses/LICENSE-2.0.html'
1159
+ />
1160
+ </api>
1161
+ </server>
1162
+ )
1163
+ ```
1164
+
1165
+ ### \<contact>
1166
+
1167
+ [← back](#api-info)
1168
+
1169
+ `<contact>` element MUST be placed in `<api>` element.
1170
+ The contact information for the exposed API.
1171
+
1172
+ #### name
1173
+
1174
+ The identifying name of the contact person/organization.
1175
+
1176
+ *src/app.tsx*
1177
+ ```typescript jsx
1178
+ export default (
1179
+ <server>
1180
+ <api>
1181
+ <contact name='Mike' />
1182
+ </api>
1183
+ </server>
1184
+ )
1185
+ ```
1186
+
1187
+ #### email
1188
+
1189
+ The email address of the contact person/organization.
1190
+ This MUST be in the form of an email address.
1191
+
1192
+ *src/app.tsx*
1193
+ ```typescript jsx
1194
+ export default (
1195
+ <server>
1196
+ <api>
1197
+ <contact
1198
+ email='d8@cantinc.com'
1199
+ />
1200
+ </api>
1201
+ </server>
1202
+ )
1203
+ ```
1204
+
1205
+ #### url
1206
+
1207
+ The URL pointing to the contact information.
1208
+ This MUST be in the form of a URL.
1209
+
1210
+ *src/app.tsx*
1211
+ ```typescript jsx
1212
+ export default (
1213
+ <server>
1214
+ <api>
1215
+ <contact
1216
+ url='https://...'
1217
+ />
1218
+ </api>
1219
+ </server>
1220
+ )
1221
+ ```
1222
+
1223
+ ### \<host>
1224
+
1225
+ [← back](#api-info)
1226
+
1227
+ `<host>` element MUST be placed in `<api>` element.
1228
+
1229
+ This element adds a link to related documentation API.
1230
+ You can provide many stands like dev, stage or prod.
1231
+
1232
+ #### url
1233
+
1234
+ REQUIRED prop of URL to the target host.
1235
+
1236
+ This URL supports Server Variables and MAY be relative,
1237
+ to indicate that the host location is relative to the location where the OpenAPI document is being served.
1238
+ Variable substitutions will be made when a variable is named in {brackets}.
1239
+
1240
+ *src/app.tsx*
1241
+ ```typescript jsx
1242
+ export default (
1243
+ <server>
1244
+ <api>
1245
+ <host
1246
+ url='https://your.address/api'
1247
+ />
1248
+ </api>
1249
+ </server>
1250
+ )
1251
+ ```
1252
+
1253
+ #### description
1254
+
1255
+ An optional string describing the host designated by the URL.
1256
+ [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
1257
+
1258
+ *src/app.tsx*
1259
+ ```typescript jsx
1260
+ export default (
1261
+ <server>
1262
+ <api>
1263
+ <host
1264
+ url='https://your.address/api'
1265
+ description='Production server'
1266
+ />
1267
+ </api>
1268
+ </server>
1269
+ )
1270
+ ```
1271
+
1272
+ ### \<variable>
1273
+
1274
+ [← back](#api-info)
1275
+
1276
+ This element MUST be placed in `<host>` element and defines a variable from the `<host>`.
1277
+
1278
+ #### key
1279
+
1280
+ REQUIRED props. `key` is a server url parameter.
1281
+
1282
+ *src/app.tsx*
1283
+ ```typescript jsx
1284
+ export default (
1285
+ <server>
1286
+ <api>
1287
+ <host
1288
+ url='https://{env}.your.address/api'
1289
+ description='Test servers'>
1290
+ <variable key='env' />
1291
+ </host>
1292
+ </api>
1293
+ </server>
1294
+ )
1295
+ ```
1296
+
1297
+ #### value
1298
+
1299
+ The `value` prop uses for substitution by default.
1300
+ If the `values` is defined, the `value` MUST exist in the `values`.
1301
+
1302
+ *src/app.tsx*
1303
+ ```typescript jsx
1304
+ export default (
1305
+ <server>
1306
+ <api>
1307
+ <host
1308
+ url='https://{env}.your.address/api'
1309
+ description='Test servers'>
1310
+ <variable
1311
+ key='env'
1312
+ value='stage'
1313
+ />
1314
+ </host>
1315
+ </api>
1316
+ </server>
1317
+ )
1318
+ ```
1319
+
1320
+ #### values
1321
+
1322
+ An enumeration of string values to be used if the substitution options are from a limited set.
1323
+ The array MUST NOT be empty.
1324
+
1325
+ *src/app.tsx*
1326
+ ```typescript jsx
1327
+ export default (
1328
+ <server>
1329
+ <api>
1330
+ <host
1331
+ url='https://{env}.your.address/api'
1332
+ description='Test servers'>
1333
+ <variable
1334
+ key='env'
1335
+ values={[
1336
+ 'stage',
1337
+ 'dev',
1338
+ 'qa',
1339
+ ]}
1340
+ />
1341
+ </host>
1342
+ </api>
1343
+ </server>
1344
+ )
1345
+ ```
1346
+
1347
+ #### description
1348
+
1349
+ An optional description for the server variable.
1350
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
1351
+
1352
+ *src/app.tsx*
1353
+ ```typescript jsx
1354
+ export default (
1355
+ <server>
1356
+ <api>
1357
+ <host
1358
+ url='https://{env}.your.address/api'
1359
+ description='Test servers'>
1360
+ <variable
1361
+ key='env'
1362
+ values={[
1363
+ 'stage',
1364
+ 'dev',
1365
+ 'qa',
1366
+ ]}
1367
+ description='Server environment'
1368
+ />
1369
+ </host>
1370
+ </api>
1371
+ </server>
1372
+ )
1373
+ ```
1374
+
1375
+ ## Endpoints
1376
+
1377
+ [← back](#index)
1378
+
1379
+ [\<endpoint>](#endpoint)
1380
+ [\<tag>](#tag)
1381
+ [\<param>](#param)
1382
+ [\<body>](#body)
1383
+ [\<response>](#response)
1384
+
1385
+ ---
1386
+
1387
+ ### \<endpoint>
1388
+
1389
+ [← back](#endpoints)
1390
+
1391
+ `<endpoint>` defines an endpoint of the API and MUST be placed in `<api>`.
1392
+
1393
+ `<api>` uses a specific algorithm to find expected endpoint.
1394
+
1395
+ It does no matter how many endpoints you have.
1396
+ It depends on the deep of path pieces.
1397
+ If you have the deep equals 1 (`/users`, `/user`, `/login`, `/logout`) the endpoint will be found immediately O(1).
1398
+
1399
+ #### method
1400
+
1401
+ A method of the endpoint.
1402
+
1403
+ MUST be one of `'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head' | 'trace'`
1404
+
1405
+ #### path
1406
+
1407
+ A relative path to an individual endpoint.
1408
+
1409
+ The property MUST begin with a forward slash (/).
1410
+
1411
+ Path templating is allowed.
1412
+
1413
+ When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
1414
+ Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
1415
+
1416
+ *src/app.tsx*
1417
+ ```typescript jsx
1418
+ export default (
1419
+ <server>
1420
+ <api>
1421
+ <endpoint
1422
+ method='get'
1423
+ path='/users'
1424
+ />
1425
+ </api>
1426
+ </server>
1427
+ )
1428
+ ```
1429
+
1430
+ #### summary
1431
+
1432
+ An optional, string summary, intended to apply to all operations in this path.
1433
+
1434
+ *src/app.tsx*
1435
+ ```typescript jsx
1436
+ export default (
1437
+ <server>
1438
+ <api>
1439
+ <endpoint
1440
+ method='get'
1441
+ path='/users'
1442
+ summary='Returns users'
1443
+ />
1444
+ </api>
1445
+ </server>
1446
+ )
1447
+ ```
1448
+
1449
+ #### description
1450
+
1451
+ An optional, string description, intended to apply to all operations in this path.
1452
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
1453
+
1454
+ *src/app.tsx*
1455
+ ```typescript jsx
1456
+ export default (
1457
+ <server>
1458
+ <api>
1459
+ <endpoint
1460
+ method='get'
1461
+ path='/users'
1462
+ description='Users list query'
1463
+ />
1464
+ </api>
1465
+ </server>
1466
+ )
1467
+ ```
1468
+
1469
+ #### deprecated
1470
+
1471
+ Declares this operation to be deprecated.
1472
+ Consumers SHOULD refrain from usage of the declared operation.
1473
+ Default value is `false`.
1474
+
1475
+ *src/app.tsx*
1476
+ ```typescript jsx
1477
+ export default (
1478
+ <server>
1479
+ <api>
1480
+ <endpoint
1481
+ method='get'
1482
+ path='/users'
1483
+ deprecated
1484
+ />
1485
+ </api>
1486
+ </server>
1487
+ )
1488
+ ```
1489
+
1490
+ #### private
1491
+
1492
+ Declares this operation to make an endpoint private.
1493
+ That means the endpoint should not be described and will not be shown in the Open API documentation.
1494
+
1495
+ *src/app.tsx*
1496
+ ```typescript jsx
1497
+ export default (
1498
+ <server>
1499
+ <api>
1500
+ <endpoint
1501
+ method='get'
1502
+ path='/users'
1503
+ private
1504
+ />
1505
+ </api>
1506
+ </server>
1507
+ )
1508
+ ```
1509
+
1510
+ #### operationId
1511
+
1512
+ `operationId` is an optional unique string used to identify an operation.
1513
+ If provided, these IDs must be unique among all operations described in your API.
1514
+
1515
+ Tools and libraries MAY use the operationId to uniquely identify an operation, therefore, it is recommended to follow common programming naming conventions.
1516
+
1517
+ *src/app.tsx*
1518
+ ```typescript jsx
1519
+ export default (
1520
+ <server>
1521
+ <api>
1522
+ <endpoint
1523
+ method='get'
1524
+ path='/users'
1525
+ operationId='getUsers'
1526
+ />
1527
+ </api>
1528
+ </server>
1529
+ )
1530
+ ```
1531
+
1532
+ ### \<tag>
1533
+
1534
+ [← back](#endpoints)
1535
+
1536
+ You can wrap endpoints by `<tag>` element to group the endpoints.
1537
+ You can see the changes in Swagger UI.
1538
+
1539
+ *src/app.tsx*
1540
+ ```typescript jsx
1541
+ export default (
1542
+ <server>
1543
+ <api>
1544
+ <tag name='user'>
1545
+ <endpoint
1546
+ method='get'
1547
+ path='/users'
1548
+ />
1549
+ <endpoint
1550
+ method='post'
1551
+ path='/users'
1552
+ />
1553
+ </tag>
1554
+ </api>
1555
+ </server>
1556
+ )
1557
+ ```
1558
+
1559
+ #### group
1560
+
1561
+ You can organize tags into groups using the `group` property.
1562
+ This adds tag groups support to the OpenAPI specification,
1563
+ which is displayed in documentation viewers.
1564
+
1565
+ *src/app.tsx*
1566
+ ```typescript jsx
1567
+ export default (
1568
+ <server>
1569
+ <api>
1570
+ <tag group='Authentication' name='auth'>
1571
+ <endpoint method='post' path='/login' />
1572
+ <endpoint method='post' path='/logout' />
1573
+ </tag>
1574
+ <tag group='Users' name='users'>
1575
+ <endpoint method='get' path='/users' />
1576
+ <endpoint method='post' path='/users' />
1577
+ </tag>
1578
+ </api>
1579
+ </server>
1580
+ )
1581
+ ```
1582
+
1583
+ This will create tag groups in your OpenAPI documentation:
1584
+ - **Authentication** group containing the `auth` tag
1585
+ - **Users** group containing the `users` tag
1586
+
1587
+ ### \<param>
1588
+
1589
+ [← back](#endpoints)
1590
+
1591
+ Describes a single operation parameter.
1592
+
1593
+ A unique parameter is defined by a combination of a `name` and location.
1594
+
1595
+ ##### Parameter Locations
1596
+
1597
+ There are four possible parameter locations specified by the `in` prop:
1598
+
1599
+ - **path** - Used together with [Path Templating](https://swagger.io/specification/#path-templating), where the parameter value is actually part of the operation's URL.
1600
+ This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`.
1601
+ - **query** - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
1602
+ - **header** - Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
1603
+ - **cookie** - Used to pass a specific cookie value to the API.
1604
+
1605
+ #### in
1606
+
1607
+ The location of the parameter.
1608
+ Possible values are `"query"`, `"header"`, `"path"` or `"cookie"`.
1609
+
1610
+ #### name
1611
+
1612
+ The name of the parameter. Parameter names are *case sensitive*.
1613
+
1614
+ - If `in` is "path", the `name` field MUST correspond to a template expression occurring within the `path` field in the `endpoint`. See [Path Templating](https://swagger.io/specification/#path-templating) for further information.
1615
+ - If `in` is "header" and the `name` field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
1616
+ - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
1617
+
1618
+ *src/app.tsx*
1619
+ ```typescript jsx
1620
+ export default (
1621
+ <server>
1622
+ <api>
1623
+ <endpoint method='get' path='/users/{userId}'>
1624
+ <param in='path' name='userId' />
1625
+ </endpoint>
1626
+ </api>
1627
+ </server>
1628
+ )
1629
+ ```
1630
+
1631
+ #### description
1632
+
1633
+ A brief description of the parameter.
1634
+ This could contain examples of use.
1635
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
1636
+
1637
+ *src/app.tsx*
1638
+ ```typescript jsx
1639
+ export default (
1640
+ <server>
1641
+ <api>
1642
+ <endpoint method='get' path='/users/{userId}'>
1643
+ <param
1644
+ in='path'
1645
+ name='userId'
1646
+ description='User identification number'
1647
+ />
1648
+ </endpoint>
1649
+ </api>
1650
+ </server>
1651
+ )
1652
+ ```
1653
+
1654
+ #### required
1655
+
1656
+ Determines whether this parameter is mandatory.
1657
+ If the parameter location is "path", this property is `true` and its value MUST be `true`.
1658
+ Otherwise, the property MAY be included and its default value is `false`.
1659
+
1660
+ *src/app.tsx*
1661
+ ```typescript jsx
1662
+ export default (
1663
+ <server>
1664
+ <api>
1665
+ <endpoint method='get' path='/users'>
1666
+ <param
1667
+ in='cookie'
1668
+ name='token'
1669
+ required
1670
+ />
1671
+ </endpoint>
1672
+ </api>
1673
+ </server>
1674
+ )
1675
+ ```
1676
+
1677
+ #### deprecated
1678
+
1679
+ Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
1680
+ Default value is `false`.
1681
+
1682
+ *src/app.tsx*
1683
+ ```typescript jsx
1684
+ export default (
1685
+ <server>
1686
+ <api>
1687
+ <endpoint method='get' path='/users'>
1688
+ <param
1689
+ in='query'
1690
+ name='status'
1691
+ deprecated
1692
+ />
1693
+ </endpoint>
1694
+ </api>
1695
+ </server>
1696
+ )
1697
+ ```
1698
+
1699
+ ### \<body>
1700
+
1701
+ [← back](#endpoints)
1702
+
1703
+ This element MUST be placed inside `<endpoint>`.
1704
+ It defines request body for the endpoint.
1705
+ `@innet/server` formats and validate the value automatically (real-time).
1706
+
1707
+ *src/app.tsx*
1708
+ ```typescript jsx
1709
+ return (
1710
+ <server>
1711
+ <api>
1712
+ <endpoint method='post' path='/partners'>
1713
+ <body>
1714
+ <object>
1715
+ <field key='name'>
1716
+ <string example='CANTent.' />
1717
+ </field>
1718
+ <field key='gift'>
1719
+ <boolean />
1720
+ </field>
1721
+ <field optional key='addresses'>
1722
+ <array>
1723
+ <number description='address id' />
1724
+ </array>
1725
+ </field>
1726
+ </object>
1727
+ </body>
1728
+ </endpoint>
1729
+ </api>
1730
+ </server>
1731
+ )
1732
+ ```
1733
+
1734
+ ### \<response>
1735
+
1736
+ [← back](#endpoints)
1737
+
1738
+ This element MUST be placed inside `<endpoint>`.
1739
+ It defines response body for the endpoint.
1740
+
1741
+ *src/app.tsx*
1742
+ ```typescript jsx
1743
+ return (
1744
+ <server>
1745
+ <api>
1746
+ <endpoint method='get' path='/settings'>
1747
+ <response>
1748
+ <object />
1749
+ </response>
1750
+ </endpoint>
1751
+ </api>
1752
+ </server>
1753
+ )
1754
+ ```
1755
+
1756
+ #### status
1757
+ A status of the `<response>`.
1758
+ Any [HTTP status code](https://swagger.io/specification/#http-codes) can be used as a number of the property.
1759
+
1760
+ By default, `status` equals `'default'`.
1761
+
1762
+ *src/app.tsx*
1763
+ ```typescript jsx
1764
+ return (
1765
+ <server>
1766
+ <api>
1767
+ <endpoint method='get' path='/settings'>
1768
+ <response status={200}>
1769
+ <object />
1770
+ </response>
1771
+ </endpoint>
1772
+ </api>
1773
+ </server>
1774
+ )
1775
+ ```
1776
+
1777
+ To define a range of response codes, this field MAY contain the uppercase wildcard character `X`.
1778
+ For example, `2XX` represents all response codes between \[200-299].
1779
+ Only the following range definitions are allowed: `1XX`, `2XX`, `3XX`, `4XX` and `5XX`.
1780
+
1781
+ *src/app.tsx*
1782
+ ```typescript jsx
1783
+ return (
1784
+ <server>
1785
+ <api>
1786
+ <endpoint method='get' path='/settings'>
1787
+ <response status='2XX'>
1788
+ <object />
1789
+ </response>
1790
+ </endpoint>
1791
+ </api>
1792
+ </server>
1793
+ )
1794
+ ```
1795
+
1796
+ Many number statuses have a string id you can use on the property.
1797
+
1798
+ *src/app.tsx*
1799
+ ```typescript jsx
1800
+ return (
1801
+ <server>
1802
+ <api>
1803
+ <endpoint method='get' path='/settings'>
1804
+ <response status='notFound'>
1805
+ <object />
1806
+ </response>
1807
+ </endpoint>
1808
+ </api>
1809
+ </server>
1810
+ )
1811
+ ```
1812
+
1813
+ You can use many `<response>` elements in an endpoint.
1814
+
1815
+ *src/app.tsx*
1816
+ ```typescript jsx
1817
+ return (
1818
+ <server>
1819
+ <api>
1820
+ <endpoint method='get' path='/settings'>
1821
+ <response status='2XX'>
1822
+ <object />
1823
+ </response>
1824
+ <response status='4XX'>
1825
+ <object>
1826
+ <field key='error'>
1827
+ <string />
1828
+ </field>
1829
+ <field optional key='data'>
1830
+ <object />
1831
+ </field>
1832
+ </object>
1833
+ </response>
1834
+ </endpoint>
1835
+ </api>
1836
+ </server>
1837
+ )
1838
+ ```
1839
+
1840
+ #### type
1841
+ A media type of the `<response>`.
1842
+
1843
+ By default, `type` equals `'application/json'`.
1013
1844
 
1014
1845
  *src/app.tsx*
1015
1846
  ```typescript jsx
1016
- export default (
1847
+ return (
1017
1848
  <server>
1018
1849
  <api>
1019
- <tag name='user'>
1020
- <endpoint
1021
- method='get'
1022
- path='/users'
1023
- />
1024
- <endpoint
1025
- method='post'
1026
- path='/users'
1027
- />
1028
- </tag>
1850
+ <endpoint method='get' path='/hello'>
1851
+ <response type='text/html'>
1852
+ Hello World!
1853
+ </response>
1854
+ </endpoint>
1029
1855
  </api>
1030
1856
  </server>
1031
1857
  )
1032
1858
  ```
1033
1859
 
1034
- ### \<param>
1035
-
1036
- [← back](#endpoints)
1037
-
1038
- Describes a single operation parameter.
1039
-
1040
- A unique parameter is defined by a combination of a `name` and location.
1041
-
1042
- ##### Parameter Locations
1043
-
1044
- There are four possible parameter locations specified by the `in` prop:
1860
+ ## Primitive Data
1045
1861
 
1046
- - **path** - Used together with [Path Templating](https://swagger.io/specification/#path-templating), where the parameter value is actually part of the operation's URL.
1047
- This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`.
1048
- - **query** - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
1049
- - **header** - Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
1050
- - **cookie** - Used to pass a specific cookie value to the API.
1862
+ [ back](#index)
1051
1863
 
1052
- #### in
1864
+ [\<any>](#any)
1865
+ [\<null>](#null)
1866
+ [\<boolean>](#boolean)
1867
+ [\<string>](#string)
1868
+ [\<number>](#number)
1869
+ [\<integer>](#integer)
1870
+ [\<date>](#date)
1871
+ [\<uuid>](#uuid)
1872
+ [\<binary>](#binary)
1053
1873
 
1054
- The location of the parameter.
1055
- Possible values are `"query"`, `"header"`, `"path"` or `"cookie"`.
1874
+ ---
1056
1875
 
1057
- #### name
1876
+ ### \<any>
1058
1877
 
1059
- The name of the parameter. Parameter names are *case sensitive*.
1878
+ [← back](#primitive-data)
1060
1879
 
1061
- - If `in` is "path", the `name` field MUST correspond to a template expression occurring within the `path` field in the `endpoint`. See [Path Templating](https://swagger.io/specification/#path-templating) for further information.
1062
- - If `in` is "header" and the `name` field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
1063
- - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
1880
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1881
+ It defines `any` value for a parent element.
1882
+ `@innet/server` formats and validate the value automatically (real-time).
1064
1883
 
1065
1884
  *src/app.tsx*
1066
1885
  ```typescript jsx
1067
1886
  export default (
1068
1887
  <server>
1069
1888
  <api>
1070
- <endpoint method='get' path='/users/{userId}'>
1071
- <param in='path' name='userId' />
1889
+ <endpoint method='get' path='/todos'>
1890
+ <param
1891
+ in='query'
1892
+ name='search'>
1893
+ <any />
1894
+ </param>
1072
1895
  </endpoint>
1073
1896
  </api>
1074
1897
  </server>
1075
1898
  )
1076
1899
  ```
1077
1900
 
1078
- #### description
1901
+ #### default
1079
1902
 
1080
- A brief description of the parameter.
1081
- This could contain examples of use.
1082
- [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
1903
+ A default value for the `any`.
1083
1904
 
1084
1905
  *src/app.tsx*
1085
1906
  ```typescript jsx
1086
1907
  export default (
1087
1908
  <server>
1088
1909
  <api>
1089
- <endpoint method='get' path='/users/{userId}'>
1910
+ <endpoint method='get' path='/users'>
1090
1911
  <param
1091
- in='path'
1092
- name='userId'
1093
- description='User identification number'
1094
- />
1912
+ in='query'
1913
+ name='search'>
1914
+ <any default={null} />
1915
+ </param>
1095
1916
  </endpoint>
1096
1917
  </api>
1097
1918
  </server>
1098
1919
  )
1099
1920
  ```
1100
1921
 
1101
- #### required
1922
+ #### example
1102
1923
 
1103
- Determines whether this parameter is mandatory.
1104
- If the parameter location is "path", this property is `true` and its value MUST be `true`.
1105
- Otherwise, the property MAY be included and its default value is `false`.
1924
+ An example value.
1106
1925
 
1107
1926
  *src/app.tsx*
1108
1927
  ```typescript jsx
1109
1928
  export default (
1110
1929
  <server>
1111
1930
  <api>
1112
- <endpoint method='get' path='/users'>
1931
+ <endpoint method='get' path='/products'>
1113
1932
  <param
1114
- in='cookie'
1115
- name='token'
1116
- required
1117
- />
1933
+ in='query'
1934
+ name='active'>
1935
+ <any example={false} />
1936
+ </param>
1118
1937
  </endpoint>
1119
1938
  </api>
1120
1939
  </server>
1121
1940
  )
1122
1941
  ```
1123
1942
 
1124
- #### deprecated
1943
+ #### description
1125
1944
 
1126
- Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
1127
- Default value is `false`.
1945
+ A description of the `any`.
1128
1946
 
1129
1947
  *src/app.tsx*
1130
1948
  ```typescript jsx
1131
1949
  export default (
1132
1950
  <server>
1133
1951
  <api>
1134
- <endpoint method='get' path='/users'>
1952
+ <endpoint method='get' path='/products'>
1135
1953
  <param
1136
1954
  in='query'
1137
- name='status'
1138
- deprecated
1139
- />
1955
+ name='active'>
1956
+ <any
1957
+ description='Active products param'
1958
+ />
1959
+ </param>
1140
1960
  </endpoint>
1141
1961
  </api>
1142
1962
  </server>
1143
1963
  )
1144
1964
  ```
1145
1965
 
1146
- ### \<body>
1966
+ ### \<null>
1147
1967
 
1148
- [← back](#endpoints)
1968
+ [← back](#primitive-data)
1149
1969
 
1150
- This element MUST be placed inside `<endpoint>`.
1151
- It defines request body for the endpoint.
1970
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1971
+ It defines `null` value for a parent element.
1152
1972
  `@innet/server` formats and validate the value automatically (real-time).
1153
1973
 
1974
+ *src/app.tsx*
1154
1975
  ```typescript jsx
1155
- return (
1976
+ export default (
1156
1977
  <server>
1157
1978
  <api>
1158
- <endpoint method='post' path='/partners'>
1159
- <body>
1160
- <object>
1161
- <field key='name'>
1162
- <string example='CANTent.' />
1163
- </field>
1164
- <field key='gift'>
1165
- <boolean />
1166
- </field>
1167
- <field optional key='addresses'>
1168
- <array>
1169
- <number description='address id' />
1170
- </array>
1171
- </field>
1172
- </object>
1173
- </body>
1979
+ <endpoint method='get' path='/todos'>
1980
+ <param
1981
+ in='query'
1982
+ name='search'>
1983
+ <null />
1984
+ </param>
1174
1985
  </endpoint>
1175
1986
  </api>
1176
1987
  </server>
1177
1988
  )
1178
1989
  ```
1179
1990
 
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
1991
+ #### description
1188
1992
 
1189
- [← back](#index)
1993
+ A description of the `null`.
1190
1994
 
1191
- [\<null>](#null)
1192
- [\<boolean>](#boolean)
1193
- [\<string>](#string)
1194
- [\<number>](#number)
1195
- [\<integer>](#integer)
1196
- [\<date>](#date)
1197
- [\<uuid>](#uuid)
1198
- [\<binary>](#binary)
1995
+ *src/app.tsx*
1996
+ ```typescript jsx
1997
+ export default (
1998
+ <server>
1999
+ <api>
2000
+ <endpoint method='get' path='/products'>
2001
+ <param
2002
+ in='query'
2003
+ name='active'>
2004
+ <null description='FIXME!' />
2005
+ </param>
2006
+ </endpoint>
2007
+ </api>
2008
+ </server>
2009
+ )
2010
+ ```
1199
2011
 
1200
2012
  ### \<boolean>
1201
2013
 
@@ -1503,6 +2315,26 @@ you get an error:
1503
2315
  }
1504
2316
  ```
1505
2317
 
2318
+ #### format
2319
+
2320
+ An optional format modifier serves as a hint at the contents and format of the string.
2321
+ Available formats include: `email`, `date-time`, `date`, `uri`, `hostname`, `ipv4`, `ipv6`, `uuid`, `byte`, `binary`, `password` or custom string.
2322
+
2323
+ *src/app.tsx*
2324
+ ```typescript jsx
2325
+ export default (
2326
+ <server>
2327
+ <api>
2328
+ <endpoint method='get' path='/users'>
2329
+ <param in='query' name='email'>
2330
+ <string format='email' />
2331
+ </param>
2332
+ </endpoint>
2333
+ </api>
2334
+ </server>
2335
+ )
2336
+ ```
2337
+
1506
2338
  ### \<number>
1507
2339
 
1508
2340
  [← back](#primitive-data)
@@ -1652,6 +2484,66 @@ export default (
1652
2484
 
1653
2485
  *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
1654
2486
 
2487
+ #### exclusiveMinimum, exclusiveMaximum
2488
+
2489
+ These props restrict the value to be strictly greater than or less than the specified number.
2490
+
2491
+ *src/app.tsx*
2492
+ ```typescript jsx
2493
+ export default (
2494
+ <server>
2495
+ <api>
2496
+ <endpoint method='get' path='/products'>
2497
+ <param in='query' name='rating'>
2498
+ <number
2499
+ exclusiveMinimum={0}
2500
+ exclusiveMaximum={5}
2501
+ />
2502
+ </param>
2503
+ </endpoint>
2504
+ </api>
2505
+ </server>
2506
+ )
2507
+ ```
2508
+
2509
+ #### multipleOf
2510
+
2511
+ This prop restricts the value to be a multiple of the specified number.
2512
+
2513
+ *src/app.tsx*
2514
+ ```typescript jsx
2515
+ export default (
2516
+ <server>
2517
+ <api>
2518
+ <endpoint method='get' path='/products'>
2519
+ <param in='query' name='quantity'>
2520
+ <number multipleOf={10} />
2521
+ </param>
2522
+ </endpoint>
2523
+ </api>
2524
+ </server>
2525
+ )
2526
+ ```
2527
+
2528
+ #### format
2529
+
2530
+ An optional format modifier serves as a hint at the contents and format of the number.
2531
+
2532
+ *src/app.tsx*
2533
+ ```typescript jsx
2534
+ export default (
2535
+ <server>
2536
+ <api>
2537
+ <endpoint method='get' path='/products'>
2538
+ <param in='query' name='price'>
2539
+ <number format='float' />
2540
+ </param>
2541
+ </endpoint>
2542
+ </api>
2543
+ </server>
2544
+ )
2545
+ ```
2546
+
1655
2547
  ### \<integer>
1656
2548
 
1657
2549
  [← back](#primitive-data)
@@ -1825,6 +2717,47 @@ export default (
1825
2717
 
1826
2718
  *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
1827
2719
 
2720
+ #### exclusiveMinimum, exclusiveMaximum
2721
+
2722
+ These props restrict the value to be strictly greater than or less than the specified number.
2723
+
2724
+ *src/app.tsx*
2725
+ ```typescript jsx
2726
+ export default (
2727
+ <server>
2728
+ <api>
2729
+ <endpoint method='get' path='/products'>
2730
+ <param in='query' name='count'>
2731
+ <integer
2732
+ exclusiveMinimum={0}
2733
+ exclusiveMaximum={100}
2734
+ />
2735
+ </param>
2736
+ </endpoint>
2737
+ </api>
2738
+ </server>
2739
+ )
2740
+ ```
2741
+
2742
+ #### multipleOf
2743
+
2744
+ This prop restricts the value to be a multiple of the specified number.
2745
+
2746
+ *src/app.tsx*
2747
+ ```typescript jsx
2748
+ export default (
2749
+ <server>
2750
+ <api>
2751
+ <endpoint method='get' path='/products'>
2752
+ <param in='query' name='quantity'>
2753
+ <integer multipleOf={5} />
2754
+ </param>
2755
+ </endpoint>
2756
+ </api>
2757
+ </server>
2758
+ )
2759
+ ```
2760
+
1828
2761
  ### \<date>
1829
2762
 
1830
2763
  [← back](#primitive-data)
@@ -2462,6 +3395,48 @@ export default (
2462
3395
  )
2463
3396
  ```
2464
3397
 
3398
+ #### minItems, maxItems
3399
+
3400
+ Those two props validate the array by minimum and maximum number of items.
3401
+
3402
+ *src/app.tsx*
3403
+ ```typescript jsx
3404
+ export default (
3405
+ <server>
3406
+ <api>
3407
+ <endpoint method='get' path='/products'>
3408
+ <param in='query' name='tags'>
3409
+ <array minItems={1} maxItems={10}>
3410
+ <string />
3411
+ </array>
3412
+ </param>
3413
+ </endpoint>
3414
+ </api>
3415
+ </server>
3416
+ )
3417
+ ```
3418
+
3419
+ #### uniqueItems
3420
+
3421
+ This prop validates that all items in the array are unique.
3422
+
3423
+ *src/app.tsx*
3424
+ ```typescript jsx
3425
+ export default (
3426
+ <server>
3427
+ <api>
3428
+ <endpoint method='get' path='/products'>
3429
+ <param in='query' name='ids'>
3430
+ <array uniqueItems>
3431
+ <number />
3432
+ </array>
3433
+ </param>
3434
+ </endpoint>
3435
+ </api>
3436
+ </server>
3437
+ )
3438
+ ```
3439
+
2465
3440
  ### \<object>
2466
3441
 
2467
3442
  [← back](#list-of-data)
@@ -2477,7 +3452,9 @@ export default (
2477
3452
  <api>
2478
3453
  <endpoint method='post' path='/users'>
2479
3454
  <body>
2480
- <object />
3455
+ <object>
3456
+ <string />
3457
+ </object>
2481
3458
  </body>
2482
3459
  </endpoint>
2483
3460
  </api>
@@ -2538,9 +3515,9 @@ export default (
2538
3515
  <api>
2539
3516
  <endpoint method='post' path='/users'>
2540
3517
  <body>
2541
- <object
2542
- description='The object of a user'
2543
- />
3518
+ <object
3519
+ description='The object of a user'
3520
+ />
2544
3521
  </body>
2545
3522
  </endpoint>
2546
3523
  </api>
@@ -2556,7 +3533,7 @@ The element MUST be placed inside [\<object>](#object).
2556
3533
  It defines a `field` of an `object` value for a parent element.
2557
3534
  `@innet/server` formats and validate the value automatically (real-time).
2558
3535
 
2559
- `key` is REQUIRED prop of `<field>`, it defines a field name of the `<object>`.
3536
+ `key` is REQUIRED prop of `<field>`, it defines a field name of the [\<object>](#object).
2560
3537
 
2561
3538
  *src/app.tsx*
2562
3539
  ```typescript jsx
@@ -2600,116 +3577,98 @@ export default (
2600
3577
  )
2601
3578
  ```
2602
3579
 
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)
3580
+ #### deprecated
2629
3581
 
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).
3582
+ You can deprecate a field.
2635
3583
 
2636
3584
  *src/app.tsx*
2637
3585
  ```typescript jsx
2638
3586
  export default (
2639
3587
  <server>
2640
3588
  <api>
2641
- <fallback>
2642
- <error
2643
- code='unknownEndpoint'
2644
- />
2645
- </fallback>
3589
+ <endpoint method='post' path='/users'>
3590
+ <body>
3591
+ <object>
3592
+ <field key='name' />
3593
+ <field key='surname' />
3594
+ <field deprecated optional key='birthbay' />
3595
+ </object>
3596
+ </body>
3597
+ </endpoint>
2646
3598
  </api>
2647
3599
  </server>
2648
3600
  )
2649
3601
  ```
2650
3602
 
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)
3603
+ #### readOnly
2664
3604
 
2665
- This element MUST be placed in `<endpoint>` element.
2666
- It defines run-time call handler for the endpoint.
3605
+ You can mark a field as read-only, meaning it can only be returned in responses, not sent in requests.
2667
3606
 
2668
3607
  *src/app.tsx*
2669
3608
  ```typescript jsx
2670
3609
  export default (
2671
3610
  <server>
2672
3611
  <api>
2673
- <endpoint method='get' path='/partners'>
2674
- <request>
2675
- <success>
2676
- {{partners: []}}
2677
- </success>
2678
- </request>
3612
+ <endpoint method='get' path='/users'>
3613
+ <response>
3614
+ <object>
3615
+ <field key='id' readOnly>
3616
+ <uuid />
3617
+ </field>
3618
+ <field key='name'>
3619
+ <string />
3620
+ </field>
3621
+ </object>
3622
+ </response>
2679
3623
  </endpoint>
2680
3624
  </api>
2681
3625
  </server>
2682
3626
  )
2683
3627
  ```
2684
3628
 
2685
- You can place a component inside it.
2686
- The component will run when the endpoint will be triggered.
3629
+ #### writeOnly
3630
+
3631
+ You can mark a field as write-only, meaning it can only be sent in requests, not returned in responses.
2687
3632
 
2688
3633
  *src/app.tsx*
2689
3634
  ```typescript jsx
2690
- import { GetPartners } from './GetPartners'
2691
-
2692
3635
  export default (
2693
3636
  <server>
2694
3637
  <api>
2695
- <endpoint method='get' path='/partners'>
2696
- <request>
2697
- <GetPartners />
2698
- </request>
3638
+ <endpoint method='post' path='/users'>
3639
+ <body>
3640
+ <object>
3641
+ <field key='password' writeOnly>
3642
+ <string />
3643
+ </field>
3644
+ <field key='name'>
3645
+ <string />
3646
+ </field>
3647
+ </object>
3648
+ </body>
2699
3649
  </endpoint>
2700
3650
  </api>
2701
3651
  </server>
2702
3652
  )
2703
3653
  ```
2704
3654
 
2705
- *src/GetPartners.tsx*
2706
- ```typescript jsx
2707
- export const GetPartners = () => (
2708
- <success>
2709
- {{partners: []}}
2710
- </success>
2711
- )
2712
- ```
3655
+ ## Run-Time
3656
+
3657
+ Next elements relate to run-time action.
3658
+ This action calls on user request.
3659
+
3660
+ [← back](#index)
3661
+
3662
+ [\<success>](#success)
3663
+ [\<error>](#error)
3664
+ [\<proxy>](#proxy)
3665
+ [\<redirect>](#redirect)
3666
+ [\<cms>](#cms)
3667
+ [\<file>](#file)
3668
+ [\<header>](#header)
3669
+ [\<cookie>](#cookie)
3670
+
3671
+ ---
2713
3672
 
2714
3673
  ### \<success>
2715
3674
 
@@ -2721,11 +3680,9 @@ This is a base element to return a success data.
2721
3680
  ```typescript jsx
2722
3681
  export default (
2723
3682
  <server>
2724
- <api>
2725
- <fallback>
2726
- <success />
2727
- </fallback>
2728
- </api>
3683
+ <return>
3684
+ <success />
3685
+ </return>
2729
3686
  </server>
2730
3687
  )
2731
3688
  ```
@@ -2740,13 +3697,11 @@ const data = {...}
2740
3697
 
2741
3698
  export default (
2742
3699
  <server>
2743
- <api>
2744
- <fallback>
2745
- <success>
2746
- {data}
2747
- </success>
2748
- </fallback>
2749
- </api>
3700
+ <return>
3701
+ <success>
3702
+ {data}
3703
+ </success>
3704
+ </return>
2750
3705
  </server>
2751
3706
  )
2752
3707
  ```
@@ -2763,13 +3718,11 @@ const data = {...}
2763
3718
 
2764
3719
  export default (
2765
3720
  <server>
2766
- <api>
2767
- <fallback>
2768
- <success status='created'>
2769
- {data}
2770
- </success>
2771
- </fallback>
2772
- </api>
3721
+ <return>
3722
+ <success status='created'>
3723
+ {data}
3724
+ </success>
3725
+ </return>
2773
3726
  </server>
2774
3727
  )
2775
3728
  ```
@@ -2784,13 +3737,29 @@ const data = {...}
2784
3737
 
2785
3738
  export default (
2786
3739
  <server>
2787
- <api>
2788
- <fallback>
2789
- <success status={201}>
2790
- {data}
2791
- </success>
2792
- </fallback>
2793
- </api>
3740
+ <return>
3741
+ <success status={201}>
3742
+ {data}
3743
+ </success>
3744
+ </return>
3745
+ </server>
3746
+ )
3747
+ ```
3748
+
3749
+ #### contentType
3750
+
3751
+ This props sets response content type.
3752
+ By default, it checks children element to define the prop.
3753
+
3754
+ *src/app.tsx*
3755
+ ```typescript jsx
3756
+ export default (
3757
+ <server>
3758
+ <return>
3759
+ <success contentType='text/html'>
3760
+ Hello World!
3761
+ </success>
3762
+ </return>
2794
3763
  </server>
2795
3764
  )
2796
3765
  ```
@@ -2800,17 +3769,15 @@ export default (
2800
3769
  [← back](#run-time)
2801
3770
 
2802
3771
  Returns an error.
2803
- This element MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3772
+ This element MUST be placed in [\<return>](#return).
2804
3773
 
2805
3774
  *src/app.tsx*
2806
3775
  ```typescript jsx
2807
3776
  export default (
2808
3777
  <server>
2809
- <api>
2810
- <fallback>
2811
- <error />
2812
- </fallback>
2813
- </api>
3778
+ <return>
3779
+ <error />
3780
+ </return>
2814
3781
  </server>
2815
3782
  )
2816
3783
  ```
@@ -2823,13 +3790,11 @@ const data = {...}
2823
3790
 
2824
3791
  export default (
2825
3792
  <server>
2826
- <api>
2827
- <fallback>
2828
- <error>
2829
- {data}
2830
- </error>
2831
- </fallback>
2832
- </api>
3793
+ <return>
3794
+ <error>
3795
+ {data}
3796
+ </error>
3797
+ </return>
2833
3798
  </server>
2834
3799
  )
2835
3800
  ```
@@ -2845,13 +3810,11 @@ const data = {
2845
3810
 
2846
3811
  export default (
2847
3812
  <server>
2848
- <api>
2849
- <fallback>
2850
- <error status='notFound'>
2851
- {data}
2852
- </error>
2853
- </fallback>
2854
- </api>
3813
+ <return>
3814
+ <error status='notFound'>
3815
+ {data}
3816
+ </error>
3817
+ </return>
2855
3818
  </server>
2856
3819
  )
2857
3820
  ```
@@ -2866,13 +3829,11 @@ const data = {
2866
3829
 
2867
3830
  export default (
2868
3831
  <server>
2869
- <api>
2870
- <fallback>
2871
- <error status={404}>
2872
- {data}
2873
- </error>
2874
- </fallback>
2875
- </api>
3832
+ <return>
3833
+ <error status={404}>
3834
+ {data}
3835
+ </error>
3836
+ </return>
2876
3837
  </server>
2877
3838
  )
2878
3839
  ```
@@ -2900,15 +3861,13 @@ const data = {
2900
3861
 
2901
3862
  export default (
2902
3863
  <server>
2903
- <api>
2904
- <fallback>
2905
- <error
2906
- code='noUser'
2907
- status='notFound'>
2908
- {data}
2909
- </error>
2910
- </fallback>
2911
- </api>
3864
+ <return>
3865
+ <error
3866
+ code='noUser'
3867
+ status='notFound'>
3868
+ {data}
3869
+ </error>
3870
+ </return>
2912
3871
  </server>
2913
3872
  )
2914
3873
  ```
@@ -2936,7 +3895,7 @@ There are some default errors:
2936
3895
 
2937
3896
  [← back](#run-time)
2938
3897
 
2939
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3898
+ MUST be placed in [\<return>](#return).
2940
3899
 
2941
3900
  You can easy proxy endpoints to another server/service.
2942
3901
 
@@ -2948,14 +3907,14 @@ export default (
2948
3907
  <endpoint
2949
3908
  path='/test'
2950
3909
  method='get'>
2951
- <request>
3910
+ <return>
2952
3911
  <proxy to='https://...' />
2953
- </request>
3912
+ </return>
2954
3913
  </endpoint>
2955
- <fallback>
2956
- <proxy to='https://...' />
2957
- </fallback>
2958
3914
  </api>
3915
+ <return>
3916
+ <proxy to='https://...' />
3917
+ </return>
2959
3918
  </server>
2960
3919
  )
2961
3920
  ```
@@ -2964,7 +3923,7 @@ export default (
2964
3923
 
2965
3924
  [← back](#run-time)
2966
3925
 
2967
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3926
+ MUST be placed in [\<return>](#return).
2968
3927
 
2969
3928
  You can redirect users to another resource. It adds `Cache-Control` header by default.
2970
3929
 
@@ -2976,14 +3935,14 @@ export default (
2976
3935
  <endpoint
2977
3936
  path='/test'
2978
3937
  method='get'>
2979
- <request>
3938
+ <return>
2980
3939
  <redirect to='https://...' />
2981
- </request>
3940
+ </return>
2982
3941
  </endpoint>
2983
- <fallback>
2984
- <redirect to='https://...' />
2985
- </fallback>
2986
3942
  </api>
3943
+ <return>
3944
+ <redirect to='https://...' />
3945
+ </return>
2987
3946
  </server>
2988
3947
  )
2989
3948
  ```
@@ -3001,20 +3960,20 @@ export default (
3001
3960
  <endpoint
3002
3961
  path='/test'
3003
3962
  method='get'>
3004
- <request>
3963
+ <return>
3005
3964
  <redirect
3006
3965
  status='found'
3007
3966
  to='https://...'
3008
3967
  />
3009
- </request>
3968
+ </return>
3010
3969
  </endpoint>
3011
- <fallback>
3012
- <redirect
3013
- status={303}
3014
- to='https://...'
3015
- />
3016
- </fallback>
3017
3970
  </api>
3971
+ <return>
3972
+ <redirect
3973
+ status={303}
3974
+ to='https://...'
3975
+ />
3976
+ </return>
3018
3977
  </server>
3019
3978
  )
3020
3979
  ```
@@ -3023,7 +3982,7 @@ export default (
3023
3982
 
3024
3983
  [← back](#run-time)
3025
3984
 
3026
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3985
+ MUST be placed in [\<return>](#return).
3027
3986
 
3028
3987
  `<cms>` helps to return files from a folder by path. It checks files run-time on the server.
3029
3988
 
@@ -3031,18 +3990,16 @@ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3031
3990
  ```typescript jsx
3032
3991
  export default (
3033
3992
  <server>
3034
- <api>
3035
- <fallback>
3036
- <cms />
3037
- </fallback>
3038
- </api>
3993
+ <return>
3994
+ <cms />
3995
+ </return>
3039
3996
  </server>
3040
3997
  )
3041
3998
  ```
3042
3999
 
3043
4000
  #### dir
3044
4001
 
3045
- By default, it looks at project folder.
4002
+ By default, it equals `INNET_CMS_DIR` node env variable or the project folder.
3046
4003
  If you try the previous example on [http://localhost/package.json](http://localhost/package.json)
3047
4004
  you get the project `package.json` file.
3048
4005
 
@@ -3052,11 +4009,9 @@ You can change root folder by `dir` property.
3052
4009
  ```typescript jsx
3053
4010
  export default (
3054
4011
  <server>
3055
- <api>
3056
- <fallback>
3057
- <cms dir='src' />
3058
- </fallback>
3059
- </api>
4012
+ <return>
4013
+ <cms dir='src' />
4014
+ </return>
3060
4015
  </server>
3061
4016
  )
3062
4017
  ```
@@ -3067,15 +4022,16 @@ you get the index file in `src` folder.
3067
4022
  #### prefix
3068
4023
 
3069
4024
  `<cms>` matches full `path`, you should take it into account if you add `prefix` on `<api>`.
4025
+ By default, it equals `INNET_CMS_PREFIX` node env variable or `/`.
3070
4026
 
3071
4027
  *src/app.tsx*
3072
4028
  ```typescript jsx
3073
4029
  export default (
3074
4030
  <server>
3075
4031
  <api prefix='/src'>
3076
- <fallback>
4032
+ <return>
3077
4033
  <cms />
3078
- </fallback>
4034
+ </return>
3079
4035
  </api>
3080
4036
  </server>
3081
4037
  )
@@ -3091,9 +4047,9 @@ You can reduce the path for matching by prefix property of `<cms>`.
3091
4047
  export default (
3092
4048
  <server>
3093
4049
  <api prefix='/api'>
3094
- <fallback>
4050
+ <return>
3095
4051
  <cms prefix='/api' />
3096
- </fallback>
4052
+ </return>
3097
4053
  </api>
3098
4054
  </server>
3099
4055
  )
@@ -3109,13 +4065,11 @@ You can handle if a file was not found by children elements of `<cms>`.
3109
4065
  ```typescript jsx
3110
4066
  export default (
3111
4067
  <server>
3112
- <api prefix='/src'>
3113
- <fallback>
3114
- <cms>
3115
- <error status={404} />
3116
- </cms>
3117
- </fallback>
3118
- </api>
4068
+ <return>
4069
+ <cms>
4070
+ <error status={404} />
4071
+ </cms>
4072
+ </return>
3119
4073
  </server>
3120
4074
  )
3121
4075
  ```
@@ -3124,7 +4078,7 @@ export default (
3124
4078
 
3125
4079
  [← back](#run-time)
3126
4080
 
3127
- It returns a file. MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
4081
+ It returns a file. MUST be placed in [\<return>](#return).
3128
4082
 
3129
4083
  It adds `Content-Length` and `Content-Type` automatically.
3130
4084
 
@@ -3134,13 +4088,9 @@ It has a REQUIRED property of `path`.
3134
4088
  ```typescript jsx
3135
4089
  export default (
3136
4090
  <server>
3137
- <api>
3138
- <fallback>
3139
- <file
3140
- path='package.json'
3141
- />
3142
- </fallback>
3143
- </api>
4091
+ <return>
4092
+ <file path='package.json' />
4093
+ </return>
3144
4094
  </server>
3145
4095
  )
3146
4096
  ```
@@ -3155,20 +4105,18 @@ You can handle if a file was not found by children elements of `<file>`.
3155
4105
  ```typescript jsx
3156
4106
  export default (
3157
4107
  <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>
4108
+ <return>
4109
+ <file path='file_is_not_exist.txt'>
4110
+ <error status={404} />
4111
+ </file>
4112
+ </return>
3165
4113
  </server>
3166
4114
  )
3167
4115
  ```
3168
4116
 
3169
4117
  ### \<header>
3170
4118
 
3171
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
4119
+ MUST be placed in [\<return>](#return).
3172
4120
 
3173
4121
  [← back](#run-time)
3174
4122
 
@@ -3178,22 +4126,20 @@ You can add an HTTP header into response by `<header>` element.
3178
4126
  ```typescript jsx
3179
4127
  export default (
3180
4128
  <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>
4129
+ <return>
4130
+ <header
4131
+ key='Cache-Control'
4132
+ value='no-cache, no-store, must-revalidate'
4133
+ />
4134
+ <success />
4135
+ </return>
3190
4136
  </server>
3191
4137
  )
3192
4138
  ```
3193
4139
 
3194
4140
  ### \<cookie>
3195
4141
 
3196
- MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
4142
+ MUST be placed in [\<return>](#return).
3197
4143
 
3198
4144
  [← back](#run-time)
3199
4145
 
@@ -3203,18 +4149,16 @@ You can add/remove a cookie into response by `<cookie>` element.
3203
4149
  ```typescript jsx
3204
4150
  export default (
3205
4151
  <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>
4152
+ <return>
4153
+ <cookie
4154
+ key='token'
4155
+ value='...'
4156
+ />
4157
+ <cookie
4158
+ key='removedCookie'
4159
+ />
4160
+ <success />
4161
+ </return>
3218
4162
  </server>
3219
4163
  )
3220
4164
  ```
@@ -3228,16 +4172,14 @@ By default, no domain is set, and most clients will consider the cookie to apply
3228
4172
  ```typescript jsx
3229
4173
  export default (
3230
4174
  <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>
4175
+ <return>
4176
+ <cookie
4177
+ domain='.example.com'
4178
+ key='token'
4179
+ value='...'
4180
+ />
4181
+ <success />
4182
+ </return>
3241
4183
  </server>
3242
4184
  )
3243
4185
  ```
@@ -3256,16 +4198,14 @@ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/h
3256
4198
  ```typescript jsx
3257
4199
  export default (
3258
4200
  <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>
4201
+ <return>
4202
+ <cookie
4203
+ expires={new Date('2050-01-01')}
4204
+ key='token'
4205
+ value='...'
4206
+ />
4207
+ <success />
4208
+ </return>
3269
4209
  </server>
3270
4210
  )
3271
4211
  ```
@@ -3279,16 +4219,14 @@ Note be careful when setting this to true, as compliant clients will not allow c
3279
4219
  ```typescript jsx
3280
4220
  export default (
3281
4221
  <server>
3282
- <api prefix='/src'>
3283
- <fallback>
3284
- <cookie
3285
- httpOnly
3286
- key='token'
3287
- value='...'
3288
- />
3289
- <success />
3290
- </fallback>
3291
- </api>
4222
+ <return>
4223
+ <cookie
4224
+ httpOnly
4225
+ key='token'
4226
+ value='...'
4227
+ />
4228
+ <success />
4229
+ </return>
3292
4230
  </server>
3293
4231
  )
3294
4232
  ```
@@ -3302,17 +4240,15 @@ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/h
3302
4240
  ```typescript jsx
3303
4241
  export default (
3304
4242
  <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>
4243
+ <return>
4244
+ <cookie
4245
+ httpOnly
4246
+ maxAge={9999}
4247
+ key='token'
4248
+ value='...'
4249
+ />
4250
+ <success />
4251
+ </return>
3316
4252
  </server>
3317
4253
  )
3318
4254
  ```
@@ -3326,18 +4262,16 @@ By default, the path is considered the “default path”.
3326
4262
  ```typescript jsx
3327
4263
  export default (
3328
4264
  <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>
4265
+ <return>
4266
+ <cookie
4267
+ httpOnly
4268
+ maxAge={9999}
4269
+ path='/src'
4270
+ key='token'
4271
+ value='...'
4272
+ />
4273
+ <success />
4274
+ </return>
3341
4275
  </server>
3342
4276
  )
3343
4277
  ```
@@ -3356,18 +4290,16 @@ note This is an attribute that has not yet been fully standardized, and may chan
3356
4290
  ```typescript jsx
3357
4291
  export default (
3358
4292
  <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>
4293
+ <return>
4294
+ <cookie
4295
+ httpOnly
4296
+ priority='high'
4297
+ path='/src'
4298
+ key='token'
4299
+ value='...'
4300
+ />
4301
+ <success />
4302
+ </return>
3371
4303
  </server>
3372
4304
  )
3373
4305
  ```
@@ -3389,19 +4321,17 @@ This also means many clients may ignore this attribute until they understand it.
3389
4321
  ```typescript jsx
3390
4322
  export default (
3391
4323
  <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>
4324
+ <return>
4325
+ <cookie
4326
+ httpOnly
4327
+ sameSite
4328
+ priority='high'
4329
+ path='/src'
4330
+ key='token'
4331
+ value='...'
4332
+ />
4333
+ <success />
4334
+ </return>
3405
4335
  </server>
3406
4336
  )
3407
4337
  ```
@@ -3418,17 +4348,15 @@ Note be careful when setting this to true, as compliant clients will not send th
3418
4348
  ```typescript jsx
3419
4349
  export default (
3420
4350
  <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>
4351
+ <return>
4352
+ <cookie
4353
+ httpOnly
4354
+ secure
4355
+ key='token'
4356
+ value='...'
4357
+ />
4358
+ <success />
4359
+ </return>
3432
4360
  </server>
3433
4361
  )
3434
4362
  ```
@@ -3461,14 +4389,12 @@ import { SetToken } from './SetToken'
3461
4389
 
3462
4390
  export default (
3463
4391
  <server>
3464
- <api prefix='/src'>
3465
- <fallback>
3466
- <SetToken
3467
- value='...'
3468
- />
3469
- <success />
3470
- </fallback>
3471
- </api>
4392
+ <return>
4393
+ <SetToken
4394
+ value='...'
4395
+ />
4396
+ <success />
4397
+ </return>
3472
4398
  </server>
3473
4399
  )
3474
4400
  ```
@@ -3493,10 +4419,12 @@ Real-time
3493
4419
  [useClientIp](#useclientip)
3494
4420
 
3495
4421
  Server start
3496
- [useRequestPlugin](#userequestplugin)
4422
+ [useServerPlugin](#useserverplugin)
3497
4423
 
3498
4424
  Both
3499
4425
  [useServer](#useserver)
4426
+ [usePort](#useport)
4427
+ [useIsServerHttps](#useisserverhttps)
3500
4428
  [useComponentName](#usecomponentname)
3501
4429
 
3502
4430
  ---
@@ -3505,7 +4433,7 @@ Both
3505
4433
 
3506
4434
  [← back](#hooks)
3507
4435
 
3508
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4436
+ This hook MUST be used in a component placed in [\<return>](#return).
3509
4437
  This hook returns current request instance.
3510
4438
 
3511
4439
  *src/Component.tsx*
@@ -3526,7 +4454,7 @@ export function Component () {
3526
4454
 
3527
4455
  [← back](#hooks)
3528
4456
 
3529
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4457
+ This hook MUST be used in a component placed in [\<return>](#return).
3530
4458
  This hook returns current response instance.
3531
4459
 
3532
4460
  *src/Component.tsx*
@@ -3547,7 +4475,7 @@ export function Component () {
3547
4475
 
3548
4476
  [← back](#hooks)
3549
4477
 
3550
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4478
+ This hook MUST be used in a component placed in [\<return>](#return).
3551
4479
  This hook returns current request headers object.
3552
4480
 
3553
4481
  *src/Component.tsx*
@@ -3566,7 +4494,7 @@ export function Component () {
3566
4494
 
3567
4495
  [← back](#hooks)
3568
4496
 
3569
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4497
+ This hook MUST be used in a component placed in [\<return>](#return).
3570
4498
  This hook returns current request cookies object.
3571
4499
 
3572
4500
  *src/Component.tsx*
@@ -3585,7 +4513,7 @@ export function Component () {
3585
4513
 
3586
4514
  [← back](#hooks)
3587
4515
 
3588
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4516
+ This hook MUST be used in a component placed in [\<return>](#return).
3589
4517
  This hook returns current request URL path as a `string`.
3590
4518
 
3591
4519
  *src/Component.tsx*
@@ -3604,7 +4532,7 @@ export function Component () {
3604
4532
 
3605
4533
  [← back](#hooks)
3606
4534
 
3607
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4535
+ This hook MUST be used in a component placed in [\<return>](#return).
3608
4536
  This hook returns an object of URL params you set by [\<param>](#param).
3609
4537
 
3610
4538
  *src/Component.tsx*
@@ -3622,7 +4550,7 @@ export function Component () {
3622
4550
 
3623
4551
  [← back](#hooks)
3624
4552
 
3625
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4553
+ This hook MUST be used in a component placed in [\<return>](#return).
3626
4554
  This hook returns an object of URL query params.
3627
4555
 
3628
4556
  *src/Component.tsx*
@@ -3640,7 +4568,7 @@ export function Component () {
3640
4568
 
3641
4569
  [← back](#hooks)
3642
4570
 
3643
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4571
+ This hook MUST be used in a component placed in [\<return>](#return).
3644
4572
  This hook returns current request body.
3645
4573
 
3646
4574
  *src/Component.tsx*
@@ -3659,7 +4587,7 @@ export function Component () {
3659
4587
  [← back](#hooks)
3660
4588
 
3661
4589
  This hook returns request user IP.
3662
- This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
4590
+ This hook MUST be used in a component placed in [\<return>](#return).
3663
4591
 
3664
4592
  *src/Component.tsx*
3665
4593
  ```typescript jsx
@@ -3672,7 +4600,7 @@ export function Component () {
3672
4600
  }
3673
4601
  ```
3674
4602
 
3675
- ### useRequestPlugin
4603
+ ### useServerPlugin
3676
4604
 
3677
4605
  [← back](#hooks)
3678
4606
 
@@ -3680,25 +4608,24 @@ This hook adds a request plugin function.
3680
4608
  The function runs before check endpoints.
3681
4609
  If the function returns `true` the request handling stops, and you get full control over the request.
3682
4610
 
3683
- This hook MUST be used in a component placed in [\<api>](#api).
4611
+ This hook MUST be used in a component placed in [\<server>](#server).
3684
4612
 
3685
4613
  *src/SecretEndpoint.tsx*
3686
4614
  ```typescript jsx
3687
- import { useRequestPlugin } from '@innet/sever'
4615
+ import { useRequestPlugin, useAction } from '@innet/sever'
3688
4616
 
3689
4617
  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
4618
+ useServerPlugin(() => {
4619
+ const action = useAction()
4620
+
4621
+ if (action.path.startsWith('/secret-endpoint')) {
4622
+ return <success>A secret message</success>
3696
4623
  }
3697
4624
  })
3698
4625
  }
3699
4626
  ```
3700
4627
 
3701
- Then use the plugin in [\<api>](#api).
4628
+ Then use the plugin in [\<server>](#server) or [\<api>](#api).
3702
4629
 
3703
4630
  *src/app.tsx*
3704
4631
  ```typescript jsx
@@ -3706,12 +4633,10 @@ import { SecretEndpoint } from './SecretEndpoint'
3706
4633
 
3707
4634
  export default (
3708
4635
  <server>
3709
- <api>
3710
- <fallback>
3711
- <error />
3712
- </fallback>
3713
- <SecretEndpoint />
3714
- </api>
4636
+ <SecretEndpoint />
4637
+ <return>
4638
+ <error />
4639
+ </return>
3715
4640
  </server>
3716
4641
  )
3717
4642
  ```
@@ -3739,6 +4664,53 @@ export function Component () {
3739
4664
  }
3740
4665
  ```
3741
4666
 
4667
+ ### usePort
4668
+
4669
+ [← back](#hooks)
4670
+
4671
+ This hook MUST be used in a component placed in [\<server>](#server).
4672
+ This hook returns current http(s) server port.
4673
+
4674
+ *src/LocalHost.tsx*
4675
+ ```typescript jsx
4676
+ import { usePort } from '@innet/sever'
4677
+
4678
+ export function LocalHost () {
4679
+ const port = usePort()
4680
+
4681
+ return (
4682
+ <host
4683
+ description='Development'
4684
+ url={`http://localhost:${port}/api`}
4685
+ />
4686
+ )
4687
+ }
4688
+ ```
4689
+
4690
+ ### useIsServerHttps
4691
+
4692
+ [← back](#hooks)
4693
+
4694
+ This hook MUST be used in a component placed in [\<server>](#server).
4695
+ This hook returns `true` if it is https server and `false` if not.
4696
+
4697
+ *src/LocalHost.tsx*
4698
+ ```typescript jsx
4699
+ import { usePort, useIsServerHttps } from '@innet/sever'
4700
+
4701
+ export function LocalHost () {
4702
+ const https = useIsServerHttps() ? 'https' : 'http'
4703
+ const port = usePort()
4704
+
4705
+ return (
4706
+ <host
4707
+ description='Development'
4708
+ url={`${https}://localhost:${port}/api`}
4709
+ />
4710
+ )
4711
+ }
4712
+ ```
4713
+
3742
4714
  ### useComponentName
3743
4715
 
3744
4716
  [← back](#hooks)