@innet/server 1.7.0 → 2.0.0-alpha.0

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 (755) hide show
  1. package/README.md +3060 -387
  2. package/constants.d.ts +4 -1
  3. package/constants.es6.js +10 -2
  4. package/constants.js +11 -2
  5. package/declaration.d.ts +9 -0
  6. package/example/app/App/App.d.ts +1 -0
  7. package/example/app/App/index.d.ts +1 -0
  8. package/example/index.d.ts +1 -0
  9. package/example/requests/index.d.ts +1 -0
  10. package/example/requests/partners/EditPartner/EditPartner.d.ts +1 -0
  11. package/example/requests/partners/EditPartner/index.d.ts +1 -0
  12. package/example/requests/partners/GetPartner/GetPartner.d.ts +1 -0
  13. package/example/requests/partners/GetPartner/index.d.ts +1 -0
  14. package/example/requests/partners/GetPartners/GetPartners.d.ts +1 -0
  15. package/example/requests/partners/GetPartners/index.d.ts +1 -0
  16. package/example/requests/partners/index.d.ts +3 -0
  17. package/example/schemas/address/AddressSchema/AddressSchema.d.ts +1 -0
  18. package/example/schemas/address/AddressSchema/index.d.ts +1 -0
  19. package/example/schemas/address/index.d.ts +1 -0
  20. package/example/schemas/app/ListSchema/ListSchema.d.ts +1 -0
  21. package/example/schemas/app/ListSchema/index.d.ts +1 -0
  22. package/example/schemas/app/index.d.ts +1 -0
  23. package/example/schemas/index.d.ts +4 -0
  24. package/example/schemas/location/LocationSchema/LocationSchema.d.ts +1 -0
  25. package/example/schemas/location/LocationSchema/index.d.ts +1 -0
  26. package/example/schemas/location/index.d.ts +1 -0
  27. package/example/schemas/partner/EditPartnerSchema/EditPartnerSchema.d.ts +1 -0
  28. package/example/schemas/partner/EditPartnerSchema/index.d.ts +1 -0
  29. package/example/schemas/partner/PartnerSchema/PartnerSchema.d.ts +1 -0
  30. package/example/schemas/partner/PartnerSchema/index.d.ts +1 -0
  31. package/example/schemas/partner/index.d.ts +2 -0
  32. package/example/tags/Partner/Partner.d.ts +1 -0
  33. package/example/tags/Partner/index.d.ts +1 -0
  34. package/example/tags/index.d.ts +1 -0
  35. package/handler/handler.d.ts +96 -58
  36. package/handler/handler.es6.js +102 -63
  37. package/handler/handler.js +100 -65
  38. package/handler/index.d.ts +1 -1
  39. package/hooks/index.d.ts +25 -6
  40. package/hooks/index.es6.js +25 -6
  41. package/hooks/index.js +25 -18
  42. package/hooks/useAction/index.d.ts +1 -1
  43. package/hooks/useAction/useAction.d.ts +4 -4
  44. package/hooks/useAction/useAction.es6.js +9 -7
  45. package/hooks/useAction/useAction.js +9 -7
  46. package/hooks/useApi/index.d.ts +1 -0
  47. package/hooks/useApi/index.es6.js +1 -0
  48. package/hooks/useApi/index.js +10 -0
  49. package/hooks/useApi/useApi.d.ts +13 -0
  50. package/hooks/useApi/useApi.es6.js +12 -0
  51. package/hooks/useApi/useApi.js +17 -0
  52. package/hooks/useBlock/index.d.ts +1 -0
  53. package/hooks/useBlock/index.es6.js +1 -0
  54. package/hooks/{useFiles → useBlock}/index.js +2 -2
  55. package/hooks/useBlock/useBlock.d.ts +2 -0
  56. package/hooks/useBlock/useBlock.es6.js +14 -0
  57. package/hooks/useBlock/useBlock.js +18 -0
  58. package/hooks/useBody/index.d.ts +1 -1
  59. package/hooks/useBody/useBody.d.ts +1 -1
  60. package/hooks/useBody/useBody.es6.js +3 -2
  61. package/hooks/useBody/useBody.js +3 -2
  62. package/hooks/useBodyFile/index.d.ts +1 -0
  63. package/hooks/useBodyFile/index.es6.js +1 -0
  64. package/hooks/useBodyFile/index.js +10 -0
  65. package/hooks/useBodyFile/useBodyFile.d.ts +3 -0
  66. package/hooks/useBodyFile/useBodyFile.es6.js +14 -0
  67. package/hooks/useBodyFile/useBodyFile.js +19 -0
  68. package/hooks/useComponentName/index.d.ts +1 -0
  69. package/hooks/useComponentName/index.es6.js +1 -0
  70. package/hooks/useComponentName/index.js +9 -0
  71. package/hooks/useComponentName/useComponentName.d.ts +1 -0
  72. package/hooks/useComponentName/useComponentName.es6.js +8 -0
  73. package/hooks/useComponentName/useComponentName.js +12 -0
  74. package/hooks/useCookies/index.d.ts +1 -1
  75. package/hooks/useCookies/useCookies.d.ts +1 -2
  76. package/hooks/useCookies/useCookies.es6.js +3 -2
  77. package/hooks/useCookies/useCookies.js +3 -2
  78. package/hooks/useEndpoint/index.d.ts +1 -0
  79. package/hooks/useEndpoint/index.es6.js +1 -0
  80. package/hooks/useEndpoint/index.js +10 -0
  81. package/hooks/useEndpoint/useEndpoint.d.ts +10 -0
  82. package/hooks/useEndpoint/useEndpoint.es6.js +12 -0
  83. package/hooks/useEndpoint/useEndpoint.js +17 -0
  84. package/hooks/useHeaders/index.d.ts +1 -0
  85. package/hooks/useHeaders/index.es6.js +1 -0
  86. package/hooks/useHeaders/index.js +9 -0
  87. package/hooks/useHeaders/useHeaders.d.ts +3 -0
  88. package/hooks/useHeaders/useHeaders.es6.js +8 -0
  89. package/hooks/useHeaders/useHeaders.js +12 -0
  90. package/hooks/useHost/index.d.ts +1 -0
  91. package/hooks/useHost/index.es6.js +1 -0
  92. package/hooks/useHost/index.js +10 -0
  93. package/hooks/useHost/useHost.d.ts +7 -0
  94. package/hooks/useHost/useHost.es6.js +12 -0
  95. package/hooks/useHost/useHost.js +17 -0
  96. package/hooks/useNewSchema/index.d.ts +1 -0
  97. package/hooks/useNewSchema/index.es6.js +1 -0
  98. package/hooks/useNewSchema/index.js +9 -0
  99. package/hooks/useNewSchema/useNewSchema.d.ts +2 -0
  100. package/hooks/useNewSchema/useNewSchema.es6.js +32 -0
  101. package/hooks/useNewSchema/useNewSchema.js +36 -0
  102. package/hooks/useObjectRule/index.d.ts +1 -0
  103. package/hooks/useObjectRule/index.es6.js +1 -0
  104. package/hooks/useObjectRule/index.js +10 -0
  105. package/hooks/useObjectRule/useObjectRule.d.ts +4 -0
  106. package/hooks/useObjectRule/useObjectRule.es6.js +14 -0
  107. package/hooks/useObjectRule/useObjectRule.js +19 -0
  108. package/hooks/useOneElementError/index.d.ts +1 -0
  109. package/hooks/useOneElementError/index.es6.js +1 -0
  110. package/hooks/useOneElementError/index.js +9 -0
  111. package/hooks/useOneElementError/useOneElementError.d.ts +1 -0
  112. package/hooks/useOneElementError/useOneElementError.es6.js +8 -0
  113. package/hooks/useOneElementError/useOneElementError.js +12 -0
  114. package/hooks/useParam/index.d.ts +1 -0
  115. package/hooks/useParam/index.es6.js +1 -0
  116. package/hooks/useParam/index.js +10 -0
  117. package/hooks/useParam/useParam.d.ts +7 -0
  118. package/hooks/useParam/useParam.es6.js +12 -0
  119. package/hooks/useParam/useParam.js +17 -0
  120. package/hooks/useParams/index.d.ts +1 -0
  121. package/hooks/useParams/index.es6.js +1 -0
  122. package/hooks/useParams/index.js +10 -0
  123. package/hooks/useParams/useParams.d.ts +3 -0
  124. package/hooks/useParams/useParams.es6.js +8 -0
  125. package/hooks/useParams/useParams.js +13 -0
  126. package/hooks/useParentRule/index.d.ts +1 -0
  127. package/hooks/useParentRule/index.es6.js +1 -0
  128. package/hooks/useParentRule/index.js +10 -0
  129. package/hooks/useParentRule/useParentRule.d.ts +4 -0
  130. package/hooks/useParentRule/useParentRule.es6.js +10 -0
  131. package/hooks/useParentRule/useParentRule.js +15 -0
  132. package/hooks/usePath/index.d.ts +1 -0
  133. package/hooks/usePath/index.es6.js +1 -0
  134. package/hooks/usePath/index.js +9 -0
  135. package/hooks/usePath/usePath.d.ts +1 -0
  136. package/hooks/usePath/usePath.es6.js +8 -0
  137. package/hooks/{useFiles/useFiles.js → usePath/usePath.js} +4 -3
  138. package/hooks/useRequest/index.d.ts +1 -0
  139. package/hooks/useRequest/index.es6.js +1 -0
  140. package/hooks/useRequest/index.js +10 -0
  141. package/hooks/useRequest/useRequest.d.ts +5 -0
  142. package/hooks/useRequest/useRequest.es6.js +8 -0
  143. package/hooks/useRequest/useRequest.js +13 -0
  144. package/hooks/useResponse/index.d.ts +1 -0
  145. package/hooks/useResponse/index.es6.js +1 -0
  146. package/hooks/useResponse/index.js +10 -0
  147. package/hooks/useResponse/useResponse.d.ts +5 -0
  148. package/hooks/useResponse/useResponse.es6.js +8 -0
  149. package/hooks/useResponse/useResponse.js +13 -0
  150. package/hooks/useRule/index.d.ts +1 -0
  151. package/hooks/useRule/index.es6.js +1 -0
  152. package/hooks/useRule/index.js +11 -0
  153. package/hooks/useRule/useRule.d.ts +6 -0
  154. package/hooks/useRule/useRule.es6.js +17 -0
  155. package/hooks/useRule/useRule.js +23 -0
  156. package/hooks/useSchemaContext/index.d.ts +1 -0
  157. package/hooks/useSchemaContext/index.es6.js +1 -0
  158. package/hooks/useSchemaContext/index.js +10 -0
  159. package/hooks/useSchemaContext/useSchemaContext.d.ts +5 -0
  160. package/hooks/useSchemaContext/useSchemaContext.es6.js +8 -0
  161. package/hooks/useSchemaContext/useSchemaContext.js +13 -0
  162. package/hooks/useSchemaType/index.d.ts +1 -0
  163. package/hooks/useSchemaType/index.es6.js +1 -0
  164. package/hooks/useSchemaType/index.js +9 -0
  165. package/hooks/useSchemaType/useSchemaType.d.ts +4 -0
  166. package/hooks/useSchemaType/useSchemaType.es6.js +32 -0
  167. package/hooks/useSchemaType/useSchemaType.js +36 -0
  168. package/hooks/useSearch/index.d.ts +1 -1
  169. package/hooks/useSearch/useSearch.d.ts +1 -1
  170. package/hooks/useSearch/useSearch.es6.js +9 -2
  171. package/hooks/useSearch/useSearch.js +9 -2
  172. package/hooks/useServer/index.d.ts +1 -1
  173. package/hooks/useServer/useServer.d.ts +11 -7
  174. package/hooks/useServer/useServer.es6.js +7 -7
  175. package/hooks/useServer/useServer.js +7 -7
  176. package/hooks/useTag/index.d.ts +1 -0
  177. package/hooks/useTag/index.es6.js +1 -0
  178. package/hooks/useTag/index.js +10 -0
  179. package/hooks/useTag/useTag.d.ts +3 -0
  180. package/hooks/useTag/useTag.es6.js +8 -0
  181. package/hooks/useTag/useTag.js +13 -0
  182. package/hooks/useThrow/index.d.ts +1 -0
  183. package/hooks/useThrow/index.es6.js +1 -0
  184. package/hooks/useThrow/index.js +9 -0
  185. package/hooks/useThrow/useThrow.d.ts +1 -0
  186. package/hooks/useThrow/useThrow.es6.js +9 -0
  187. package/hooks/useThrow/useThrow.js +13 -0
  188. package/index.d.ts +6 -5
  189. package/index.es6.js +104 -21
  190. package/index.js +213 -44
  191. package/openApi.test.d.ts +1 -0
  192. package/package.json +27 -12
  193. package/{experimental/serverFn → plugins/handler}/index.d.ts +1 -1
  194. package/plugins/handler/index.es6.js +1 -0
  195. package/plugins/handler/index.js +4 -0
  196. package/plugins/handler/serverFn/index.d.ts +1 -0
  197. package/plugins/handler/serverFn/serverFn.d.ts +2 -0
  198. package/plugins/handler/serverFn/serverFn.es6.js +14 -0
  199. package/{experimental → plugins/handler}/serverFn/serverFn.js +9 -7
  200. package/plugins/index.d.ts +5 -15
  201. package/plugins/index.es6.js +5 -15
  202. package/plugins/index.js +5 -42
  203. package/plugins/main/api/api.d.ts +22 -0
  204. package/plugins/main/api/api.es6.js +180 -0
  205. package/plugins/main/api/api.js +188 -0
  206. package/plugins/main/api/index.d.ts +1 -0
  207. package/plugins/main/api/index.es6.js +1 -0
  208. package/plugins/main/api/index.js +9 -0
  209. package/plugins/main/body/body.d.ts +4 -0
  210. package/plugins/main/body/body.es6.js +55 -0
  211. package/plugins/main/body/body.js +63 -0
  212. package/plugins/main/body/index.d.ts +1 -0
  213. package/plugins/main/body/index.es6.js +1 -0
  214. package/plugins/main/body/index.js +9 -0
  215. package/plugins/main/contact/contact.d.ts +10 -0
  216. package/plugins/main/contact/contact.es6.js +16 -0
  217. package/plugins/main/contact/contact.js +20 -0
  218. package/plugins/main/contact/index.d.ts +1 -0
  219. package/plugins/main/contact/index.es6.js +1 -0
  220. package/plugins/main/contact/index.js +9 -0
  221. package/plugins/main/endpoint/endpoint.d.ts +37 -0
  222. package/plugins/main/endpoint/endpoint.es6.js +54 -0
  223. package/plugins/main/endpoint/endpoint.js +62 -0
  224. package/plugins/main/endpoint/index.d.ts +1 -0
  225. package/plugins/main/endpoint/index.es6.js +1 -0
  226. package/plugins/main/endpoint/index.js +9 -0
  227. package/plugins/main/fallback/fallback.d.ts +4 -0
  228. package/plugins/main/fallback/fallback.es6.js +19 -0
  229. package/plugins/main/fallback/fallback.js +23 -0
  230. package/plugins/main/fallback/index.d.ts +1 -0
  231. package/plugins/main/fallback/index.es6.js +1 -0
  232. package/plugins/main/fallback/index.js +9 -0
  233. package/plugins/main/host/host.d.ts +16 -0
  234. package/plugins/main/host/host.es6.js +26 -0
  235. package/plugins/main/host/host.js +34 -0
  236. package/plugins/main/host/index.d.ts +1 -0
  237. package/plugins/main/host/index.es6.js +1 -0
  238. package/plugins/main/host/index.js +9 -0
  239. package/plugins/main/index.d.ts +13 -0
  240. package/plugins/main/index.es6.js +13 -0
  241. package/plugins/main/index.js +16 -0
  242. package/plugins/main/license/index.d.ts +1 -0
  243. package/plugins/main/license/index.es6.js +1 -0
  244. package/plugins/main/license/index.js +9 -0
  245. package/plugins/main/license/license.d.ts +21 -0
  246. package/plugins/main/license/license.es6.js +15 -0
  247. package/plugins/main/license/license.js +19 -0
  248. package/plugins/main/param/index.d.ts +1 -0
  249. package/plugins/main/param/index.es6.js +1 -0
  250. package/plugins/main/param/index.js +9 -0
  251. package/plugins/main/param/param.d.ts +35 -0
  252. package/plugins/main/param/param.es6.js +63 -0
  253. package/plugins/main/param/param.js +71 -0
  254. package/plugins/main/request/index.d.ts +1 -0
  255. package/plugins/main/request/index.es6.js +1 -0
  256. package/plugins/main/request/index.js +9 -0
  257. package/plugins/main/request/request.d.ts +4 -0
  258. package/plugins/main/request/request.es6.js +21 -0
  259. package/plugins/main/request/request.js +25 -0
  260. package/plugins/main/response/index.d.ts +1 -0
  261. package/plugins/main/response/index.es6.js +1 -0
  262. package/plugins/main/response/index.js +9 -0
  263. package/plugins/main/response/response.d.ts +16 -0
  264. package/plugins/main/response/response.es6.js +44 -0
  265. package/plugins/main/response/response.js +52 -0
  266. package/plugins/{server → main/server}/index.d.ts +1 -1
  267. package/plugins/main/server/server.d.ts +13 -0
  268. package/plugins/main/server/server.es6.js +44 -0
  269. package/plugins/main/server/server.js +55 -0
  270. package/plugins/main/tag/index.d.ts +1 -0
  271. package/plugins/main/tag/index.es6.js +1 -0
  272. package/plugins/main/tag/index.js +9 -0
  273. package/plugins/main/tag/tag.d.ts +11 -0
  274. package/plugins/main/tag/tag.es6.js +29 -0
  275. package/plugins/main/tag/tag.js +37 -0
  276. package/plugins/main/variable/index.d.ts +1 -0
  277. package/plugins/main/variable/index.es6.js +1 -0
  278. package/plugins/main/variable/index.js +9 -0
  279. package/plugins/main/variable/variable.d.ts +24 -0
  280. package/plugins/main/variable/variable.es6.js +16 -0
  281. package/plugins/main/variable/variable.js +20 -0
  282. package/plugins/request/cms/cms.d.ts +5 -0
  283. package/plugins/request/cms/cms.es6.js +24 -0
  284. package/plugins/request/cms/cms.js +33 -0
  285. package/plugins/{cms → request/cms}/index.d.ts +1 -1
  286. package/plugins/request/cookie/cookie.d.ts +7 -0
  287. package/plugins/request/cookie/cookie.es6.js +28 -0
  288. package/plugins/request/cookie/cookie.js +36 -0
  289. package/plugins/{cookie → request/cookie}/index.d.ts +1 -1
  290. package/plugins/{error → request/error}/error.d.ts +60 -61
  291. package/plugins/{error → request/error}/error.es6.js +70 -70
  292. package/plugins/{error → request/error}/error.js +70 -75
  293. package/plugins/{error → request/error}/index.d.ts +1 -1
  294. package/plugins/request/file/file.d.ts +4 -0
  295. package/plugins/request/file/file.es6.js +38 -0
  296. package/plugins/request/file/file.js +48 -0
  297. package/plugins/{file → request/file}/index.d.ts +1 -1
  298. package/plugins/request/header/header.d.ts +6 -0
  299. package/plugins/request/header/header.es6.js +15 -0
  300. package/plugins/request/header/header.js +19 -0
  301. package/plugins/{header → request/header}/index.d.ts +1 -1
  302. package/plugins/request/index.d.ts +8 -0
  303. package/plugins/request/index.es6.js +8 -0
  304. package/plugins/request/index.js +11 -0
  305. package/plugins/{proxy → request/proxy}/index.d.ts +1 -1
  306. package/plugins/request/proxy/proxy.d.ts +6 -0
  307. package/plugins/request/proxy/proxy.es6.js +20 -0
  308. package/plugins/request/proxy/proxy.js +28 -0
  309. package/plugins/{redirect → request/redirect}/index.d.ts +1 -1
  310. package/plugins/{redirect → request/redirect}/redirect.d.ts +17 -19
  311. package/plugins/request/redirect/redirect.es6.js +41 -0
  312. package/plugins/request/redirect/redirect.js +46 -0
  313. package/plugins/{success → request/success}/index.d.ts +1 -1
  314. package/plugins/{success → request/success}/success.d.ts +17 -19
  315. package/plugins/request/success/success.es6.js +33 -0
  316. package/plugins/request/success/success.js +38 -0
  317. package/plugins/schema/array/array.d.ts +5 -0
  318. package/plugins/schema/array/array.es6.js +58 -0
  319. package/plugins/schema/array/array.js +66 -0
  320. package/plugins/schema/array/index.d.ts +1 -0
  321. package/plugins/schema/array/index.es6.js +1 -0
  322. package/plugins/schema/array/index.js +9 -0
  323. package/plugins/schema/binary/binary.d.ts +9 -0
  324. package/plugins/schema/binary/binary.es6.js +39 -0
  325. package/plugins/schema/binary/binary.js +43 -0
  326. package/plugins/schema/binary/index.d.ts +1 -0
  327. package/plugins/schema/binary/index.es6.js +1 -0
  328. package/plugins/{action → schema/binary}/index.js +2 -2
  329. package/plugins/schema/boolean/boolean.d.ts +5 -0
  330. package/plugins/schema/boolean/boolean.es6.js +32 -0
  331. package/plugins/schema/boolean/boolean.js +36 -0
  332. package/plugins/schema/boolean/index.d.ts +1 -0
  333. package/plugins/schema/boolean/index.es6.js +1 -0
  334. package/plugins/schema/boolean/index.js +9 -0
  335. package/plugins/schema/date/date.d.ts +8 -0
  336. package/plugins/schema/date/date.es6.js +64 -0
  337. package/plugins/schema/date/date.js +68 -0
  338. package/plugins/schema/date/index.d.ts +1 -0
  339. package/plugins/schema/date/index.es6.js +1 -0
  340. package/plugins/schema/date/index.js +9 -0
  341. package/plugins/schema/field/field.d.ts +6 -0
  342. package/plugins/schema/field/field.es6.js +46 -0
  343. package/plugins/schema/field/field.js +54 -0
  344. package/plugins/schema/field/index.d.ts +1 -0
  345. package/plugins/schema/field/index.es6.js +1 -0
  346. package/plugins/schema/field/index.js +9 -0
  347. package/plugins/schema/index.d.ts +12 -0
  348. package/plugins/schema/index.es6.js +12 -0
  349. package/plugins/schema/index.js +15 -0
  350. package/plugins/schema/integer/index.d.ts +1 -0
  351. package/plugins/schema/integer/index.es6.js +1 -0
  352. package/plugins/schema/integer/index.js +9 -0
  353. package/plugins/schema/integer/integer.d.ts +8 -0
  354. package/plugins/schema/integer/integer.es6.js +46 -0
  355. package/plugins/schema/integer/integer.js +50 -0
  356. package/plugins/schema/null/index.d.ts +1 -0
  357. package/plugins/schema/null/index.es6.js +1 -0
  358. package/plugins/schema/null/index.js +9 -0
  359. package/plugins/schema/null/null.d.ts +5 -0
  360. package/plugins/schema/null/null.es6.js +15 -0
  361. package/plugins/schema/null/null.js +19 -0
  362. package/plugins/schema/number/index.d.ts +1 -0
  363. package/plugins/schema/number/index.es6.js +1 -0
  364. package/plugins/schema/number/index.js +9 -0
  365. package/plugins/schema/number/number.d.ts +9 -0
  366. package/plugins/schema/number/number.es6.js +46 -0
  367. package/plugins/schema/number/number.js +50 -0
  368. package/plugins/schema/object/index.d.ts +1 -0
  369. package/plugins/schema/object/index.es6.js +1 -0
  370. package/plugins/schema/object/index.js +9 -0
  371. package/plugins/schema/object/object.d.ts +5 -0
  372. package/plugins/schema/object/object.es6.js +54 -0
  373. package/plugins/schema/object/object.js +62 -0
  374. package/plugins/schema/string/index.d.ts +1 -0
  375. package/plugins/schema/string/index.es6.js +1 -0
  376. package/plugins/schema/string/index.js +9 -0
  377. package/plugins/schema/string/string.d.ts +9 -0
  378. package/plugins/schema/string/string.es6.js +51 -0
  379. package/plugins/schema/string/string.js +55 -0
  380. package/plugins/schema/tuple/index.d.ts +1 -0
  381. package/plugins/schema/tuple/index.es6.js +1 -0
  382. package/plugins/schema/tuple/index.js +9 -0
  383. package/plugins/schema/tuple/tuple.d.ts +5 -0
  384. package/plugins/schema/tuple/tuple.es6.js +54 -0
  385. package/plugins/schema/tuple/tuple.js +62 -0
  386. package/plugins/schema/uuid/index.d.ts +1 -0
  387. package/plugins/schema/uuid/index.es6.js +1 -0
  388. package/plugins/schema/uuid/index.js +9 -0
  389. package/plugins/schema/uuid/uuid.d.ts +6 -0
  390. package/plugins/schema/uuid/uuid.es6.js +39 -0
  391. package/plugins/schema/uuid/uuid.js +43 -0
  392. package/plugins/utils/dev/dev.d.ts +4 -0
  393. package/plugins/utils/dev/dev.es6.js +10 -0
  394. package/plugins/utils/dev/dev.js +18 -0
  395. package/plugins/utils/dev/index.d.ts +1 -0
  396. package/plugins/utils/dev/index.es6.js +1 -0
  397. package/plugins/utils/dev/index.js +9 -0
  398. package/plugins/utils/dts/dts.d.ts +6 -0
  399. package/plugins/utils/dts/dts.es6.js +35 -0
  400. package/plugins/utils/dts/dts.js +44 -0
  401. package/plugins/utils/dts/index.d.ts +1 -0
  402. package/plugins/utils/dts/index.es6.js +1 -0
  403. package/plugins/utils/dts/index.js +9 -0
  404. package/plugins/utils/index.d.ts +4 -0
  405. package/plugins/utils/index.es6.js +4 -0
  406. package/plugins/utils/index.js +7 -0
  407. package/plugins/utils/prod/index.d.ts +1 -0
  408. package/plugins/utils/prod/index.es6.js +1 -0
  409. package/plugins/utils/prod/index.js +9 -0
  410. package/plugins/utils/prod/prod.d.ts +4 -0
  411. package/plugins/utils/prod/prod.es6.js +10 -0
  412. package/plugins/utils/prod/prod.js +18 -0
  413. package/plugins/utils/swagger/index.d.ts +1 -0
  414. package/plugins/utils/swagger/index.es6.js +1 -0
  415. package/plugins/utils/swagger/index.js +9 -0
  416. package/plugins/utils/swagger/swagger.d.ts +5 -0
  417. package/plugins/utils/swagger/swagger.es6.js +28 -0
  418. package/plugins/utils/swagger/swagger.html.es6.js +3 -0
  419. package/plugins/utils/swagger/swagger.html.js +7 -0
  420. package/plugins/utils/swagger/swagger.js +32 -0
  421. package/types.d.ts +76 -0
  422. package/types.es6.js +1 -0
  423. package/types.js +2 -0
  424. package/utils/FileData/Bin.d.ts +47 -0
  425. package/utils/FileData/Bin.es6.js +19 -0
  426. package/utils/FileData/Bin.js +23 -0
  427. package/utils/FileData/index.d.ts +1 -0
  428. package/utils/FileData/index.es6.js +1 -0
  429. package/utils/FileData/index.js +9 -0
  430. package/utils/JSONString/JSONString.d.ts +1 -0
  431. package/utils/JSONString/JSONString.es6.js +10 -0
  432. package/utils/JSONString/JSONString.js +14 -0
  433. package/utils/JSONString/index.d.ts +1 -0
  434. package/utils/JSONString/index.es6.js +1 -0
  435. package/utils/JSONString/index.js +9 -0
  436. package/utils/action/Action.d.ts +29 -0
  437. package/utils/action/Action.es6.js +125 -0
  438. package/utils/action/Action.js +134 -0
  439. package/utils/action/index.d.ts +1 -1
  440. package/utils/action/index.es6.js +1 -1
  441. package/utils/action/index.js +1 -3
  442. package/utils/dateFormat/dateFormat.d.ts +2 -0
  443. package/utils/dateFormat/dateFormat.es6.js +11 -0
  444. package/utils/dateFormat/dateFormat.js +15 -0
  445. package/utils/dateFormat/index.d.ts +1 -0
  446. package/utils/dateFormat/index.es6.js +1 -0
  447. package/utils/dateFormat/index.js +9 -0
  448. package/utils/decorators/index.d.ts +1 -0
  449. package/utils/decorators/index.es6.js +1 -0
  450. package/utils/decorators/index.js +4 -0
  451. package/utils/decorators/once/index.d.ts +1 -0
  452. package/utils/decorators/once/index.es6.js +1 -0
  453. package/utils/decorators/once/index.js +9 -0
  454. package/utils/decorators/once/once.d.ts +4 -0
  455. package/utils/decorators/once/once.es6.js +28 -0
  456. package/utils/decorators/once/once.js +32 -0
  457. package/utils/decorators/once/once.test.d.ts +1 -0
  458. package/utils/getEndpoint/getEndpoint.d.ts +2 -0
  459. package/utils/getEndpoint/getEndpoint.es6.js +31 -0
  460. package/utils/getEndpoint/getEndpoint.js +35 -0
  461. package/utils/getEndpoint/index.d.ts +1 -0
  462. package/utils/getEndpoint/index.es6.js +1 -0
  463. package/utils/getEndpoint/index.js +9 -0
  464. package/utils/getOrAdd/getOrAdd.d.ts +1 -0
  465. package/utils/getOrAdd/getOrAdd.es6.js +14 -0
  466. package/utils/getOrAdd/getOrAdd.js +18 -0
  467. package/utils/getOrAdd/index.d.ts +1 -0
  468. package/utils/getOrAdd/index.es6.js +1 -0
  469. package/utils/getOrAdd/index.js +9 -0
  470. package/utils/httpOnStart/httpOnStart.d.ts +2 -0
  471. package/utils/httpOnStart/httpOnStart.es6.js +5 -0
  472. package/utils/httpOnStart/httpOnStart.js +9 -0
  473. package/utils/httpOnStart/index.d.ts +1 -0
  474. package/utils/httpOnStart/index.es6.js +1 -0
  475. package/utils/httpOnStart/index.js +9 -0
  476. package/utils/index.d.ts +12 -3
  477. package/utils/index.es6.js +12 -3
  478. package/utils/index.js +12 -13
  479. package/{plugins → utils}/parseBody/index.d.ts +1 -1
  480. package/utils/parseBody/parseBody.d.ts +3 -0
  481. package/utils/parseBody/parseBody.es6.js +23 -0
  482. package/utils/parseBody/parseBody.js +27 -0
  483. package/utils/parseFormBody/index.d.ts +1 -0
  484. package/utils/parseFormBody/index.es6.js +1 -0
  485. package/utils/parseFormBody/index.js +9 -0
  486. package/utils/parseFormBody/parseFormBody.d.ts +3 -0
  487. package/utils/parseFormBody/parseFormBody.es6.js +56 -0
  488. package/utils/parseFormBody/parseFormBody.js +60 -0
  489. package/utils/parseSearch/index.d.ts +1 -1
  490. package/utils/parseSearch/index.es6.js +1 -1
  491. package/utils/parseSearch/index.js +1 -0
  492. package/utils/parseSearch/parseSearch.d.ts +3 -2
  493. package/utils/parseSearch/parseSearch.es6.js +6 -3
  494. package/utils/parseSearch/parseSearch.js +6 -3
  495. package/utils/parseSearch/parseSearch.test.d.ts +1 -0
  496. package/utils/rules/any/any.d.ts +1 -0
  497. package/utils/rules/any/any.es6.js +5 -0
  498. package/utils/rules/any/any.js +9 -0
  499. package/utils/rules/any/index.d.ts +1 -0
  500. package/utils/rules/any/index.es6.js +1 -0
  501. package/utils/rules/any/index.js +9 -0
  502. package/utils/rules/arrayOf/arrayOf.d.ts +2 -0
  503. package/utils/rules/arrayOf/arrayOf.es6.js +15 -0
  504. package/utils/rules/arrayOf/arrayOf.js +19 -0
  505. package/utils/rules/arrayOf/index.d.ts +1 -0
  506. package/utils/rules/arrayOf/index.es6.js +1 -0
  507. package/utils/rules/arrayOf/index.js +9 -0
  508. package/utils/rules/bin/bin.d.ts +2 -0
  509. package/utils/rules/bin/bin.es6.js +12 -0
  510. package/utils/rules/bin/bin.js +16 -0
  511. package/utils/rules/bin/index.d.ts +1 -0
  512. package/utils/rules/bin/index.es6.js +1 -0
  513. package/utils/rules/bin/index.js +9 -0
  514. package/utils/rules/binaryAccept/binaryAccept.d.ts +2 -0
  515. package/utils/rules/binaryAccept/binaryAccept.es6.js +32 -0
  516. package/utils/rules/binaryAccept/binaryAccept.js +36 -0
  517. package/utils/rules/binaryAccept/index.d.ts +1 -0
  518. package/utils/rules/binaryAccept/index.es6.js +1 -0
  519. package/utils/rules/binaryAccept/index.js +9 -0
  520. package/utils/rules/constants.d.ts +1 -0
  521. package/utils/rules/constants.es6.js +28 -0
  522. package/utils/rules/constants.js +32 -0
  523. package/utils/rules/dateTo/dateTo.d.ts +2 -0
  524. package/utils/rules/dateTo/dateTo.es6.js +11 -0
  525. package/utils/rules/dateTo/dateTo.js +15 -0
  526. package/utils/rules/dateTo/index.d.ts +1 -0
  527. package/utils/rules/dateTo/index.es6.js +1 -0
  528. package/utils/rules/dateTo/index.js +9 -0
  529. package/utils/rules/defaultTo/defaultTo.d.ts +1 -0
  530. package/utils/rules/defaultTo/defaultTo.es6.js +9 -0
  531. package/utils/rules/defaultTo/defaultTo.js +13 -0
  532. package/utils/rules/defaultTo/index.d.ts +1 -0
  533. package/utils/rules/defaultTo/index.es6.js +1 -0
  534. package/utils/rules/defaultTo/index.js +9 -0
  535. package/utils/rules/helpers.d.ts +8 -0
  536. package/utils/rules/helpers.es6.js +11 -0
  537. package/utils/rules/helpers.js +16 -0
  538. package/utils/rules/index.d.ts +29 -0
  539. package/utils/rules/index.es6.js +29 -0
  540. package/utils/rules/index.js +39 -0
  541. package/utils/rules/int/index.d.ts +1 -0
  542. package/utils/rules/int/index.es6.js +1 -0
  543. package/utils/rules/int/index.js +9 -0
  544. package/utils/rules/int/int.d.ts +2 -0
  545. package/utils/rules/int/int.es6.js +36 -0
  546. package/utils/rules/int/int.js +40 -0
  547. package/utils/rules/max/index.d.ts +1 -0
  548. package/utils/rules/max/index.es6.js +1 -0
  549. package/utils/rules/max/index.js +9 -0
  550. package/utils/rules/max/max.d.ts +1 -0
  551. package/utils/rules/max/max.es6.js +16 -0
  552. package/utils/rules/max/max.js +20 -0
  553. package/utils/rules/maxBin/index.d.ts +1 -0
  554. package/utils/rules/maxBin/index.es6.js +1 -0
  555. package/utils/rules/maxBin/index.js +9 -0
  556. package/utils/rules/maxBin/maxBin.d.ts +2 -0
  557. package/utils/rules/maxBin/maxBin.es6.js +13 -0
  558. package/utils/rules/maxBin/maxBin.js +17 -0
  559. package/utils/rules/maxDate/index.d.ts +1 -0
  560. package/utils/rules/maxDate/index.es6.js +1 -0
  561. package/utils/rules/maxDate/index.js +9 -0
  562. package/utils/rules/maxDate/maxDate.d.ts +1 -0
  563. package/utils/rules/maxDate/maxDate.es6.js +15 -0
  564. package/utils/rules/maxDate/maxDate.js +19 -0
  565. package/utils/rules/maxLength/index.d.ts +1 -0
  566. package/utils/rules/maxLength/index.es6.js +1 -0
  567. package/utils/rules/maxLength/index.js +9 -0
  568. package/utils/rules/maxLength/maxLength.d.ts +1 -0
  569. package/utils/rules/maxLength/maxLength.es6.js +16 -0
  570. package/utils/rules/maxLength/maxLength.js +20 -0
  571. package/utils/rules/min/index.d.ts +1 -0
  572. package/utils/rules/min/index.es6.js +1 -0
  573. package/utils/rules/min/index.js +9 -0
  574. package/utils/rules/min/min.d.ts +1 -0
  575. package/utils/rules/min/min.es6.js +16 -0
  576. package/utils/rules/min/min.js +20 -0
  577. package/utils/rules/minBin/index.d.ts +1 -0
  578. package/utils/rules/minBin/index.es6.js +1 -0
  579. package/utils/rules/minBin/index.js +9 -0
  580. package/utils/rules/minBin/minBin.d.ts +2 -0
  581. package/utils/rules/minBin/minBin.es6.js +13 -0
  582. package/utils/rules/minBin/minBin.js +17 -0
  583. package/utils/rules/minDate/index.d.ts +1 -0
  584. package/utils/rules/minDate/index.es6.js +1 -0
  585. package/utils/rules/minDate/index.js +9 -0
  586. package/utils/rules/minDate/minDate.d.ts +1 -0
  587. package/utils/rules/minDate/minDate.es6.js +15 -0
  588. package/utils/rules/minDate/minDate.js +19 -0
  589. package/utils/rules/minLength/index.d.ts +1 -0
  590. package/utils/rules/minLength/index.es6.js +1 -0
  591. package/utils/rules/minLength/index.js +9 -0
  592. package/utils/rules/minLength/minLength.d.ts +1 -0
  593. package/utils/rules/minLength/minLength.es6.js +16 -0
  594. package/utils/rules/minLength/minLength.js +20 -0
  595. package/utils/rules/nullable/index.d.ts +1 -0
  596. package/utils/rules/nullable/index.es6.js +1 -0
  597. package/utils/rules/nullable/index.js +9 -0
  598. package/utils/rules/nullable/nullable.d.ts +1 -0
  599. package/utils/rules/nullable/nullable.es6.js +10 -0
  600. package/utils/rules/nullable/nullable.js +14 -0
  601. package/utils/rules/num/index.d.ts +1 -0
  602. package/utils/rules/num/index.es6.js +1 -0
  603. package/utils/rules/num/index.js +9 -0
  604. package/utils/rules/num/num.d.ts +1 -0
  605. package/utils/rules/num/num.es6.js +11 -0
  606. package/utils/rules/num/num.js +15 -0
  607. package/utils/rules/objectOf/index.d.ts +1 -0
  608. package/utils/rules/objectOf/index.es6.js +1 -0
  609. package/utils/rules/objectOf/index.js +9 -0
  610. package/utils/rules/objectOf/objectOf.d.ts +3 -0
  611. package/utils/rules/objectOf/objectOf.es6.js +16 -0
  612. package/utils/rules/objectOf/objectOf.js +20 -0
  613. package/utils/rules/oneOf/index.d.ts +1 -0
  614. package/utils/rules/oneOf/index.es6.js +1 -0
  615. package/utils/rules/oneOf/index.js +9 -0
  616. package/utils/rules/oneOf/oneOf.d.ts +2 -0
  617. package/utils/rules/oneOf/oneOf.es6.js +18 -0
  618. package/utils/rules/oneOf/oneOf.js +22 -0
  619. package/utils/rules/optional/index.d.ts +1 -0
  620. package/utils/rules/optional/index.es6.js +1 -0
  621. package/utils/rules/optional/index.js +9 -0
  622. package/utils/rules/optional/optional.d.ts +2 -0
  623. package/utils/rules/optional/optional.es6.js +9 -0
  624. package/utils/rules/optional/optional.js +13 -0
  625. package/utils/rules/pattern/index.d.ts +1 -0
  626. package/utils/rules/pattern/index.es6.js +1 -0
  627. package/utils/rules/pattern/index.js +9 -0
  628. package/utils/rules/pattern/pattern.d.ts +1 -0
  629. package/utils/rules/pattern/pattern.es6.js +13 -0
  630. package/utils/rules/pattern/pattern.js +17 -0
  631. package/utils/rules/pipe/index.d.ts +1 -0
  632. package/utils/rules/pipe/index.es6.js +1 -0
  633. package/utils/rules/pipe/index.js +9 -0
  634. package/utils/rules/pipe/pipe.d.ts +2 -0
  635. package/utils/rules/pipe/pipe.es6.js +7 -0
  636. package/utils/rules/pipe/pipe.js +11 -0
  637. package/utils/rules/required/index.d.ts +1 -0
  638. package/utils/rules/required/index.es6.js +1 -0
  639. package/utils/rules/required/index.js +9 -0
  640. package/utils/rules/required/required.d.ts +2 -0
  641. package/utils/rules/required/required.es6.js +12 -0
  642. package/utils/rules/required/required.js +16 -0
  643. package/utils/rules/tupleOf/index.d.ts +1 -0
  644. package/utils/rules/tupleOf/index.es6.js +1 -0
  645. package/utils/rules/tupleOf/index.js +9 -0
  646. package/utils/rules/tupleOf/tupleOf.d.ts +2 -0
  647. package/utils/rules/tupleOf/tupleOf.es6.js +19 -0
  648. package/utils/rules/tupleOf/tupleOf.js +23 -0
  649. package/utils/rules/types.d.ts +4 -0
  650. package/utils/rules/types.es6.js +1 -0
  651. package/utils/rules/types.js +2 -0
  652. package/utils/rules/uuidTo/index.d.ts +1 -0
  653. package/utils/rules/uuidTo/index.es6.js +1 -0
  654. package/utils/rules/uuidTo/index.js +9 -0
  655. package/utils/rules/uuidTo/uuidTo.d.ts +1 -0
  656. package/utils/rules/uuidTo/uuidTo.es6.js +11 -0
  657. package/utils/rules/uuidTo/uuidTo.js +15 -0
  658. package/utils/rules/values/index.d.ts +1 -0
  659. package/utils/rules/values/index.es6.js +1 -0
  660. package/utils/rules/values/index.js +9 -0
  661. package/utils/rules/values/values.d.ts +1 -0
  662. package/utils/rules/values/values.es6.js +13 -0
  663. package/utils/rules/values/values.js +17 -0
  664. package/utils/stringifySearch/index.d.ts +1 -1
  665. package/utils/stringifySearch/stringifySearch.d.ts +2 -2
  666. package/utils/stringifySearch/stringifySearch.es6.js +2 -2
  667. package/utils/stringifySearch/stringifySearch.js +2 -3
  668. package/experimental/serverFn/serverFn.d.ts +0 -2
  669. package/experimental/serverFn/serverFn.es6.js +0 -12
  670. package/hooks/useFiles/index.d.ts +0 -1
  671. package/hooks/useFiles/index.es6.js +0 -1
  672. package/hooks/useFiles/useFiles.d.ts +0 -1
  673. package/hooks/useFiles/useFiles.es6.js +0 -7
  674. package/plugins/access/access.d.ts +0 -14
  675. package/plugins/access/access.es6.js +0 -24
  676. package/plugins/access/access.js +0 -34
  677. package/plugins/access/index.d.ts +0 -1
  678. package/plugins/access/index.es6.js +0 -1
  679. package/plugins/access/index.js +0 -10
  680. package/plugins/action/action.d.ts +0 -10
  681. package/plugins/action/action.es6.js +0 -38
  682. package/plugins/action/action.js +0 -60
  683. package/plugins/action/index.d.ts +0 -1
  684. package/plugins/action/index.es6.js +0 -1
  685. package/plugins/cms/cms.d.ts +0 -9
  686. package/plugins/cms/cms.es6.js +0 -25
  687. package/plugins/cms/cms.js +0 -34
  688. package/plugins/cookie/cookie.d.ts +0 -14
  689. package/plugins/cookie/cookie.es6.js +0 -21
  690. package/plugins/cookie/cookie.js +0 -29
  691. package/plugins/file/file.d.ts +0 -7
  692. package/plugins/file/file.es6.js +0 -39
  693. package/plugins/file/file.js +0 -50
  694. package/plugins/formatter/formatter.d.ts +0 -16
  695. package/plugins/formatter/formatter.es6.js +0 -30
  696. package/plugins/formatter/formatter.js +0 -51
  697. package/plugins/formatter/index.d.ts +0 -1
  698. package/plugins/formatter/index.es6.js +0 -1
  699. package/plugins/formatter/index.js +0 -9
  700. package/plugins/header/header.d.ts +0 -12
  701. package/plugins/header/header.es6.js +0 -14
  702. package/plugins/header/header.js +0 -23
  703. package/plugins/parseBody/parseBody.d.ts +0 -7
  704. package/plugins/parseBody/parseBody.es6.js +0 -9
  705. package/plugins/parseBody/parseBody.js +0 -18
  706. package/plugins/proxy/proxy.d.ts +0 -10
  707. package/plugins/proxy/proxy.es6.js +0 -18
  708. package/plugins/proxy/proxy.js +0 -27
  709. package/plugins/redirect/redirect.es6.js +0 -34
  710. package/plugins/redirect/redirect.js +0 -40
  711. package/plugins/router/index.d.ts +0 -1
  712. package/plugins/router/index.es6.js +0 -1
  713. package/plugins/router/index.js +0 -12
  714. package/plugins/router/router.d.ts +0 -20
  715. package/plugins/router/router.es6.js +0 -51
  716. package/plugins/router/router.js +0 -63
  717. package/plugins/server/server.d.ts +0 -22
  718. package/plugins/server/server.es6.js +0 -43
  719. package/plugins/server/server.js +0 -55
  720. package/plugins/success/success.es6.js +0 -34
  721. package/plugins/success/success.js +0 -44
  722. package/plugins/validation/index.d.ts +0 -1
  723. package/plugins/validation/index.es6.js +0 -1
  724. package/plugins/validation/index.js +0 -10
  725. package/plugins/validation/validation.d.ts +0 -16
  726. package/plugins/validation/validation.es6.js +0 -31
  727. package/plugins/validation/validation.js +0 -41
  728. package/utils/action/Action/Action.d.ts +0 -48
  729. package/utils/action/Action/Action.es6.js +0 -134
  730. package/utils/action/Action/Action.js +0 -165
  731. package/utils/action/Action/index.d.ts +0 -1
  732. package/utils/action/Action/index.es6.js +0 -1
  733. package/utils/action/Action/index.js +0 -12
  734. /package/{experimental → plugins/handler}/serverFn/index.es6.js +0 -0
  735. /package/{experimental → plugins/handler}/serverFn/index.js +0 -0
  736. /package/plugins/{server → main/server}/index.es6.js +0 -0
  737. /package/plugins/{server → main/server}/index.js +0 -0
  738. /package/plugins/{cms → request/cms}/index.es6.js +0 -0
  739. /package/plugins/{cms → request/cms}/index.js +0 -0
  740. /package/plugins/{cookie → request/cookie}/index.es6.js +0 -0
  741. /package/plugins/{cookie → request/cookie}/index.js +0 -0
  742. /package/plugins/{error → request/error}/index.es6.js +0 -0
  743. /package/plugins/{error → request/error}/index.js +0 -0
  744. /package/plugins/{file → request/file}/index.es6.js +0 -0
  745. /package/plugins/{file → request/file}/index.js +0 -0
  746. /package/plugins/{header → request/header}/index.es6.js +0 -0
  747. /package/plugins/{header → request/header}/index.js +0 -0
  748. /package/plugins/{proxy → request/proxy}/index.es6.js +0 -0
  749. /package/plugins/{proxy → request/proxy}/index.js +0 -0
  750. /package/plugins/{redirect → request/redirect}/index.es6.js +0 -0
  751. /package/plugins/{redirect → request/redirect}/index.js +0 -0
  752. /package/plugins/{success → request/success}/index.es6.js +0 -0
  753. /package/plugins/{success → request/success}/index.js +0 -0
  754. /package/{plugins → utils}/parseBody/index.es6.js +0 -0
  755. /package/{plugins → utils}/parseBody/index.js +0 -0
package/README.md CHANGED
@@ -13,815 +13,3488 @@
13
13
  [![license](https://img.shields.io/npm/l/@innet/server)](https://github.com/d8corp/innet-server/blob/main/LICENSE)
14
14
 
15
15
  ## Abstract
16
- This package helps to create server-side application.
16
+ This package helps to create server-side application based on [innet](https://www.npmjs.com/package/innet).
17
17
 
18
- Here you find **JSX components on back-end side** 🎉, cms, routing, proxy, html rendering and more.
18
+ Here you find **JSX components on back-end side** 🎉, Open API generation, Swagger UI in the box, validation, formatting, cms, proxy and more.
19
19
 
20
- Based on [innet](https://www.npmjs.com/package/innet).
20
+ You can create Open API documentation without implementation.
21
+ It helps to define API contracts before start implementing on backend and frontend sides.
21
22
 
22
23
  [![stars](https://img.shields.io/github/stars/d8corp/innet-server?style=social)](https://github.com/d8corp/innet-server/stargazers)
23
24
  [![watchers](https://img.shields.io/github/watchers/d8corp/innet-server?style=social)](https://github.com/d8corp/innet-server/watchers)
24
25
 
26
+ ## Index
27
+
28
+ [Install](#install)
29
+ [Handler](#handler)
30
+ [Usage](#usage)
31
+
32
+ JSX Elements
33
+ [Main](#main)
34
+ [Utils](#utils)
35
+ [API Info](#api-info)
36
+ [Endpoints](#endpoints)
37
+ [Primitive Data](#primitive-data)
38
+ [List of Data](#list-of-data)
39
+ [Run-Time](#run-time)
40
+
41
+ Customize
42
+ [Components](#components)
43
+ [Hooks](#hooks)
44
+
25
45
  ## Install
26
- The simplest way is using `innetjs`
46
+
47
+ [← back](#index)
48
+
49
+ The simplest way to start working with `@innet/server`, it is `innetjs` usage.
27
50
 
28
51
  ```shell
29
- npx innetjs init my-app -t be
52
+ npx innetjs init my-app -t api
30
53
  ```
31
54
  *change my-app to work folder name*
32
55
 
33
56
  Go into `my-app` and check `README.md`
34
57
 
35
- ## Handler
58
+ ## Handler
59
+
60
+ [← back](#index)
61
+
62
+ Use `server` handler to start an application.
63
+
64
+ *src/index.ts*
65
+ ```typescript
66
+ import innet from 'innet'
67
+ import server from '@innet/server'
68
+
69
+ import app from './app'
70
+
71
+ innet(app, server)
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ [← back](#index)
77
+
78
+ Here is a **Hello World** example:
79
+
80
+ *src/app.tsx*
81
+ ```typescript jsx
82
+ export default (
83
+ <server>
84
+ <api />
85
+ </server>
86
+ )
87
+ ```
88
+
89
+ *Use `npm start` to run this server.*
90
+
91
+ Open http://localhost:80
92
+ You will see a base Open API JSON structure.
93
+
94
+ ```json
95
+ {
96
+ "openapi": "3.1.0",
97
+ "info": {
98
+ "title": "",
99
+ "version": "0.0.0"
100
+ },
101
+ "paths": {}
102
+ }
103
+ ```
104
+
105
+ ## Main
106
+
107
+ [← back](#index)
108
+
109
+ [\<server>](#server)
110
+ [\<api>](#api)
111
+
112
+ ---
113
+
114
+ ### \<server>
115
+
116
+ [← back](#main)
117
+
118
+ `<server>` element helps to start http(s) server.
119
+
120
+ *src/app.tsx*
121
+ ```typescript jsx
122
+ export default (
123
+ <server />
124
+ )
125
+ ```
126
+
127
+ #### port
128
+
129
+ Use `port` property to set up the server port:
130
+
131
+ *src/app.tsx*
132
+ ```typescript jsx
133
+ export default (
134
+ <server port={3000} />
135
+ )
136
+ ```
137
+
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.
141
+
142
+ #### ssl
143
+
144
+ To start `https` server, use `ssl` property:
145
+
146
+ *src/app.tsx*
147
+ ```typescript jsx
148
+ export default (
149
+ <server
150
+ ssl={{
151
+ cert: 'url_to_file.crt',
152
+ key: 'url_to_file.key',
153
+ }}
154
+ />
155
+ )
156
+ ```
157
+
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.
160
+ - You can add `localhost.key` and `localhost.crt` files in your project folder.
161
+
162
+ #### onStart
163
+
164
+ Use `onStart` prop to handle server start event.
165
+ You can put `httpOnStart` to the prop.
166
+ This will log URL into console after start the server.
167
+ The URL opens the server app.
168
+
169
+ *src/app.tsx*
170
+ ```typescript jsx
171
+ import { httpOnStart } from '@innet/server'
172
+
173
+ export default (
174
+ <server
175
+ onStart={httpOnStart}
176
+ />
177
+ )
178
+ ```
179
+
180
+ #### onRequest
181
+
182
+ Use `onRequest` to handle any request of the server.
183
+
184
+ *src/app.tsx*
185
+ ```typescript jsx
186
+ export default (
187
+ <server
188
+ onRequest={(req, res) => console.log({
189
+ req,
190
+ res,
191
+ })}
192
+ />
193
+ )
194
+ ```
195
+
196
+ #### onError
197
+
198
+ Use `onError` to handle any request error on the server.
199
+
200
+ *src/app.tsx*
201
+ ```typescript jsx
202
+ export default (
203
+ <server
204
+ onError={error => console.error(error)}
205
+ />
206
+ )
207
+ ```
208
+
209
+ ### \<api>
210
+
211
+ [← back](#main)
212
+
213
+ `<api>` element MUST be placed in `<server>` element.
214
+ This element defines a REST API on the server.
215
+
216
+ #### title
217
+
218
+ This is a title of the API.
219
+ Open API specifies the parameter is REQUIRED.
220
+ But it's NOT REQUIRED in `<api>` element, it equals [empty string](#usage) by default.
221
+
222
+ *src/app.tsx*
223
+ ```typescript jsx
224
+ export default (
225
+ <server>
226
+ <api
227
+ title='@innet/server API'
228
+ />
229
+ </server>
230
+ )
231
+ ```
232
+
233
+ #### description
234
+
235
+ You can add a `description` of the API.
236
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
237
+
238
+ *src/app.tsx*
239
+ ```typescript jsx
240
+ export default (
241
+ <server>
242
+ <api
243
+ description='**MARKDOWN** is available'
244
+ />
245
+ </server>
246
+ )
247
+ ```
248
+
249
+ [innetjs](https://www.npmjs.com/package/innetjs) can help to use a separate file of description:
250
+
251
+ *src/app.tsx*
252
+ ```typescript jsx
253
+ import desc from './desc.md'
254
+
255
+ export default (
256
+ <server>
257
+ <api description={desc} />
258
+ </server>
259
+ )
260
+ ```
261
+
262
+ #### summary
263
+
264
+ Add a short summary of the API.
265
+
266
+ *src/app.tsx*
267
+ ```typescript jsx
268
+ export default (
269
+ <server>
270
+ <api
271
+ summary='Hello World!'
272
+ />
273
+ </server>
274
+ )
275
+ ```
276
+
277
+ #### version
278
+
279
+ The version of the OpenAPI document (which is distinct from the
280
+ [OpenAPI Specification version](https://swagger.io/specification/#oas-version)
281
+ or the API implementation version).
282
+
283
+ *src/app.tsx*
284
+ ```typescript jsx
285
+ export default (
286
+ <server>
287
+ <api
288
+ title='@innet/server API'
289
+ version='1.0.1'
290
+ />
291
+ </server>
292
+ )
293
+ ```
294
+
295
+ *default: 0.0.0*
296
+
297
+ #### prefix
298
+
299
+ URL path prefix scopes the API.
300
+
301
+ *src/app.tsx*
302
+ ```typescript jsx
303
+ export default (
304
+ <server>
305
+ <api
306
+ prefix='/api'
307
+ />
308
+ </server>
309
+ )
310
+ ```
311
+
312
+ ## Utils
313
+
314
+ This section contains elements of utils.
315
+
316
+ [← back](#index)
317
+
318
+ [\<swagger>](#swagger)
319
+ [\<dev>](#dev)
320
+ [\<dts>](#dts)
321
+
322
+ ---
323
+
324
+ ### \<swagger>
325
+
326
+ [← back](#utils)
327
+
328
+ Use `<swagger>` element to add Swagger UI documentation.
329
+ `<swagger>` element MUST be placed in `<api>` element.
330
+
331
+ *src/app.tsx*
332
+ ```typescript jsx
333
+ export default (
334
+ <server>
335
+ <api>
336
+ <swagger />
337
+ </api>
338
+ </server>
339
+ )
340
+ ```
341
+
342
+ Open http://localhost:80/swagger-ui
343
+ You will see Swagger UI documentation.
344
+
345
+ You can change the Swagger UI URL path by `path` property of `<swagger>` element.
346
+
347
+ *src/app.tsx*
348
+ ```typescript jsx
349
+ export default (
350
+ <server>
351
+ <api>
352
+ <swagger path='/swagger' />
353
+ </api>
354
+ </server>
355
+ )
356
+ ```
357
+
358
+ ### \<dev>
359
+
360
+ [← back](#utils)
361
+
362
+ Everything inside <dev> will work when `NODE_ENV` equals `development`.
363
+
364
+ *src/app.tsx*
365
+ ```typescript jsx
366
+ export default (
367
+ <server>
368
+ <api>
369
+ <dev>
370
+ <swagger />
371
+ </dev>
372
+ </api>
373
+ </server>
374
+ )
375
+ ```
376
+
377
+ ### \<dts>
378
+
379
+ [← back](#utils)
380
+
381
+ Use `<dts>` element to add types generation.
382
+ `<dts>` element MUST be placed in `<api>` element.
383
+
384
+ `<dts>` has a required prop of `path`. This is a path of api TypeScript types file, `<dts>` generates it.
385
+
386
+ *src/app.tsx*
387
+ ```typescript jsx
388
+ export default (
389
+ <server>
390
+ <api>
391
+ <dev>
392
+ <dts path='src/api.d.ts' />
393
+ </dev>
394
+ </api>
395
+ </server>
396
+ )
397
+ ```
398
+
399
+ > You MUST add some [endpoint](#endpoint) with some schema otherwise you get the `Error: There is no schema in the input contents`.
400
+
401
+ Here is an example of generated types usage.
402
+
403
+ *src/GetPartner.tsx*
404
+ ```typescript jsx
405
+ import { useParams } from '@innet/server'
406
+
407
+ export function GetPartner () {
408
+ const { id } = useParams<Paths.Partners$Id.Get.PathParameters>()
409
+ return <success>{{ id }}</success>
410
+ }
411
+ ```
412
+
413
+ You do not need to import types, they generate as namespaces.
414
+
415
+ ## API Info
416
+
417
+ The API information elements are here.
418
+
419
+ [← back](#index)
420
+
421
+ [\<license>](#license)
422
+ [\<contact>](#contact)
423
+ [\<host>](#host)
424
+ [\<variable>](#variable)
425
+
426
+ ---
427
+
428
+ ### \<license>
429
+
430
+ [← back](#api-info)
431
+
432
+ `<license>` element MUST be placed in `<api>` element.
433
+ Use `<license>` element to define the API license.
434
+
435
+ #### name
436
+
437
+ REQUIRED prop. The license name used for the API.
438
+
439
+ *src/app.tsx*
440
+ ```typescript jsx
441
+ export default (
442
+ <server>
443
+ <api>
444
+ <license
445
+ name='Apache 2.0'
446
+ />
447
+ </api>
448
+ </server>
449
+ )
450
+ ```
451
+
452
+ #### identifier
453
+
454
+ An [SPDX](https://spdx.org/spdx-specification-21-web-version#h.jxpfx0ykyb60) license expression for the API.
455
+ The `identifier` field is mutually exclusive of the `url` prop.
456
+
457
+ *src/app.tsx*
458
+ ```typescript jsx
459
+ export default (
460
+ <server>
461
+ <api>
462
+ <license
463
+ name='Apache 2.0'
464
+ identifier='Apache-2.0'
465
+ />
466
+ </api>
467
+ </server>
468
+ )
469
+ ```
470
+
471
+ #### url
472
+
473
+ A URL to the license used for the API.
474
+ This MUST be in the form of a URL.
475
+ The `url` field is mutually exclusive of the `identifier` field.
476
+
477
+ *src/app.tsx*
478
+ ```typescript jsx
479
+ export default (
480
+ <server>
481
+ <api>
482
+ <license
483
+ name='Apache 2.0'
484
+ url='https://www.apache.org/licenses/LICENSE-2.0.html'
485
+ />
486
+ </api>
487
+ </server>
488
+ )
489
+ ```
490
+
491
+ ### \<contact>
492
+
493
+ [← back](#api-info)
494
+
495
+ `<contact>` element MUST be placed in `<api>` element.
496
+ The contact information for the exposed API.
497
+
498
+ #### name
499
+
500
+ The identifying name of the contact person/organization.
501
+
502
+ *src/app.tsx*
503
+ ```typescript jsx
504
+ export default (
505
+ <server>
506
+ <api>
507
+ <contact name='Mike' />
508
+ </api>
509
+ </server>
510
+ )
511
+ ```
512
+
513
+ #### email
514
+
515
+ The email address of the contact person/organization.
516
+ This MUST be in the form of an email address.
517
+
518
+ *src/app.tsx*
519
+ ```typescript jsx
520
+ export default (
521
+ <server>
522
+ <api>
523
+ <contact
524
+ email='d8@cantinc.com'
525
+ />
526
+ </api>
527
+ </server>
528
+ )
529
+ ```
530
+
531
+ #### url
532
+
533
+ The URL pointing to the contact information.
534
+ This MUST be in the form of a URL.
535
+
536
+ *src/app.tsx*
537
+ ```typescript jsx
538
+ export default (
539
+ <server>
540
+ <api>
541
+ <contact
542
+ url='https://...'
543
+ />
544
+ </api>
545
+ </server>
546
+ )
547
+ ```
548
+
549
+ ### \<host>
550
+
551
+ [← back](#api-info)
552
+
553
+ `<host>` element MUST be placed in `<api>` element.
554
+
555
+ This element adds a link to related documentation API.
556
+ You can provide many stands like dev, stage or prod.
557
+
558
+ #### url
559
+
560
+ REQUIRED prop of URL to the target host.
561
+
562
+ This URL supports Server Variables and MAY be relative,
563
+ to indicate that the host location is relative to the location where the OpenAPI document is being served.
564
+ Variable substitutions will be made when a variable is named in {brackets}.
565
+
566
+ *src/app.tsx*
567
+ ```typescript jsx
568
+ export default (
569
+ <server>
570
+ <api>
571
+ <host
572
+ url='https://your.address/api'
573
+ />
574
+ </api>
575
+ </server>
576
+ )
577
+ ```
578
+
579
+ #### description
580
+
581
+ An optional string describing the host designated by the URL.
582
+ [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation.
583
+
584
+ *src/app.tsx*
585
+ ```typescript jsx
586
+ export default (
587
+ <server>
588
+ <api>
589
+ <host
590
+ url='https://your.address/api'
591
+ description='Production server'
592
+ />
593
+ </api>
594
+ </server>
595
+ )
596
+ ```
597
+
598
+ ### \<variable>
599
+
600
+ [← back](#api-info)
601
+
602
+ This element MUST be placed in `<host>` element and defines a variable from the `<host>`.
603
+
604
+ #### key
605
+
606
+ REQUIRED props. `key` is a server url parameter.
607
+
608
+ *src/app.tsx*
609
+ ```typescript jsx
610
+ export default (
611
+ <server>
612
+ <api>
613
+ <host
614
+ url='https://{env}.your.address/api'
615
+ description='Test servers'>
616
+ <variable key='env' />
617
+ </host>
618
+ </api>
619
+ </server>
620
+ )
621
+ ```
622
+
623
+ #### value
624
+
625
+ The `value` prop uses for substitution by default.
626
+ If the `values` is defined, the `value` MUST exist in the `values`.
627
+
628
+ *src/app.tsx*
629
+ ```typescript jsx
630
+ export default (
631
+ <server>
632
+ <api>
633
+ <host
634
+ url='https://{env}.your.address/api'
635
+ description='Test servers'>
636
+ <variable
637
+ key='env'
638
+ value='stage'
639
+ />
640
+ </host>
641
+ </api>
642
+ </server>
643
+ )
644
+ ```
645
+
646
+ #### values
647
+
648
+ An enumeration of string values to be used if the substitution options are from a limited set.
649
+ The array MUST NOT be empty.
650
+
651
+ *src/app.tsx*
652
+ ```typescript jsx
653
+ export default (
654
+ <server>
655
+ <api>
656
+ <host
657
+ url='https://{env}.your.address/api'
658
+ description='Test servers'>
659
+ <variable
660
+ key='env'
661
+ values={[
662
+ 'stage',
663
+ 'dev',
664
+ 'qa',
665
+ ]}
666
+ />
667
+ </host>
668
+ </api>
669
+ </server>
670
+ )
671
+ ```
672
+
673
+ #### description
674
+
675
+ An optional description for the server variable.
676
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
677
+
678
+ *src/app.tsx*
679
+ ```typescript jsx
680
+ export default (
681
+ <server>
682
+ <api>
683
+ <host
684
+ url='https://{env}.your.address/api'
685
+ description='Test servers'>
686
+ <variable
687
+ key='env'
688
+ values={[
689
+ 'stage',
690
+ 'dev',
691
+ 'qa',
692
+ ]}
693
+ description='Server environment'
694
+ />
695
+ </host>
696
+ </api>
697
+ </server>
698
+ )
699
+ ```
700
+
701
+ ## Endpoints
702
+
703
+ [← back](#index)
704
+
705
+ [\<endpoint>](#endpoint)
706
+ [\<tag>](#tag)
707
+ [\<param>](#param)
708
+ [\<body>](#body)
709
+ [\<response>](#response)
710
+
711
+ ---
712
+
713
+ ### \<endpoint>
714
+
715
+ [← back](#endpoints)
716
+
717
+ `<endpoint>` defines an endpoint of the API and MUST be placed in `<api>`.
718
+
719
+ `<api>` uses a specific algorithm to find expected endpoint.
720
+
721
+ It does no matter how many endpoints you have.
722
+ It depends on the deep of path pieces.
723
+ If you have the deep equals 1 (`/users`, `/user`, `/login`, `/logout`) the endpoint will be found immediately O(1).
724
+
725
+ #### method
726
+
727
+ A method of the endpoint.
728
+
729
+ MUST be one of `'get' | 'post' | 'put' | 'patch' | 'delete' | 'options' | 'head' | 'trace'`
730
+
731
+ #### path
732
+
733
+ A relative path to an individual endpoint.
734
+
735
+ The property MUST begin with a forward slash (/).
736
+
737
+ Path templating is allowed.
738
+
739
+ When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
740
+ Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.
741
+
742
+ *src/app.tsx*
743
+ ```typescript jsx
744
+ export default (
745
+ <server>
746
+ <api>
747
+ <endpoint
748
+ method='get'
749
+ path='/users'
750
+ />
751
+ </api>
752
+ </server>
753
+ )
754
+ ```
755
+
756
+ #### summary
757
+
758
+ An optional, string summary, intended to apply to all operations in this path.
759
+
760
+ *src/app.tsx*
761
+ ```typescript jsx
762
+ export default (
763
+ <server>
764
+ <api>
765
+ <endpoint
766
+ method='get'
767
+ path='/users'
768
+ summary='Returns users'
769
+ />
770
+ </api>
771
+ </server>
772
+ )
773
+ ```
774
+
775
+ #### description
776
+
777
+ An optional, string description, intended to apply to all operations in this path.
778
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
779
+
780
+ *src/app.tsx*
781
+ ```typescript jsx
782
+ export default (
783
+ <server>
784
+ <api>
785
+ <endpoint
786
+ method='get'
787
+ path='/users'
788
+ description='Users list query'
789
+ />
790
+ </api>
791
+ </server>
792
+ )
793
+ ```
794
+
795
+ #### deprecated
796
+
797
+ Declares this operation to be deprecated.
798
+ Consumers SHOULD refrain from usage of the declared operation.
799
+ Default value is `false`.
800
+
801
+ *src/app.tsx*
802
+ ```typescript jsx
803
+ export default (
804
+ <server>
805
+ <api>
806
+ <endpoint
807
+ method='get'
808
+ path='/users'
809
+ deprecated
810
+ />
811
+ </api>
812
+ </server>
813
+ )
814
+ ```
815
+
816
+ #### private
817
+
818
+ Declares this operation to make an endpoint private.
819
+ That means the endpoint should not be described and will not be shown in the Open API documentation.
820
+
821
+ *src/app.tsx*
822
+ ```typescript jsx
823
+ export default (
824
+ <server>
825
+ <api>
826
+ <endpoint
827
+ method='get'
828
+ path='/users'
829
+ private
830
+ />
831
+ </api>
832
+ </server>
833
+ )
834
+ ```
835
+
836
+ ### \<tag>
837
+
838
+ [← back](#endpoints)
839
+
840
+ You can wrap endpoints by `<tag>` element to group the endpoints.
841
+ You can see the changes in Swagger UI.
842
+
843
+ *src/app.tsx*
844
+ ```typescript jsx
845
+ export default (
846
+ <server>
847
+ <api>
848
+ <tag name='user'>
849
+ <endpoint
850
+ method='get'
851
+ path='/users'
852
+ />
853
+ <endpoint
854
+ method='post'
855
+ path='/users'
856
+ />
857
+ </tag>
858
+ </api>
859
+ </server>
860
+ )
861
+ ```
862
+
863
+ ### \<param>
864
+
865
+ [← back](#endpoints)
866
+
867
+ Describes a single operation parameter.
868
+
869
+ A unique parameter is defined by a combination of a `name` and location.
870
+
871
+ ##### Parameter Locations
872
+
873
+ There are four possible parameter locations specified by the `in` prop:
874
+
875
+ - **path** - Used together with [Path Templating](https://swagger.io/specification/#path-templating), where the parameter value is actually part of the operation's URL.
876
+ This does not include the host or base path of the API. For example, in `/items/{itemId}`, the path parameter is `itemId`.
877
+ - **query** - Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
878
+ - **header** - Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
879
+ - **cookie** - Used to pass a specific cookie value to the API.
880
+
881
+ #### in
882
+
883
+ The location of the parameter.
884
+ Possible values are `"query"`, `"header"`, `"path"` or `"cookie"`.
885
+
886
+ #### name
887
+
888
+ The name of the parameter. Parameter names are *case sensitive*.
889
+
890
+ - 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.
891
+ - If `in` is "header" and the `name` field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.
892
+ - For all other cases, the `name` corresponds to the parameter name used by the `in` property.
893
+
894
+ *src/app.tsx*
895
+ ```typescript jsx
896
+ export default (
897
+ <server>
898
+ <api>
899
+ <endpoint method='get' path='/users/{userId}'>
900
+ <param in='path' name='userId' />
901
+ </endpoint>
902
+ </api>
903
+ </server>
904
+ )
905
+ ```
906
+
907
+ #### description
908
+
909
+ A brief description of the parameter.
910
+ This could contain examples of use.
911
+ [CommonMark syntax](https://spec.commonmark.org) MAY be used for rich text representation.
912
+
913
+ *src/app.tsx*
914
+ ```typescript jsx
915
+ export default (
916
+ <server>
917
+ <api>
918
+ <endpoint method='get' path='/users/{userId}'>
919
+ <param
920
+ in='path'
921
+ name='userId'
922
+ description='User identification number'
923
+ />
924
+ </endpoint>
925
+ </api>
926
+ </server>
927
+ )
928
+ ```
929
+
930
+ #### required
931
+
932
+ Determines whether this parameter is mandatory.
933
+ If the parameter location is "path", this property is `true` and its value MUST be `true`.
934
+ Otherwise, the property MAY be included and its default value is `false`.
935
+
936
+ *src/app.tsx*
937
+ ```typescript jsx
938
+ export default (
939
+ <server>
940
+ <api>
941
+ <endpoint method='get' path='/users'>
942
+ <param
943
+ in='cookie'
944
+ name='token'
945
+ required
946
+ />
947
+ </endpoint>
948
+ </api>
949
+ </server>
950
+ )
951
+ ```
952
+
953
+ #### deprecated
954
+
955
+ Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.
956
+ Default value is `false`.
957
+
958
+ *src/app.tsx*
959
+ ```typescript jsx
960
+ export default (
961
+ <server>
962
+ <api>
963
+ <endpoint method='get' path='/users'>
964
+ <param
965
+ in='query'
966
+ name='status'
967
+ deprecated
968
+ />
969
+ </endpoint>
970
+ </api>
971
+ </server>
972
+ )
973
+ ```
974
+
975
+ ### \<body>
976
+
977
+ [← back](#endpoints)
978
+
979
+ This element MUST be placed inside `<endpoint>`.
980
+ It defines request body for the endpoint.
981
+ `@innet/server` formats and validate the value automatically (real-time).
982
+
983
+ ```typescript jsx
984
+ return (
985
+ <server>
986
+ <api>
987
+ <endpoint method='post' path='/partners'>
988
+ <body>
989
+ <object>
990
+ <field key='name'>
991
+ <string example='CANTent.' />
992
+ </field>
993
+ <field key='gift'>
994
+ <boolean />
995
+ </field>
996
+ <field optional key='addresses'>
997
+ <array>
998
+ <number description='address id' />
999
+ </array>
1000
+ </field>
1001
+ </object>
1002
+ </body>
1003
+ </endpoint>
1004
+ </api>
1005
+ </server>
1006
+ )
1007
+ ```
1008
+
1009
+ ### \<response>
1010
+
1011
+ [← back](#endpoints)
1012
+
1013
+ This element MUST be placed inside `<endpoint>`.
1014
+ It defines response body for the endpoint.
1015
+
1016
+ ## Primitive Data
1017
+
1018
+ [← back](#index)
1019
+
1020
+ [\<null>](#null)
1021
+ [\<boolean>](#boolean)
1022
+ [\<string>](#string)
1023
+ [\<number>](#number)
1024
+ [\<integer>](#integer)
1025
+ [\<date>](#date)
1026
+ [\<uuid>](#uuid)
1027
+ [\<binary>](#binary)
1028
+
1029
+ ### \<boolean>
1030
+
1031
+ [← back](#primitive-data)
1032
+
1033
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1034
+ It defines `boolean` value for a parent element.
1035
+ `@innet/server` formats and validate the value automatically (real-time).
1036
+
1037
+ *src/app.tsx*
1038
+ ```typescript jsx
1039
+ export default (
1040
+ <server>
1041
+ <api>
1042
+ <endpoint method='get' path='/users'>
1043
+ <param
1044
+ in='query'
1045
+ name='active'>
1046
+ <boolean />
1047
+ </param>
1048
+ </endpoint>
1049
+ </api>
1050
+ </server>
1051
+ )
1052
+ ```
1053
+
1054
+ #### default
1055
+
1056
+ A default value for the `boolean`.
1057
+
1058
+ *src/app.tsx*
1059
+ ```typescript jsx
1060
+ export default (
1061
+ <server>
1062
+ <api>
1063
+ <endpoint method='get' path='/users'>
1064
+ <param
1065
+ in='query'
1066
+ name='active'>
1067
+ <boolean default={false} />
1068
+ </param>
1069
+ </endpoint>
1070
+ </api>
1071
+ </server>
1072
+ )
1073
+ ```
1074
+
1075
+ #### example
1076
+
1077
+ An example value.
1078
+
1079
+ *src/app.tsx*
1080
+ ```typescript jsx
1081
+ export default (
1082
+ <server>
1083
+ <api>
1084
+ <endpoint method='get' path='/products'>
1085
+ <param
1086
+ in='query'
1087
+ name='active'>
1088
+ <boolean example={false} />
1089
+ </param>
1090
+ </endpoint>
1091
+ </api>
1092
+ </server>
1093
+ )
1094
+ ```
1095
+
1096
+ #### description
1097
+
1098
+ A description of the `boolean`.
1099
+
1100
+ *src/app.tsx*
1101
+ ```typescript jsx
1102
+ export default (
1103
+ <server>
1104
+ <api>
1105
+ <endpoint method='get' path='/products'>
1106
+ <param
1107
+ in='query'
1108
+ name='active'>
1109
+ <boolean
1110
+ description='Active products param'
1111
+ />
1112
+ </param>
1113
+ </endpoint>
1114
+ </api>
1115
+ </server>
1116
+ )
1117
+ ```
1118
+
1119
+ ### \<string>
1120
+
1121
+ [← back](#primitive-data)
1122
+
1123
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1124
+ It defines `string` value for a parent element.
1125
+ `@innet/server` formats and validate the value automatically (real-time).
1126
+
1127
+ *src/app.tsx*
1128
+ ```typescript jsx
1129
+ export default (
1130
+ <server>
1131
+ <api>
1132
+ <endpoint method='get' path='/users'>
1133
+ <param
1134
+ in='query'
1135
+ name='search'>
1136
+ <string />
1137
+ </param>
1138
+ </endpoint>
1139
+ </api>
1140
+ </server>
1141
+ )
1142
+ ```
1143
+
1144
+ #### default
1145
+
1146
+ A default value for the `string`.
1147
+
1148
+ *src/app.tsx*
1149
+ ```typescript jsx
1150
+ export default (
1151
+ <server>
1152
+ <api>
1153
+ <endpoint method='get' path='/users'>
1154
+ <param
1155
+ in='query'
1156
+ name='status'>
1157
+ <string default='active' />
1158
+ </param>
1159
+ </endpoint>
1160
+ </api>
1161
+ </server>
1162
+ )
1163
+ ```
1164
+
1165
+ *By default, `status` query param equals `active`*
1166
+
1167
+ #### example
1168
+
1169
+ An example value.
1170
+
1171
+ *src/app.tsx*
1172
+ ```typescript jsx
1173
+ export default (
1174
+ <server>
1175
+ <api>
1176
+ <endpoint method='get' path='/products'>
1177
+ <param
1178
+ in='query'
1179
+ name='search'>
1180
+ <string example='red socks' />
1181
+ </param>
1182
+ </endpoint>
1183
+ </api>
1184
+ </server>
1185
+ )
1186
+ ```
1187
+
1188
+ #### description
1189
+
1190
+ A description of the `string`.
1191
+
1192
+ *src/app.tsx*
1193
+ ```typescript jsx
1194
+ export default (
1195
+ <server>
1196
+ <api>
1197
+ <endpoint method='get' path='/products'>
1198
+ <param
1199
+ in='query'
1200
+ name='search'>
1201
+ <string
1202
+ description='A search string'
1203
+ />
1204
+ </param>
1205
+ </endpoint>
1206
+ </api>
1207
+ </server>
1208
+ )
1209
+ ```
1210
+
1211
+ #### values
1212
+
1213
+ The enumeration of available `values`.
1214
+ If you provide the parameter value, which is not in the `values`, the server returns an error.
1215
+
1216
+ *src/app.tsx*
1217
+ ```typescript jsx
1218
+ export default (
1219
+ <server>
1220
+ <api>
1221
+ <endpoint method='get' path='/users'>
1222
+ <param
1223
+ in='query'
1224
+ name='status'>
1225
+ <string
1226
+ default='active'
1227
+ values={[
1228
+ 'active',
1229
+ 'inactive',
1230
+ ]}
1231
+ />
1232
+ </param>
1233
+ </endpoint>
1234
+ </api>
1235
+ </server>
1236
+ )
1237
+ ```
1238
+
1239
+ #### min, max
1240
+
1241
+ Those two props validate the `string` value by minimum and maximum length.
1242
+
1243
+ *src/app.tsx*
1244
+ ```typescript jsx
1245
+ export default (
1246
+ <server>
1247
+ <api>
1248
+ <endpoint method='get' path='/products'>
1249
+ <param in='query' name='name'>
1250
+ <string min={1} max={128} />
1251
+ </param>
1252
+ </endpoint>
1253
+ </api>
1254
+ </server>
1255
+ )
1256
+ ```
1257
+
1258
+ #### pattern
1259
+
1260
+ A `string` of `RegExp` or `RegExp`.
1261
+
1262
+ *src/app.tsx*
1263
+ ```typescript jsx
1264
+ export default (
1265
+ <server>
1266
+ <api>
1267
+ <endpoint method='get' path='/products'>
1268
+ <param in='query' name='friendlyName'>
1269
+ <string pattern='^[a-z_0-9]+$' />
1270
+ </param>
1271
+ </endpoint>
1272
+ </api>
1273
+ </server>
1274
+ )
1275
+ ```
1276
+
1277
+ If you make a request to the API endpoint,
1278
+ with query parameter of `friendlyName` equals `no-friendly` (as example),
1279
+ you get an error:
1280
+
1281
+ ```json
1282
+ {
1283
+ "error": "requestValidation",
1284
+ "data": {
1285
+ "error": "reg",
1286
+ "data": {
1287
+ "key": "friendlyName"
1288
+ },
1289
+ "in": "search"
1290
+ }
1291
+ }
1292
+ ```
1293
+
1294
+ #### patternId
1295
+
1296
+ This property adds an id of the pattern expression in error response.
1297
+ For example, You can use the id to load error message translations.
1298
+
1299
+ *src/app.tsx*
1300
+ ```typescript jsx
1301
+ export default (
1302
+ <server>
1303
+ <api>
1304
+ <endpoint method='get' path='/products'>
1305
+ <param in='query' name='friendlyName'>
1306
+ <string
1307
+ pattern='^[a-z_0-9]+$'
1308
+ patternID='fname'
1309
+ />
1310
+ </param>
1311
+ </endpoint>
1312
+ </api>
1313
+ </server>
1314
+ )
1315
+ ```
1316
+
1317
+ If you make a request to the API endpoint,
1318
+ with query parameter of `friendlyName` equals `no-friendly` (as example),
1319
+ you get an error:
1320
+
1321
+ ```json
1322
+ {
1323
+ "error": "requestValidation",
1324
+ "data": {
1325
+ "error": "reg",
1326
+ "data": {
1327
+ "key": "friendlyName",
1328
+ "regId": "fname"
1329
+ },
1330
+ "in": "search"
1331
+ }
1332
+ }
1333
+ ```
1334
+
1335
+ ### \<number>
1336
+
1337
+ [← back](#primitive-data)
1338
+
1339
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1340
+ It defines `number` value for a parent element.
1341
+ `@innet/server` formats and validate the value automatically (real-time).
1342
+
1343
+ Correct numbers are from `-9007199254740991` to `9007199254740991`.
1344
+ This is a value of `Number.MAX_SAFE_INTEGER`.
1345
+
1346
+ *src/app.tsx*
1347
+ ```typescript jsx
1348
+ export default (
1349
+ <server>
1350
+ <api>
1351
+ <endpoint method='get' path='/users'>
1352
+ <param
1353
+ in='query'
1354
+ name='minAge'>
1355
+ <number />
1356
+ </param>
1357
+ </endpoint>
1358
+ </api>
1359
+ </server>
1360
+ )
1361
+ ```
1362
+
1363
+ *This example defines a `GET` endpoint on `/users` which has an optional query `number` parameter of `minAge`.*
1364
+
1365
+ #### default
1366
+
1367
+ A default value for the `number`.
1368
+
1369
+ *src/app.tsx*
1370
+ ```typescript jsx
1371
+ export default (
1372
+ <server>
1373
+ <api>
1374
+ <endpoint method='get' path='/users'>
1375
+ <param
1376
+ in='query'
1377
+ name='minAge'>
1378
+ <number default={18} />
1379
+ </param>
1380
+ </endpoint>
1381
+ </api>
1382
+ </server>
1383
+ )
1384
+ ```
1385
+
1386
+ *By default, `minAge` query param equals `18`*
1387
+
1388
+ #### example
1389
+
1390
+ An example value.
1391
+
1392
+ *src/app.tsx*
1393
+ ```typescript jsx
1394
+ export default (
1395
+ <server>
1396
+ <api>
1397
+ <endpoint method='get' path='/users'>
1398
+ <param
1399
+ in='query'
1400
+ name='minAge'>
1401
+ <number example={18} />
1402
+ </param>
1403
+ </endpoint>
1404
+ </api>
1405
+ </server>
1406
+ )
1407
+ ```
1408
+
1409
+ #### description
1410
+
1411
+ A description of the `number`.
1412
+
1413
+ *src/app.tsx*
1414
+ ```typescript jsx
1415
+ export default (
1416
+ <server>
1417
+ <api>
1418
+ <endpoint method='get' path='/users'>
1419
+ <param
1420
+ in='query'
1421
+ name='minAge'>
1422
+ <number
1423
+ example={18}
1424
+ description='Age value'
1425
+ />
1426
+ </param>
1427
+ </endpoint>
1428
+ </api>
1429
+ </server>
1430
+ )
1431
+ ```
1432
+
1433
+ #### values
1434
+
1435
+ The enumeration of available `values`.
1436
+ If you provide the parameter value, which is not in the `values`, the server returns an error.
1437
+
1438
+ *src/app.tsx*
1439
+ ```typescript jsx
1440
+ export default (
1441
+ <server>
1442
+ <api>
1443
+ <endpoint method='get' path='/users'>
1444
+ <param
1445
+ in='query'
1446
+ name='minAge'>
1447
+ <number
1448
+ example={18}
1449
+ values={[
1450
+ 12,
1451
+ 16,
1452
+ 18,
1453
+ 21,
1454
+ ]}
1455
+ />
1456
+ </param>
1457
+ </endpoint>
1458
+ </api>
1459
+ </server>
1460
+ )
1461
+ ```
1462
+
1463
+ #### min, max
1464
+
1465
+ Those two props validate the number value by minimum and maximum values.
1466
+
1467
+ *src/app.tsx*
1468
+ ```typescript jsx
1469
+ export default (
1470
+ <server>
1471
+ <api>
1472
+ <endpoint method='get' path='/products'>
1473
+ <param in='query' name='rating'>
1474
+ <number min={1} max={5} />
1475
+ </param>
1476
+ </endpoint>
1477
+ </api>
1478
+ </server>
1479
+ )
1480
+ ```
1481
+
1482
+ *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
1483
+
1484
+ ### \<integer>
1485
+
1486
+ [← back](#primitive-data)
1487
+
1488
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1489
+ It defines `integer` value for a parent element.
1490
+ `@innet/server` formats and validate the value automatically (real-time).
1491
+
1492
+ *src/app.tsx*
1493
+ ```typescript jsx
1494
+ export default (
1495
+ <server>
1496
+ <api>
1497
+ <endpoint method='get' path='/users'>
1498
+ <param
1499
+ in='query'
1500
+ name='minAge'>
1501
+ <integer />
1502
+ </param>
1503
+ </endpoint>
1504
+ </api>
1505
+ </server>
1506
+ )
1507
+ ```
1508
+
1509
+ *This example defines a `GET` endpoint on `/users` which has an optional query `integer` parameter of `minAge`.*
1510
+
1511
+ #### format
1512
+
1513
+ You can set up the `integer` format.
1514
+ Possible values are `int32` or `int64`.
1515
+ By default, there are `int32` used.
1516
+
1517
+ The format of `int32` means a number from `-2147483647` to `2147483647`.
1518
+ The format of `int64` converts the value to `BigInt` and placed between `-9223372036854775807` and `9223372036854775807`
1519
+
1520
+
1521
+ *src/app.tsx*
1522
+ ```typescript jsx
1523
+ export default (
1524
+ <server>
1525
+ <api>
1526
+ <endpoint method='get' path='/users'>
1527
+ <param
1528
+ in='query'
1529
+ name='minAge'>
1530
+ <integer format='int64' />
1531
+ </param>
1532
+ </endpoint>
1533
+ </api>
1534
+ </server>
1535
+ )
1536
+ ```
1537
+
1538
+ #### default
1539
+
1540
+ A default value for the `integer`.
1541
+
1542
+ *src/app.tsx*
1543
+ ```typescript jsx
1544
+ export default (
1545
+ <server>
1546
+ <api>
1547
+ <endpoint method='get' path='/users'>
1548
+ <param
1549
+ in='query'
1550
+ name='minAge'>
1551
+ <integer default={18} />
1552
+ </param>
1553
+ </endpoint>
1554
+ </api>
1555
+ </server>
1556
+ )
1557
+ ```
1558
+
1559
+ *By default, `minAge` query param equals `18`*
1560
+
1561
+ #### example
1562
+
1563
+ An example value.
1564
+
1565
+ *src/app.tsx*
1566
+ ```typescript jsx
1567
+ export default (
1568
+ <server>
1569
+ <api>
1570
+ <endpoint method='get' path='/users'>
1571
+ <param
1572
+ in='query'
1573
+ name='minAge'>
1574
+ <integer example={18} />
1575
+ </param>
1576
+ </endpoint>
1577
+ </api>
1578
+ </server>
1579
+ )
1580
+ ```
1581
+
1582
+ #### description
1583
+
1584
+ A description of the `integer`.
1585
+
1586
+ *src/app.tsx*
1587
+ ```typescript jsx
1588
+ export default (
1589
+ <server>
1590
+ <api>
1591
+ <endpoint method='get' path='/users'>
1592
+ <param
1593
+ in='query'
1594
+ name='minAge'>
1595
+ <integer
1596
+ example={18}
1597
+ description='Age value'
1598
+ />
1599
+ </param>
1600
+ </endpoint>
1601
+ </api>
1602
+ </server>
1603
+ )
1604
+ ```
1605
+
1606
+ #### values
1607
+
1608
+ The enumeration of available `values`.
1609
+ If you provide the parameter value, which is not in the `values`, the server returns an error.
1610
+
1611
+ *src/app.tsx*
1612
+ ```typescript jsx
1613
+ export default (
1614
+ <server>
1615
+ <api>
1616
+ <endpoint method='get' path='/users'>
1617
+ <param
1618
+ in='query'
1619
+ name='minAge'>
1620
+ <integer
1621
+ example={18}
1622
+ values={[
1623
+ 12,
1624
+ 16,
1625
+ 18,
1626
+ 21,
1627
+ ]}
1628
+ />
1629
+ </param>
1630
+ </endpoint>
1631
+ </api>
1632
+ </server>
1633
+ )
1634
+ ```
1635
+
1636
+ #### min, max
1637
+
1638
+ Those two props validate the number value by minimum and maximum values.
1639
+
1640
+ *src/app.tsx*
1641
+ ```typescript jsx
1642
+ export default (
1643
+ <server>
1644
+ <api>
1645
+ <endpoint method='get' path='/products'>
1646
+ <param in='query' name='rating'>
1647
+ <integer min={1} max={5} />
1648
+ </param>
1649
+ </endpoint>
1650
+ </api>
1651
+ </server>
1652
+ )
1653
+ ```
1654
+
1655
+ *In this example `/products?rating=5` is valid and `/products?rating=6` is not*
1656
+
1657
+ ### \<date>
1658
+
1659
+ [← back](#primitive-data)
1660
+
1661
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1662
+ It defines `date` value for a parent element.
1663
+ `@innet/server` formats and validate the value automatically (real-time).
1664
+
1665
+ *src/app.tsx*
1666
+ ```typescript jsx
1667
+ export default (
1668
+ <server>
1669
+ <api>
1670
+ <endpoint method='get' path='/users'>
1671
+ <param
1672
+ in='query'
1673
+ name='birthday'>
1674
+ <date />
1675
+ </param>
1676
+ </endpoint>
1677
+ </api>
1678
+ </server>
1679
+ )
1680
+ ```
1681
+
1682
+ #### default
1683
+
1684
+ A default value for the `date`.
1685
+ Available values:
1686
+ - `string` - the date in ISO format
1687
+ - `number` - date timestamp
1688
+ - `Date` - JavaScript `Date` format
1689
+ - `'now'` - the string defines current date as default value.
1690
+
1691
+ *src/app.tsx*
1692
+ ```typescript jsx
1693
+ export default (
1694
+ <server>
1695
+ <api>
1696
+ <endpoint method='get' path='/users'>
1697
+ <param
1698
+ in='query'
1699
+ name='birthday'>
1700
+ <date default='1950-02-15' />
1701
+ </param>
1702
+ </endpoint>
1703
+ </api>
1704
+ </server>
1705
+ )
1706
+ ```
1707
+
1708
+ #### values
1709
+
1710
+ The enumeration of available `values`.
1711
+ If you provide the parameter value, which is not in the `values`, the server returns an error.
1712
+
1713
+ Available values:
1714
+ - `string` - the date in ISO format
1715
+ - `number` - date timestamp
1716
+ - `Date` - JavaScript `Date` format
1717
+
1718
+ *src/app.tsx*
1719
+ ```typescript jsx
1720
+ export default (
1721
+ <server>
1722
+ <api>
1723
+ <endpoint method='get' path='/users'>
1724
+ <param
1725
+ in='query'
1726
+ name='birthday'>
1727
+ <date
1728
+ values={[
1729
+ 1,
1730
+ new Date(),
1731
+ '1950-02-15',
1732
+ ]}
1733
+ />
1734
+ </param>
1735
+ </endpoint>
1736
+ </api>
1737
+ </server>
1738
+ )
1739
+ ```
1740
+
1741
+ #### example
1742
+
1743
+ An example value.
1744
+
1745
+ Available values:
1746
+ - `string` - the date in ISO format
1747
+ - `number` - date timestamp
1748
+ - `Date` - JavaScript `Date` format
1749
+ - `'now'` - the string defines server start date as example.
1750
+
1751
+ *src/app.tsx*
1752
+ ```typescript jsx
1753
+ export default (
1754
+ <server>
1755
+ <api>
1756
+ <endpoint method='get' path='/users'>
1757
+ <param
1758
+ in='query'
1759
+ name='birthday'>
1760
+ <date example={0} />
1761
+ </param>
1762
+ </endpoint>
1763
+ </api>
1764
+ </server>
1765
+ )
1766
+ ```
1767
+
1768
+ #### description
1769
+
1770
+ A description of the `date`.
1771
+
1772
+ *src/app.tsx*
1773
+ ```typescript jsx
1774
+ export default (
1775
+ <server>
1776
+ <api>
1777
+ <endpoint method='get' path='/users'>
1778
+ <param
1779
+ in='query'
1780
+ name='birthday'>
1781
+ <date
1782
+ description='The user birthday'
1783
+ />
1784
+ </param>
1785
+ </endpoint>
1786
+ </api>
1787
+ </server>
1788
+ )
1789
+ ```
1790
+
1791
+ #### min, max
1792
+
1793
+ Those two pros limit the date period.
1794
+
1795
+ Available values:
1796
+ - `string` - the date in ISO format
1797
+ - `number` - date timestamp
1798
+ - `Date` - JavaScript `Date` format
1799
+ - `'now'` - the string defines current server date as default.
1800
+
1801
+ *src/app.tsx*
1802
+ ```typescript jsx
1803
+ export default (
1804
+ <server>
1805
+ <api>
1806
+ <endpoint method='get' path='/users'>
1807
+ <param
1808
+ in='query'
1809
+ name='birthday'>
1810
+ <date
1811
+ min='01-01-1900'
1812
+ max='now'
1813
+ description='The user birthday'
1814
+ />
1815
+ </param>
1816
+ </endpoint>
1817
+ </api>
1818
+ </server>
1819
+ )
1820
+ ```
1821
+
1822
+ ### \<uuid>
1823
+
1824
+ [← back](#primitive-data)
1825
+
1826
+ Universally unique identifier.
1827
+
1828
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
1829
+ It defines `string` value in `uuid` format for a parent element.
1830
+ `@innet/server` formats and validate the value automatically (real-time).
1831
+
1832
+ *src/app.tsx*
1833
+ ```typescript jsx
1834
+ export default (
1835
+ <server>
1836
+ <api>
1837
+ <endpoint method='post' path='/users'>
1838
+ <param
1839
+ in='cookie'
1840
+ name='userId'>
1841
+ <uuid />
1842
+ </param>
1843
+ </endpoint>
1844
+ </api>
1845
+ </server>
1846
+ )
1847
+ ```
1848
+
1849
+ #### default
1850
+
1851
+ A default value for the `uuid`.
1852
+
1853
+ Available values:
1854
+ - `string` in uuid format
1855
+ - `new` generates a new uuid
1856
+
1857
+ *src/app.tsx*
1858
+ ```typescript jsx
1859
+ export default (
1860
+ <server>
1861
+ <api>
1862
+ <endpoint method='post' path='/users'>
1863
+ <param
1864
+ in='cookie'
1865
+ name='userId'>
1866
+ <uuid default='new' />
1867
+ </param>
1868
+ </endpoint>
1869
+ </api>
1870
+ </server>
1871
+ )
1872
+ ```
1873
+
1874
+ #### values
1875
+
1876
+ The enumeration of available `values`.
1877
+ If you provide the parameter value, which is not in the `values`, the server returns an error.
1878
+
1879
+ *src/app.tsx*
1880
+ ```typescript jsx
1881
+ export default (
1882
+ <server>
1883
+ <api>
1884
+ <endpoint method='post' path='/users'>
1885
+ <param
1886
+ in='header'
1887
+ name='uuid'>
1888
+ <uuid
1889
+ values={[
1890
+ '123e4567-e89b-12d3-a456-426655440000',
1891
+ '123e4567-e89b-12d3-a456-426614174000',
1892
+ ]}
1893
+ />
1894
+ </param>
1895
+ </endpoint>
1896
+ </api>
1897
+ </server>
1898
+ )
1899
+ ```
1900
+
1901
+ #### example
1902
+
1903
+ An example value.
1904
+
1905
+ *src/app.tsx*
1906
+ ```typescript jsx
1907
+ export default (
1908
+ <server>
1909
+ <api>
1910
+ <endpoint method='post' path='/users'>
1911
+ <param
1912
+ in='query'
1913
+ name='active'>
1914
+ <uuid
1915
+ default='new'
1916
+ example='123e4567-e89b-12d3-a456-426655440000'
1917
+ />
1918
+ </param>
1919
+ </endpoint>
1920
+ </api>
1921
+ </server>
1922
+ )
1923
+ ```
1924
+
1925
+ #### description
1926
+
1927
+ A description of the `boolean`.
1928
+
1929
+ *src/app.tsx*
1930
+ ```typescript jsx
1931
+ export default (
1932
+ <server>
1933
+ <api>
1934
+ <endpoint method='post' path='/users'>
1935
+ <param
1936
+ in='cookie'
1937
+ name='userId'>
1938
+ <uuid
1939
+ default='new'
1940
+ example='123e4567-e89b-12d3-a456-426655440000'
1941
+ description='User ID for a new user'
1942
+ />
1943
+ </param>
1944
+ </endpoint>
1945
+ </api>
1946
+ </server>
1947
+ )
1948
+ ```
1949
+
1950
+ ### \<binary>
1951
+
1952
+ [← back](#primitive-data)
1953
+
1954
+ This is a binary type of data.
1955
+ There is one way to get the type, it is `multipart/form-data` usage.
1956
+
1957
+ *src/app.tsx*
1958
+ ```typescript jsx
1959
+ export default (
1960
+ <server>
1961
+ <api>
1962
+ <endpoint method='post' path='/partner'>
1963
+ <body>
1964
+ <object>
1965
+ <field key='icon'>
1966
+ <binary />
1967
+ </field>
1968
+ <field key='name'>
1969
+ <string />
1970
+ </field>
1971
+ </object>
1972
+ </body>
1973
+ </endpoint>
1974
+ </api>
1975
+ </server>
1976
+ )
1977
+ ```
1978
+
1979
+ #### description
1980
+
1981
+ A description of the `binary`.
1982
+
1983
+ *src/app.tsx*
1984
+ ```typescript jsx
1985
+ export default (
1986
+ <server>
1987
+ <api>
1988
+ <endpoint method='post' path='/partner'>
1989
+ <body>
1990
+ <object>
1991
+ <field key='icon'>
1992
+ <binary
1993
+ description='Square icon of the partner'
1994
+ />
1995
+ </field>
1996
+ </object>
1997
+ </body>
1998
+ </endpoint>
1999
+ </api>
2000
+ </server>
2001
+ )
2002
+ ```
2003
+
2004
+ #### accept
2005
+
2006
+ This prop defines available file format.
2007
+ It works the same as [accept](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/accept) attribute of HTML input element.
2008
+
2009
+ *src/app.tsx*
2010
+ ```typescript jsx
2011
+ export default (
2012
+ <server>
2013
+ <api>
2014
+ <endpoint method='post' path='/partner'>
2015
+ <body>
2016
+ <object>
2017
+ <field key='icon'>
2018
+ <binary
2019
+ accept='image/jpeg'
2020
+ description='Square icon of the partner'
2021
+ />
2022
+ </field>
2023
+ </object>
2024
+ </body>
2025
+ </endpoint>
2026
+ </api>
2027
+ </server>
2028
+ )
2029
+ ```
2030
+
2031
+ #### min, max
2032
+
2033
+ Those two pros limit the file size.
2034
+
2035
+ *src/app.tsx*
2036
+ ```typescript jsx
2037
+ export default (
2038
+ <server>
2039
+ <api>
2040
+ <endpoint method='post' path='/partner'>
2041
+ <body>
2042
+ <object>
2043
+ <field key='icon'>
2044
+ <binary
2045
+ accept='image/jpeg'
2046
+ description='Square icon of the partner'
2047
+ min={1024}
2048
+ max={10 * 1024 ** 2}
2049
+ />
2050
+ </field>
2051
+ </object>
2052
+ </body>
2053
+ </endpoint>
2054
+ </api>
2055
+ </server>
2056
+ )
2057
+ ```
2058
+
2059
+ ## List of Data
2060
+
2061
+ [← back](#index)
2062
+
2063
+ [\<tuple>](#tuple)
2064
+ [\<array>](#array)
2065
+ [\<object>](#object)
2066
+ [\<field>](#field)
2067
+
2068
+ ---
2069
+
2070
+ ### \<tuple>
2071
+
2072
+ [← back](#list-of-data)
36
2073
 
37
- Use `server` handler to start an application.
38
- ```typescript
39
- import innet from 'innet'
40
- import server from '@innet/server'
2074
+ `<tuple>` element specifies schema parameter as a tuple of children elements.
41
2075
 
42
- import app from './app'
2076
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
43
2077
 
44
- innet(app, server)
2078
+ *src/app.tsx*
2079
+ ```typescript jsx
2080
+ export default (
2081
+ <server>
2082
+ <api>
2083
+ <endpoint method='get' path='/products'>
2084
+ <param name='rating' in='query'>
2085
+ <tuple>
2086
+ <number min={1} max={5} />
2087
+ <number min={1} max={5} />
2088
+ </tuple>
2089
+ </param>
2090
+ </endpoint>
2091
+ </api>
2092
+ </server>
2093
+ )
45
2094
  ```
46
2095
 
47
- ## Server
48
- To start http(s) server, use `server` element.
2096
+ This example defines that, `/products?rating=3&rating=4` is valid and `rating` MUST be from `3` to `4`.
2097
+ Also supports formats `/products?rating[]=3&rating[]=4` and `/products?rating[0]=3&rating[1]=4`.
49
2098
 
50
- Try it out in `app.tsx`
2099
+ `/products?rating=3` or `/products?rating=1&rating=6` returns an error.
2100
+
2101
+ You can add several elements in [\<response>](#response), [\<param>](#param) or [\<body>](#body) to define that one of the element is valid.
2102
+
2103
+ *src/app.tsx*
51
2104
  ```typescript jsx
52
2105
  export default (
53
2106
  <server>
54
- Hello World!
2107
+ <api>
2108
+ <endpoint method='get' path='/products'>
2109
+ <param in='query' name='rating'>
2110
+ <number min={1} max={5} />
2111
+ <tuple>
2112
+ <number min={1} max={5} />
2113
+ <number min={1} max={5} />
2114
+ </tuple>
2115
+ </param>
2116
+ </endpoint>
2117
+ </api>
55
2118
  </server>
56
2119
  )
57
2120
  ```
58
2121
 
59
- Any content inside the server will be turned back to user.
60
- In this case the user will get `Hello World` on any request.
2122
+ This example defines that, `/products?rating=3&rating=4` is valid and `rating` MUST be from `3` to `4`.
2123
+ Also supports `/products?rating=3`, returns products have `rating` equals `3`.
61
2124
 
62
- Use `npm start` to run this server.
2125
+ `/products?rating=text` or `/products?rating=1&rating=6` returns an error.
63
2126
 
64
- ### Port
65
- To change the port of the web server you can use `port` prop.
2127
+ #### default
66
2128
 
2129
+ Defines default `<tuple>` value.
2130
+
2131
+ *src/app.tsx*
67
2132
  ```typescript jsx
68
2133
  export default (
69
- <server port={80}>
70
- Hello World!
2134
+ <server>
2135
+ <api>
2136
+ <endpoint method='get' path='/products'>
2137
+ <param in='query' name='rating'>
2138
+ <number min={1} max={5} />
2139
+ <tuple default={[1, 5]}>
2140
+ <number min={1} max={5} />
2141
+ <number min={1} max={5} />
2142
+ </tuple>
2143
+ </param>
2144
+ </endpoint>
2145
+ </api>
71
2146
  </server>
72
2147
  )
73
2148
  ```
74
2149
 
75
- or you can use `PORT` environment variable.
2150
+ #### example
76
2151
 
77
- ### SSL
78
- To have https connection you should provide SSL certificate.
2152
+ Defines an example of the `<tuple>` value.
79
2153
 
2154
+ *src/app.tsx*
80
2155
  ```typescript jsx
81
- const ssl = {
82
- key: 'local.key',
83
- cert: 'local.crt'
84
- }
85
-
86
2156
  export default (
87
- <server ssl={ssl}>
88
- Hello World!
2157
+ <server>
2158
+ <api>
2159
+ <endpoint method='get' path='/products'>
2160
+ <param in='query' name='rating'>
2161
+ <number min={1} max={5} />
2162
+ <tuple default={[1, 5]} example={[3, 5]}>
2163
+ <number min={1} max={5} />
2164
+ <number min={1} max={5} />
2165
+ </tuple>
2166
+ </param>
2167
+ </endpoint>
2168
+ </api>
89
2169
  </server>
90
2170
  )
91
2171
  ```
92
2172
 
93
- or you can use `SSL_CRT` and `SSL_KEY` environment variables.
2173
+ #### description
2174
+
2175
+ Defines the `<tuple>` description.
94
2176
 
95
- ### onStart
96
- You can show some message or do something right after the server starts.
2177
+ *src/app.tsx*
97
2178
  ```typescript jsx
98
2179
  export default (
99
- <server onStart={console.log}>
100
- Hello World!
2180
+ <server>
2181
+ <api>
2182
+ <endpoint method='get' path='/products'>
2183
+ <param in='query' name='rating'>
2184
+ <number min={1} max={5} />
2185
+ <tuple
2186
+ description='A range of rating score'
2187
+ default={[1, 5]}
2188
+ example={[3, 5]}>
2189
+ <number min={1} max={5} />
2190
+ <number min={1} max={5} />
2191
+ </tuple>
2192
+ </param>
2193
+ </endpoint>
2194
+ </api>
101
2195
  </server>
102
2196
  )
103
2197
  ```
104
2198
 
105
- ### onError
106
- You can log errors or do something else, when the server get an error.
2199
+ ### \<array>
2200
+
2201
+ [← back](#list-of-data)
2202
+
2203
+ `<array>` element specifies schema parameter as an array of children elements.
2204
+
2205
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
107
2206
 
2207
+ *src/app.tsx*
108
2208
  ```typescript jsx
109
2209
  export default (
110
- <server onError={console.error}>
111
- Hello World!
2210
+ <server>
2211
+ <api>
2212
+ <endpoint method='get' path='/products'>
2213
+ <param in='query' name='rating'>
2214
+ <array>
2215
+ <number min={1} max={5} />
2216
+ </array>
2217
+ </param>
2218
+ </endpoint>
2219
+ </api>
112
2220
  </server>
113
2221
  )
114
2222
  ```
115
2223
 
116
- ### onRequest
117
- You can log any request with `onRequest` prop.
2224
+ This example defines that, `/products?rating=3&rating=4` is valid and `rating` MUST be `3` or `4`.
2225
+ Also supports formats `/products?rating[]=3&rating[]=4` and `/products?rating[0]=3&rating[1]=4`.
2226
+
2227
+ `/products?rating=3` and `/products?rating=1&rating=2&rating=3` also support.
2228
+
2229
+ #### default
2230
+
2231
+ Defines default `<array>` value.
118
2232
 
2233
+ *src/app.tsx*
119
2234
  ```typescript jsx
120
2235
  export default (
121
- <server onRequest={console.log}>
122
- Hello World!
2236
+ <server>
2237
+ <api>
2238
+ <endpoint method='get' path='/products'>
2239
+ <param in='query' name='rating'>
2240
+ <array default={[1, 2, 3, 4, 5]}>
2241
+ <number min={1} max={5} />
2242
+ </array>
2243
+ </param>
2244
+ </endpoint>
2245
+ </api>
123
2246
  </server>
124
2247
  )
125
2248
  ```
126
2249
 
127
- ### onDestroy
128
- You can react on destroy the server with `onDestroy` prop.
2250
+ #### example
2251
+
2252
+ Defines an example of the `<array>` value.
129
2253
 
2254
+ *src/app.tsx*
130
2255
  ```typescript jsx
131
2256
  export default (
132
- <server
133
- onDestroy={() => console.log('destroy')}>
134
- Hello World!
2257
+ <server>
2258
+ <api>
2259
+ <endpoint method='get' path='/products'>
2260
+ <param in='query' name='rating'>
2261
+ <array example={[1, 3, 5]}>
2262
+ <number min={1} max={5} />
2263
+ </array>
2264
+ </param>
2265
+ </endpoint>
2266
+ </api>
135
2267
  </server>
136
2268
  )
137
2269
  ```
138
2270
 
139
- ## HTML
140
- You can use `html` element to return html content.
2271
+ #### description
141
2272
 
2273
+ Defines the `<array>` description.
2274
+
2275
+ *src/app.tsx*
142
2276
  ```typescript jsx
143
2277
  export default (
144
2278
  <server>
145
- <html>
146
- <head>
147
- <title>Innet App</title>
148
- </head>
149
- <body>
150
- Hello World!
151
- </body>
152
- </html>
2279
+ <api>
2280
+ <endpoint method='get' path='/products'>
2281
+ <param in='query' name='rating'>
2282
+ <array
2283
+ description='Values of rating score'
2284
+ example={[3, 5]}>
2285
+ <number min={1} max={5} />
2286
+ </array>
2287
+ </param>
2288
+ </endpoint>
2289
+ </api>
153
2290
  </server>
154
2291
  )
155
2292
  ```
156
2293
 
157
- You can use variables to split it anyhow.
2294
+ ### \<object>
2295
+
2296
+ [← back](#list-of-data)
158
2297
 
2298
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
2299
+ It defines `object` value for a parent element.
2300
+ `@innet/server` formats and validate the value automatically (real-time).
2301
+
2302
+ *src/app.tsx*
159
2303
  ```typescript jsx
160
- const content = (
161
- <html>
162
- <head>
163
- <title>Innet App</title>
164
- </head>
165
- <body>
166
- Hello World!
167
- </body>
168
- </html>
2304
+ export default (
2305
+ <server>
2306
+ <api>
2307
+ <endpoint method='post' path='/users'>
2308
+ <body>
2309
+ <object />
2310
+ </body>
2311
+ </endpoint>
2312
+ </api>
2313
+ </server>
169
2314
  )
2315
+ ```
2316
+
2317
+ #### default
170
2318
 
2319
+ A default value for the `object`.
2320
+
2321
+ *src/app.tsx*
2322
+ ```typescript jsx
171
2323
  export default (
172
2324
  <server>
173
- {content}
2325
+ <api>
2326
+ <endpoint method='post' path='/users'>
2327
+ <body>
2328
+ <object
2329
+ default={{name: 'John'}}
2330
+ />
2331
+ </body>
2332
+ </endpoint>
2333
+ </api>
174
2334
  </server>
175
2335
  )
176
2336
  ```
177
2337
 
178
- ## Header
179
- You can add an HTTP header into response with `header` element.
2338
+ #### example
180
2339
 
181
- ```typescript jsx
182
- const content = (
183
- <html.../>
184
- ) // check prev example
2340
+ An example value.
185
2341
 
2342
+ *src/app.tsx*
2343
+ ```typescript jsx
186
2344
  export default (
187
2345
  <server>
188
- <header name='content-type' value='text/html'>
189
- {content}
190
- </header>
2346
+ <api>
2347
+ <endpoint method='post' path='/users'>
2348
+ <body>
2349
+ <object
2350
+ example={{name: 'John'}}
2351
+ />
2352
+ </body>
2353
+ </endpoint>
2354
+ </api>
191
2355
  </server>
192
2356
  )
193
2357
  ```
194
2358
 
195
- Also, you can put header around the content, it works the same.
2359
+ #### description
196
2360
 
197
- ```typescript jsx
198
- const content = (
199
- <html.../>
200
- ) // check prev example
2361
+ A description of the `object`.
201
2362
 
2363
+ *src/app.tsx*
2364
+ ```typescript jsx
202
2365
  export default (
203
2366
  <server>
204
- <header name='content-type' value='text/html' />
205
- {content}
2367
+ <api>
2368
+ <endpoint method='post' path='/users'>
2369
+ <body>
2370
+ <object
2371
+ description='The object of a user'
2372
+ />
2373
+ </body>
2374
+ </endpoint>
2375
+ </api>
206
2376
  </server>
207
2377
  )
208
2378
  ```
209
2379
 
210
- ## File
211
- You can return a file as a response.
2380
+ ### \<field>
2381
+
2382
+ [← back](#list-of-data)
2383
+
2384
+ The element MUST be placed inside [\<object>](#object).
2385
+ It defines a `field` of an `object` value for a parent element.
2386
+ `@innet/server` formats and validate the value automatically (real-time).
212
2387
 
2388
+ `key` is REQUIRED prop of `<field>`, it defines a field name of the `<object>`.
2389
+
2390
+ *src/app.tsx*
213
2391
  ```typescript jsx
214
2392
  export default (
215
2393
  <server>
216
- <header name='cache-control' value='max-age=300'>
217
- <file path='index.html' />
218
- </header>
2394
+ <api>
2395
+ <endpoint method='post' path='/users'>
2396
+ <body>
2397
+ <object>
2398
+ <field key='name' />
2399
+ <field key='surname' />
2400
+ <field key='birthbay' />
2401
+ </object>
2402
+ </body>
2403
+ </endpoint>
2404
+ </api>
219
2405
  </server>
220
2406
  )
221
2407
  ```
222
2408
 
223
- In this case `cache-control` will be equal to `max-age=300` even if the file does not exist.
2409
+ #### optional
224
2410
 
225
- You can put content into the file to apply it only if the file does exist.
2411
+ By default, any field is required. You can set it as `optional` by this prop.
226
2412
 
2413
+ *src/app.tsx*
227
2414
  ```typescript jsx
228
2415
  export default (
229
2416
  <server>
230
- <file path='index.html'>
231
- <header name='cache-control' value='max-age=300' />
232
- </file>
2417
+ <api>
2418
+ <endpoint method='post' path='/users'>
2419
+ <body>
2420
+ <object>
2421
+ <field key='name' />
2422
+ <field key='surname' />
2423
+ <field optional key='birthbay' />
2424
+ </object>
2425
+ </body>
2426
+ </endpoint>
2427
+ </api>
233
2428
  </server>
234
2429
  )
235
2430
  ```
236
2431
 
237
- Put `index.html` in the root of the project (`my-app` folder).
2432
+ ## Run-Time
2433
+
2434
+ Next elements relate to run-time action.
2435
+ This action calls on user request.
2436
+
2437
+ [← back](#index)
2438
+
2439
+ Parent
2440
+ [\<fallback>](#fallback)
2441
+ [\<request>](#request)
2442
+
2443
+ Children
2444
+ [\<success>](#success)
2445
+ [\<error>](#error)
2446
+ [\<proxy>](#proxy)
2447
+ [\<redirect>](#redirect)
2448
+ [\<cms>](#cms)
2449
+ [\<file>](#file)
2450
+ [\<header>](#header)
2451
+ [\<cookie>](#cookie)
2452
+
2453
+ ---
2454
+
2455
+ ### \<fallback>
2456
+
2457
+ [← back](#run-time)
238
2458
 
239
- ## Router
240
- The router helps to handle requests by route.
2459
+ By default, `<api>` server returns 404 with empty body.
2460
+ [\<fallback>](#fallback) element defines default server response.
2461
+ This element MUST be placed in `<api>`.
2462
+ You MUST use one [\<fallback>](#fallback) per `<api>`.
2463
+ Can contain elements available inside [\<request>](#request).
2464
+
2465
+ *src/app.tsx*
241
2466
  ```typescript jsx
242
2467
  export default (
243
2468
  <server>
244
- <router>
245
- <file path='index.html' />
246
- </router>
2469
+ <api>
2470
+ <fallback>
2471
+ <error
2472
+ code='unknownEndpoint'
2473
+ />
2474
+ </fallback>
2475
+ </api>
247
2476
  </server>
248
2477
  )
249
2478
  ```
250
2479
 
251
- The router does nothing and returns self content.
252
- It starts work only with the next props.
2480
+ If you open the application on any URL except for `/`, you can see the next response.
2481
+
2482
+ ```json
2483
+ {
2484
+ "error": "unknownEndpoint"
2485
+ }
2486
+ ```
2487
+
2488
+ The next elements are placed in [\<request>](#request) or [\<fallback>](#fallback)
2489
+
2490
+ ### \<request>
253
2491
 
254
- ### method
255
- This property says that the content of the route should be run if the request method equals to the prop.
2492
+ [← back](#run-time)
256
2493
 
2494
+ This element MUST be placed in `<endpoint>` element.
2495
+ It defines run-time call handler for the endpoint.
2496
+
2497
+ *src/app.tsx*
257
2498
  ```typescript jsx
258
2499
  export default (
259
2500
  <server>
260
- <router method='GET'>
261
- <file path='index.html' />
262
- </router>
2501
+ <api>
2502
+ <endpoint method='get' path='/partners'>
2503
+ <request>
2504
+ <success>
2505
+ {{partners: []}}
2506
+ </success>
2507
+ </request>
2508
+ </endpoint>
2509
+ </api>
263
2510
  </server>
264
2511
  )
265
2512
  ```
266
2513
 
267
- ### path
268
- You can set `path` to match with it.
2514
+ You can place a component inside it.
2515
+ The component will run when the endpoint will be triggered.
269
2516
 
2517
+ *src/app.tsx*
270
2518
  ```typescript jsx
2519
+ import { GetPartners } from './GetPartners'
2520
+
271
2521
  export default (
272
2522
  <server>
273
- <router method='GET' path='/'>
274
- <file path='index.html' />
275
- </router>
2523
+ <api>
2524
+ <endpoint method='get' path='/partners'>
2525
+ <request>
2526
+ <GetPartners />
2527
+ </request>
2528
+ </endpoint>
2529
+ </api>
276
2530
  </server>
277
2531
  )
278
2532
  ```
279
2533
 
280
- You will get the `index.html` only on the root path with `GET` method.
2534
+ *src/GetPartners.tsx*
2535
+ ```typescript jsx
2536
+ export const GetPartners = () => (
2537
+ <success>
2538
+ {{partners: []}}
2539
+ </success>
2540
+ )
2541
+ ```
2542
+
2543
+ ### \<success>
281
2544
 
282
- This prop has regex like syntax, so you can set the path as you wish.
2545
+ [← back](#run-time)
283
2546
 
2547
+ This is a base element to return a success data.
2548
+
2549
+ *src/app.tsx*
284
2550
  ```typescript jsx
285
2551
  export default (
286
2552
  <server>
287
- <router path='/user/[0-9]+'>
288
- <file path='index.html' />
289
- </router>
2553
+ <api>
2554
+ <fallback>
2555
+ <success />
2556
+ </fallback>
2557
+ </api>
290
2558
  </server>
291
2559
  )
292
2560
  ```
293
2561
 
294
- To provide named params from url, use named capturing groups of regex.
2562
+ You will get a response with `204` status (`noContent`) and without content.
2563
+
2564
+ You can provide some data to the user by children.
295
2565
 
2566
+ *src/app.tsx*
296
2567
  ```typescript jsx
2568
+ const data = {...}
2569
+
297
2570
  export default (
298
2571
  <server>
299
- <router path='/user/(?<id>[\w-]+)'>
300
- <file path='index.html' />
301
- </router>
2572
+ <api>
2573
+ <fallback>
2574
+ <success>
2575
+ {data}
2576
+ </success>
2577
+ </fallback>
2578
+ </api>
302
2579
  </server>
303
2580
  )
304
2581
  ```
305
2582
 
306
- ### ish
307
- You can react on any path which starts with provided one.
2583
+ You will get `200` status (`ok`), with body equals data.
2584
+
2585
+ #### status
308
2586
 
2587
+ You can set response status by `status` prop of `<success>`.
2588
+
2589
+ *src/app.tsx*
309
2590
  ```typescript jsx
2591
+ const data = {...}
2592
+
310
2593
  export default (
311
2594
  <server>
312
- <router path='/test' ish>
313
- <file path='index.html' />
314
- </router>
2595
+ <api>
2596
+ <fallback>
2597
+ <success status='created'>
2598
+ {data}
2599
+ </success>
2600
+ </fallback>
2601
+ </api>
315
2602
  </server>
316
2603
  )
317
2604
  ```
318
2605
 
319
- `/`, `/something`, `/test1` do not match.
320
- `/test`, `/test/something` matches.
321
-
322
- ### prefix
2606
+ You will get `201` status (`created`), with data as a content.
323
2607
 
324
- You can use a router inside another one and `prefix` helps reduce path prop.
2608
+ You can use a number of `status` prop.
325
2609
 
2610
+ *src/app.tsx*
326
2611
  ```typescript jsx
2612
+ const data = {...}
2613
+
327
2614
  export default (
328
2615
  <server>
329
- <router path='/test' prefix='/test' ish>
330
- <router path='/'>
331
- <file path='index.html' />
332
- </router>
333
- <router path='/404'>
334
- <file path='404.html' />
335
- </router>
336
- </router>
2616
+ <api>
2617
+ <fallback>
2618
+ <success status={201}>
2619
+ {data}
2620
+ </success>
2621
+ </fallback>
2622
+ </api>
337
2623
  </server>
338
2624
  )
339
2625
  ```
340
2626
 
341
- Here you can get `index.html` on `/test` and `404.html` on `/test/404`.
2627
+ ### \<error>
342
2628
 
343
- ### onMatch
2629
+ [← back](#run-time)
344
2630
 
345
- You can log the requests of any router.
2631
+ Returns an error.
2632
+ This element MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
346
2633
 
2634
+ *src/app.tsx*
347
2635
  ```typescript jsx
348
2636
  export default (
349
2637
  <server>
350
- <router path='/test' onMatch={console.log}>
351
- <file path='index.html' />
352
- </router>
2638
+ <api>
2639
+ <fallback>
2640
+ <error />
2641
+ </fallback>
2642
+ </api>
353
2643
  </server>
354
2644
  )
355
2645
  ```
356
2646
 
357
- ## switch
358
-
359
- By default,
360
- routers in the same router runs one by one
361
- independent to result of the previous route.
2647
+ Place a data into the element to return an error with the data.
362
2648
 
363
- To avoid this you can use switch element.
2649
+ *src/app.tsx*
364
2650
  ```typescript jsx
2651
+ const data = {...}
2652
+
365
2653
  export default (
366
2654
  <server>
367
- <switch>
368
- <router path='/'>
369
- <file path='index.html' />
370
- </router>
371
- <file path='404.html' />
372
- </switch>
2655
+ <api>
2656
+ <fallback>
2657
+ <error>
2658
+ {data}
2659
+ </error>
2660
+ </fallback>
2661
+ </api>
373
2662
  </server>
374
2663
  )
375
2664
  ```
376
2665
 
377
- You will get `index.html` only on the root path,
378
- any other path will return `404.html`.
2666
+ #### status
2667
+ You can change response status by `status` prop. By default, it is `520` (`unknownError`)
2668
+
2669
+ *src/app.tsx*
2670
+ ```typescript jsx
2671
+ const data = {
2672
+ message: 'User not found!'
2673
+ }
379
2674
 
380
- ## cms
2675
+ export default (
2676
+ <server>
2677
+ <api>
2678
+ <fallback>
2679
+ <error status='notFound'>
2680
+ {data}
2681
+ </error>
2682
+ </fallback>
2683
+ </api>
2684
+ </server>
2685
+ )
2686
+ ```
381
2687
 
382
- CMS helps to return files from a folder by path.
2688
+ You can use a number with the status prop.
383
2689
 
2690
+ *src/app.tsx*
384
2691
  ```typescript jsx
2692
+ const data = {
2693
+ message: 'User not found!'
2694
+ }
2695
+
385
2696
  export default (
386
2697
  <server>
387
- <switch>
388
- <cms dir='cms' />
389
- <file path='404.html' />
390
- </switch>
2698
+ <api>
2699
+ <fallback>
2700
+ <error status={404}>
2701
+ {data}
2702
+ </error>
2703
+ </fallback>
2704
+ </api>
391
2705
  </server>
392
2706
  )
393
2707
  ```
394
2708
 
395
- It will check if the file exist in cms folder then returns the file else returns `404.html`.
2709
+ #### code
2710
+ When you use `<error>` element a user get next response body.
2711
+
2712
+ *for the previous example*
2713
+ ```json
2714
+ {
2715
+ "error": "undefined",
2716
+ "data": {
2717
+ "message": "User not found!"
2718
+ }
2719
+ }
2720
+ ```
396
2721
 
397
- You can use prefix with router to handle specific path.
2722
+ You can change the `error` code by `code` property.
398
2723
 
2724
+ *src/app.tsx*
399
2725
  ```typescript jsx
2726
+ const data = {
2727
+ message: 'User not found!'
2728
+ }
2729
+
400
2730
  export default (
401
2731
  <server>
402
- <switch>
403
- <router path='/cms' ish>
404
- <cms dir='cms' prefix='/cms' />
405
- </router>
406
- <file path='404.html' />
407
- </switch>
2732
+ <api>
2733
+ <fallback>
2734
+ <error
2735
+ code='noUser'
2736
+ status='notFound'>
2737
+ {data}
2738
+ </error>
2739
+ </fallback>
2740
+ </api>
408
2741
  </server>
409
2742
  )
410
2743
  ```
411
2744
 
412
- You can input something into `cms`, if requested file is exist then the content should be used.
2745
+ Then you get
2746
+
2747
+ *for the previous example*
2748
+ ```json
2749
+ {
2750
+ "error": "noUser",
2751
+ "data": {
2752
+ "message": "User not found!"
2753
+ }
2754
+ }
2755
+ ```
2756
+
2757
+ There are some default errors:
2758
+
2759
+ - `undefined` - when you use `<error>` element without `code`.
2760
+ - `requestValidation` - when request data fails schema validation.
2761
+ - `requestBodyContentType` - when cannot parse body.
2762
+ - `unknown` - can because of JSON stringify fail or other errors.
2763
+
2764
+ ### \<proxy>
413
2765
 
2766
+ [← back](#run-time)
2767
+
2768
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
2769
+
2770
+ You can easy proxy endpoints to another server/service.
2771
+
2772
+ *src/app.tsx*
414
2773
  ```typescript jsx
415
2774
  export default (
416
2775
  <server>
417
- <switch>
418
- <cms dir='cms'>
419
- <header name='cache-control' value='max-age=300' />
420
- </cms>
421
- <file path='404.html' />
422
- </switch>
2776
+ <api>
2777
+ <endpoint
2778
+ path='/test'
2779
+ method='get'>
2780
+ <request>
2781
+ <proxy to='https://...' />
2782
+ </request>
2783
+ </endpoint>
2784
+ <fallback>
2785
+ <proxy to='https://...' />
2786
+ </fallback>
2787
+ </api>
423
2788
  </server>
424
2789
  )
425
2790
  ```
426
2791
 
427
- ## proxy
428
- You can proxy request.
2792
+ ### \<redirect>
2793
+
2794
+ [← back](#run-time)
429
2795
 
2796
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
2797
+
2798
+ You can redirect users to another resource. It adds `Cache-Control` header by default.
2799
+
2800
+ *src/app.tsx*
430
2801
  ```typescript jsx
431
2802
  export default (
432
2803
  <server>
433
- <switch>
434
- <cms dir='cms' />
435
- <proxy to='https://site.com' />
436
- </switch>
2804
+ <api>
2805
+ <endpoint
2806
+ path='/test'
2807
+ method='get'>
2808
+ <request>
2809
+ <redirect to='https://...' />
2810
+ </request>
2811
+ </endpoint>
2812
+ <fallback>
2813
+ <redirect to='https://...' />
2814
+ </fallback>
2815
+ </api>
437
2816
  </server>
438
2817
  )
439
2818
  ```
440
2819
 
441
- In this case, if you have a file in cms folder then the file will return
442
- else makes request to the `site.com`.
2820
+ #### status
443
2821
 
444
- ## redirect
445
- You can redirect users to another resource.
2822
+ `<redirect>` element returns status `301` by default.
2823
+ You can change it by `status` property.
446
2824
 
2825
+ *src/app.tsx*
447
2826
  ```typescript jsx
448
2827
  export default (
449
2828
  <server>
450
- <switch>
451
- <cms dir='cms' />
452
- <redirect to='https://site.com' />
453
- </switch>
2829
+ <api>
2830
+ <endpoint
2831
+ path='/test'
2832
+ method='get'>
2833
+ <request>
2834
+ <redirect
2835
+ status='found'
2836
+ to='https://...'
2837
+ />
2838
+ </request>
2839
+ </endpoint>
2840
+ <fallback>
2841
+ <redirect
2842
+ status={303}
2843
+ to='https://...'
2844
+ />
2845
+ </fallback>
2846
+ </api>
454
2847
  </server>
455
2848
  )
456
2849
  ```
457
2850
 
458
- ### status
459
- By default, status is `301`, you can change it with `status` prop.
2851
+ ### \<cms>
2852
+
2853
+ [← back](#run-time)
2854
+
2855
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
460
2856
 
2857
+ `<cms>` helps to return files from a folder by path. It checks files run-time on the server.
2858
+
2859
+ *src/app.tsx*
461
2860
  ```typescript jsx
462
2861
  export default (
463
2862
  <server>
464
- <switch>
465
- <cms dir='cms' />
466
- <redirect to='https://site.com' status={302} />
467
- </switch>
2863
+ <api>
2864
+ <fallback>
2865
+ <cms />
2866
+ </fallback>
2867
+ </api>
468
2868
  </server>
469
2869
  )
470
2870
  ```
471
2871
 
472
- Also, you can use string key of status.
2872
+ #### dir
2873
+
2874
+ By default, it looks at project folder.
2875
+ If you try the previous example on [http://localhost/package.json](http://localhost/package.json)
2876
+ you get the project `package.json` file.
473
2877
 
2878
+ You can change root folder by `dir` property.
2879
+
2880
+ *src/app.tsx*
474
2881
  ```typescript jsx
475
2882
  export default (
476
2883
  <server>
477
- <switch>
478
- <cms dir='cms' />
479
- <redirect to='https://site.com' status='found'/>
480
- </switch>
2884
+ <api>
2885
+ <fallback>
2886
+ <cms dir='src' />
2887
+ </fallback>
2888
+ </api>
481
2889
  </server>
482
2890
  )
483
2891
  ```
484
2892
 
485
- ## Components
2893
+ Now you can try [http://localhost/index.tsx](http://localhost/index.tsx)
2894
+ you get the index file in `src` folder.
486
2895
 
487
- Any component is just a function which returns content that should be run.
2896
+ #### prefix
488
2897
 
489
- `server.tsx`
2898
+ `<cms>` matches full `path`, you should take it into account if you add `prefix` on `<api>`.
2899
+
2900
+ *src/app.tsx*
490
2901
  ```typescript jsx
491
- export const Server = ({ cmsPrefix }) => (
2902
+ export default (
492
2903
  <server>
493
- <switch>
494
- <router path={cmsPrefix} ish>
495
- <cms dir='cms' prefix={cmsPrefix} />
496
- </router>
497
- <file path='404.html' />
498
- </switch>
2904
+ <api prefix='/src'>
2905
+ <fallback>
2906
+ <cms />
2907
+ </fallback>
2908
+ </api>
499
2909
  </server>
500
2910
  )
501
2911
  ```
502
2912
 
503
- and then you can use it inside `app.tsx`.
2913
+ Here you can try [http://localhost/src/index.tsx](http://localhost/src/index.tsx)
2914
+ you get the index file in `src` folder.
504
2915
 
505
- ```typescript jsx
506
- import { Server } from './server'
2916
+ You can reduce the path for matching by prefix property of `<cms>`.
507
2917
 
508
- export default <Server cmsPrefix='/cms' />
2918
+ *src/app.tsx*
2919
+ ```typescript jsx
2920
+ export default (
2921
+ <server>
2922
+ <api prefix='/api'>
2923
+ <fallback>
2924
+ <cms prefix='/api' />
2925
+ </fallback>
2926
+ </api>
2927
+ </server>
2928
+ )
509
2929
  ```
510
2930
 
511
- You can use it with any other functionality, for example with `html`.
2931
+ Now you can try [http://localhost/api/package.json](http://localhost/api/package.json)
2932
+
2933
+ #### children
512
2934
 
2935
+ You can handle if a file was not found by children elements of `<cms>`.
2936
+
2937
+ *src/app.tsx*
513
2938
  ```typescript jsx
514
- import { useChildren } from '@innet/jsx'
2939
+ export default (
2940
+ <server>
2941
+ <api prefix='/src'>
2942
+ <fallback>
2943
+ <cms>
2944
+ <error status={404} />
2945
+ </cms>
2946
+ </fallback>
2947
+ </api>
2948
+ </server>
2949
+ )
2950
+ ```
515
2951
 
516
- function Html ({ title }) {
517
- const children = useChildren()
2952
+ ### \<file>
518
2953
 
519
- return (
520
- <header name='content-type' value='text/html'>
521
- <html>
522
- <head>
523
- <title>{title}</title>
524
- </head>
525
- <body>
526
- {children}
527
- </body>
528
- </html>
529
- </header>
530
- )
531
- }
2954
+ [← back](#run-time)
2955
+
2956
+ It returns a file. MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
2957
+
2958
+ It adds `Content-Length` and `Content-Type` automatically.
2959
+
2960
+ It has a REQUIRED property of `path`.
532
2961
 
2962
+ *src/app.tsx*
2963
+ ```typescript jsx
533
2964
  export default (
534
2965
  <server>
535
- <Html title='main'>
536
- Hello World!
537
- </Html>
538
- </server>
2966
+ <api>
2967
+ <fallback>
2968
+ <file
2969
+ path='package.json'
2970
+ />
2971
+ </fallback>
2972
+ </api>
2973
+ </server>
539
2974
  )
540
2975
  ```
541
2976
 
542
- The first argument is props, the second is children and the last one is a handler.
2977
+ For this example you get `package.json` file of the project on any path except for `/`.
543
2978
 
544
- You can use components inside another component.
2979
+ #### children
545
2980
 
546
- ## success
547
- If you work on REST API, you can use `success` or `error` as an answer
2981
+ You can handle if a file was not found by children elements of `<file>`.
548
2982
 
2983
+ *src/app.tsx*
549
2984
  ```typescript jsx
550
2985
  export default (
551
2986
  <server>
552
- <success />
553
- </server>
2987
+ <api prefix='/src'>
2988
+ <fallback>
2989
+ <file path='file_is_not_exist.txt'>
2990
+ <error status={404} />
2991
+ </file>
2992
+ </fallback>
2993
+ </api>
2994
+ </server>
554
2995
  )
555
2996
  ```
556
2997
 
557
- You will get `204` status (`noContent`), without content.
2998
+ ### \<header>
558
2999
 
559
- You can provide some data to the user by children.
560
- ```typescript jsx
561
- const data = {
562
- posts: []
563
- }
3000
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3001
+
3002
+ [← back](#run-time)
564
3003
 
3004
+ You can add an HTTP header into response by `<header>` element.
3005
+
3006
+ *src/app.tsx*
3007
+ ```typescript jsx
565
3008
  export default (
566
3009
  <server>
567
- <success>
568
- {data}
569
- </success>
3010
+ <api prefix='/src'>
3011
+ <fallback>
3012
+ <header
3013
+ key='Cache-Control'
3014
+ value='no-cache, no-store, must-revalidate'
3015
+ />
3016
+ <success />
3017
+ </fallback>
3018
+ </api>
570
3019
  </server>
571
3020
  )
572
3021
  ```
573
- You will get `200` status (`ok`), with body equals data.
574
3022
 
575
- ### status
576
- You can set status by status prop.
3023
+ ### \<cookie>
577
3024
 
578
- ```typescript jsx
579
- const data = {
580
- id: '123'
581
- }
3025
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
3026
+
3027
+ [← back](#run-time)
3028
+
3029
+ You can add/remove a cookie into response by `<cookie>` element.
582
3030
 
3031
+ *src/app.tsx*
3032
+ ```typescript jsx
583
3033
  export default (
584
3034
  <server>
585
- <success status='created'>
586
- {data}
587
- </success>
588
- </server>
3035
+ <api prefix='/src'>
3036
+ <fallback>
3037
+ <cookie
3038
+ key='token'
3039
+ value='...'
3040
+ />
3041
+ <cookie
3042
+ key='removedCookie'
3043
+ />
3044
+ <success />
3045
+ </fallback>
3046
+ </api>
3047
+ </server>
589
3048
  )
590
3049
  ```
591
3050
 
592
- You will get `201` status (`created`), with data as a content.
3051
+ #### domain
593
3052
 
594
- You can use a number with `status` prop.
3053
+ The prop specifies the value for the [Domain Set-Cookie attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.3).
3054
+ By default, no domain is set, and most clients will consider the cookie to apply to only the current domain.
595
3055
 
3056
+ *src/app.tsx*
596
3057
  ```typescript jsx
597
- const data = {
598
- id: '123'
599
- }
600
-
601
3058
  export default (
602
3059
  <server>
603
- <success status={201}>
604
- {data}
605
- </success>
606
- </server>
3060
+ <api prefix='/src'>
3061
+ <fallback>
3062
+ <cookie
3063
+ domain='.example.com'
3064
+ key='token'
3065
+ value='...'
3066
+ />
3067
+ <success />
3068
+ </fallback>
3069
+ </api>
3070
+ </server>
607
3071
  )
608
3072
  ```
609
3073
 
610
- ## error
611
- You can return an error to the user.
3074
+ #### encode
3075
+
3076
+ Specifies a function that will be used to encode a cookie's value. Since value of a cookie has a limited character set (and must be a simple string), this function can be used to encode a value into a string suited for a cookie's value.
3077
+ The default function is the global encodeURIComponent, which will encode a JavaScript string into UTF-8 byte sequences and then URL-encode any that fall outside of the cookie range.
612
3078
 
3079
+ #### expires
3080
+
3081
+ Specifies the Date object to be the value for the Expires [Set-Cookie attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.1). By default, no expiration is set, and most clients will consider this a “non-persistent cookie” and will delete it on a condition like exiting a web browser application.
3082
+ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/html/rfc6265#section-5.3) states that if both expires and maxAge are set, then maxAge takes precedence, but it is possible not all clients by obey this, so if both are set, they should point to the same date and time.
3083
+
3084
+ *src/app.tsx*
613
3085
  ```typescript jsx
614
3086
  export default (
615
3087
  <server>
616
- <error />
617
- </server>
3088
+ <api prefix='/src'>
3089
+ <fallback>
3090
+ <cookie
3091
+ expires={new Date('2050-01-01')}
3092
+ key='token'
3093
+ value='...'
3094
+ />
3095
+ <success />
3096
+ </fallback>
3097
+ </api>
3098
+ </server>
618
3099
  )
619
3100
  ```
620
3101
 
621
- You will get `520` status (`unknownError`).
3102
+ #### httpOnly
622
3103
 
623
- You can provide some data to the user by children.
3104
+ Specifies the boolean value for the [HttpOnly Set-Cookie attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.6). When truthy, the HttpOnly attribute is set, otherwise it is not. By default, the HttpOnly attribute is not set.
3105
+ Note be careful when setting this to true, as compliant clients will not allow client-side JavaScript to see the cookie in document.cookie.
624
3106
 
3107
+ *src/app.tsx*
625
3108
  ```typescript jsx
626
- const data = {
627
- message: 'Some error!'
628
- }
629
-
630
3109
  export default (
631
3110
  <server>
632
- <error>
633
- {data}
634
- </error>
635
- </server>
3111
+ <api prefix='/src'>
3112
+ <fallback>
3113
+ <cookie
3114
+ httpOnly
3115
+ key='token'
3116
+ value='...'
3117
+ />
3118
+ <success />
3119
+ </fallback>
3120
+ </api>
3121
+ </server>
636
3122
  )
637
3123
  ```
638
3124
 
639
- ### status
640
- You can change response status by `status` prop.
3125
+ #### maxAge
641
3126
 
642
- ```typescript jsx
643
- const data = {
644
- message: 'User not found!'
645
- }
3127
+ Specifies the number (in seconds) to be the value for the Max-Age Set-Cookie attribute. The given number will be converted to an integer by rounding down. By default, no maximum age is set.
3128
+ Note the [cookie storage model specification](https://datatracker.ietf.org/doc/html/rfc6265#section-5.3) states that if both expires and maxAge are set, then maxAge takes precedence, but it is possible not all clients by obey this, so if both are set, they should point to the same date and time.
646
3129
 
3130
+ *src/app.tsx*
3131
+ ```typescript jsx
647
3132
  export default (
648
3133
  <server>
649
- <error status='notFound'>
650
- {data}
651
- </error>
3134
+ <api prefix='/src'>
3135
+ <fallback>
3136
+ <cookie
3137
+ httpOnly
3138
+ maxAge={9999}
3139
+ key='token'
3140
+ value='...'
3141
+ />
3142
+ <success />
3143
+ </fallback>
3144
+ </api>
652
3145
  </server>
653
3146
  )
654
3147
  ```
655
- Also, you can use a number with the status prop.
656
3148
 
3149
+ #### path
3150
+
3151
+ Specifies the value for the [Path Set-Cookie attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.4).
3152
+ By default, the path is considered the “default path”.
3153
+
3154
+ *src/app.tsx*
657
3155
  ```typescript jsx
658
- const data = {
659
- message: 'User not found!'
660
- }
3156
+ export default (
3157
+ <server>
3158
+ <api prefix='/src'>
3159
+ <fallback>
3160
+ <cookie
3161
+ httpOnly
3162
+ maxAge={9999}
3163
+ path='/src'
3164
+ key='token'
3165
+ value='...'
3166
+ />
3167
+ <success />
3168
+ </fallback>
3169
+ </api>
3170
+ </server>
3171
+ )
3172
+ ```
3173
+
3174
+ #### priority
661
3175
 
3176
+ Specifies the string to be the value for the «Priority Set-Cookie attribute».
3177
+
3178
+ - `'low'` will set the Priority attribute to Low.
3179
+ - `'medium'` will set the Priority attribute to Medium, the default priority when not set.
3180
+ - `'high'` will set the Priority attribute to High.
3181
+
3182
+ note This is an attribute that has not yet been fully standardized, and may change in the future. This also means many clients may ignore this attribute until they understand it.
3183
+
3184
+ *src/app.tsx*
3185
+ ```typescript jsx
662
3186
  export default (
663
3187
  <server>
664
- <error status={404}>
665
- {data}
666
- </error>
3188
+ <api prefix='/src'>
3189
+ <fallback>
3190
+ <cookie
3191
+ httpOnly
3192
+ priority='high'
3193
+ path='/src'
3194
+ key='token'
3195
+ value='...'
3196
+ />
3197
+ <success />
3198
+ </fallback>
3199
+ </api>
667
3200
  </server>
668
3201
  )
669
3202
  ```
670
3203
 
671
- ## cookie
672
- You can set cookie by `cookie` element.
3204
+ #### sameSite
673
3205
 
3206
+ Specifies the `boolean` or `string` to be the value for the SameSite Set-Cookie attribute.
3207
+
3208
+ - `true` will set the SameSite attribute to Strict for strict same site enforcement.
3209
+ - `false` will not set the SameSite attribute.
3210
+ - `'lax'` will set the SameSite attribute to Lax for lax same site enforcement.
3211
+ - `'strict'` will set the SameSite attribute to Strict for strict same site enforcement.
3212
+ - `'none'` will set the SameSite attribute to None for an explicit cross-site cookie.
3213
+
3214
+ note This is an attribute that has not yet been fully standardized, and may change in the future.
3215
+ This also means many clients may ignore this attribute until they understand it.
3216
+
3217
+ *src/app.tsx*
674
3218
  ```typescript jsx
675
- const Login = ({ token }) => (
676
- <cookie key='token' value={token}>
677
- <success />
678
- </cookie>
3219
+ export default (
3220
+ <server>
3221
+ <api prefix='/src'>
3222
+ <fallback>
3223
+ <cookie
3224
+ httpOnly
3225
+ sameSite
3226
+ priority='high'
3227
+ path='/src'
3228
+ key='token'
3229
+ value='...'
3230
+ />
3231
+ <success />
3232
+ </fallback>
3233
+ </api>
3234
+ </server>
679
3235
  )
3236
+ ```
3237
+
3238
+ #### secure
680
3239
 
3240
+ Specifies the boolean value for the [Secure Set-Cookie attribute](https://datatracker.ietf.org/doc/html/rfc6265#section-5.2.5).
3241
+ When truthy, the Secure attribute is set, otherwise it is not.
3242
+ By default, the Secure attribute is not set.
3243
+
3244
+ Note be careful when setting this to true, as compliant clients will not send the cookie back to the server in the future if the browser does not have an HTTPS connection.
3245
+
3246
+ *src/app.tsx*
3247
+ ```typescript jsx
681
3248
  export default (
682
3249
  <server>
683
- <Login token='test' />
684
- </server>
3250
+ <api prefix='/src'>
3251
+ <fallback>
3252
+ <cookie
3253
+ httpOnly
3254
+ secure
3255
+ key='token'
3256
+ value='...'
3257
+ />
3258
+ <success />
3259
+ </fallback>
3260
+ </api>
3261
+ </server>
3262
+ )
3263
+ ```
3264
+
3265
+ ## Components
3266
+
3267
+ [← back](#index)
3268
+
3269
+ Component is a function which returns content that, like, placed instead of the component.
3270
+ Like you can inject a plugin between elements.
3271
+ Components are from [@innet/jsx](https://www.npmjs.com/package/@innet/jsx).
3272
+
3273
+ *src/SetToken.tsx*
3274
+ ```typescript jsx
3275
+ export const SetToken = ({ value }) => (
3276
+ <cookie
3277
+ httpOnly
3278
+ secure
3279
+ key='token'
3280
+ value={value}
3281
+ />
685
3282
  )
686
3283
  ```
687
3284
 
688
- To remove cookie just provide key without value.
3285
+ and then you can use it inside `app.tsx`.
689
3286
 
3287
+ *src/app.tsx*
690
3288
  ```typescript jsx
3289
+ import { SetToken } from './SetToken'
3290
+
691
3291
  export default (
692
3292
  <server>
693
- <cookie key='token'>
694
- <success />
695
- </cookie>
696
- </server>
3293
+ <api prefix='/src'>
3294
+ <fallback>
3295
+ <SetToken
3296
+ value='...'
3297
+ />
3298
+ <success />
3299
+ </fallback>
3300
+ </api>
3301
+ </server>
697
3302
  )
698
3303
  ```
699
3304
 
700
- ## useAction
701
- Action is an object which contains `request` and `response`.
702
- Also, it contains a couple of fields and methods.
3305
+ You can use [hooks](#hooks) inside components.
3306
+
3307
+ ## Hooks
703
3308
 
704
- Action available in components.
3309
+ Hook functions give you all features to control parent element functionality.
3310
+
3311
+ [← back](#index)
3312
+
3313
+ [useServer](#useserver)
3314
+ [useRequest](#userequest)
3315
+ [useResponse](#useresponse)
3316
+ [useHeaders](#useheaders)
3317
+ [useCookies](#usecookies)
3318
+ [usePath](#usepath)
3319
+ [useParams](#useparams)
3320
+ [useSearch](#usesearch)
3321
+ [useBody](#usebody)
3322
+
3323
+ ---
3324
+
3325
+ ### useServer
3326
+
3327
+ [← back](#hooks)
3328
+
3329
+ This hook MUST be used in a component placed in `<server>`.
3330
+ This hook returns current http(s) server instance.
3331
+
3332
+ *src/Component.tsx*
705
3333
 
706
3334
  ```typescript jsx
707
- import { useAction } from '@innet/server'
3335
+ import { useServer } from '@innet/sever'
3336
+
3337
+ export function Component () {
3338
+ const server = useServer()
708
3339
 
709
- function Test () {
710
- const { req, res } = useAction()
3340
+ console.log(server)
711
3341
 
712
- console.log(req, res)
3342
+ return <success />
713
3343
  }
714
3344
  ```
715
3345
 
716
- ### cookies
717
- You can get cookies as an object from an action.
3346
+ ### useRequest
3347
+
3348
+ [← back](#hooks)
3349
+
3350
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3351
+ This hook returns current request instance.
3352
+
3353
+ *src/Component.tsx*
718
3354
 
719
3355
  ```typescript jsx
720
- import { useAction } from '@innet/server'
3356
+ import { useRequest } from '@innet/sever'
3357
+
3358
+ export function Component () {
3359
+ const request = useRequest()
721
3360
 
722
- function Cookies () {
723
- const { cookies } = useAction()
3361
+ console.log(request)
724
3362
 
725
- return <success>{cookies}</success>
3363
+ return <success />
726
3364
  }
727
3365
  ```
728
3366
 
729
- ### setCookie
730
- You can set cookie with action.
3367
+ ### useResponse
3368
+
3369
+ [← back](#hooks)
3370
+
3371
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3372
+ This hook returns current response instance.
3373
+
3374
+ *src/Component.tsx*
731
3375
 
732
3376
  ```typescript jsx
733
- import { useAction } from '@innet/server'
3377
+ import { useResponse } from '@innet/sever'
3378
+
3379
+ export function Component () {
3380
+ const response = useResponse()
734
3381
 
735
- function Login () {
736
- const action = useAction()
3382
+ console.log(response)
737
3383
 
738
- action.setCookie('user', 'token')
3384
+ return <success />
739
3385
  }
740
3386
  ```
741
3387
 
742
- ### path
743
- You can get current path with action.
3388
+ ### useHeaders
3389
+
3390
+ [← back](#hooks)
3391
+
3392
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3393
+ This hook returns current request headers object.
3394
+
3395
+ *src/Component.tsx*
744
3396
 
745
3397
  ```typescript jsx
746
- import { useAction } from '@innet/server'
3398
+ import { useHeaders } from '@innet/sever'
747
3399
 
748
- function Path () {
749
- const { path } = useAction()
3400
+ export function Component () {
3401
+ const headers = useHeaders()
750
3402
 
751
- return path
3403
+ return <success>{{ headers }}</success>
752
3404
  }
753
3405
  ```
754
3406
 
755
- ### search
756
- You can get current search as an object.
3407
+ ### useCookies
3408
+
3409
+ [← back](#hooks)
3410
+
3411
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3412
+ This hook returns current request cookies object.
3413
+
3414
+ *src/Component.tsx*
757
3415
 
758
3416
  ```typescript jsx
759
- import { useAction } from '@innet/server'
3417
+ import { useCookies } from '@innet/sever'
760
3418
 
761
- function Search () {
762
- const { search } = useAction()
3419
+ export function Component () {
3420
+ const cookies = useCookies()
763
3421
 
764
- return <success>{search}</success>
3422
+ return <success>{{ cookies }}</success>
765
3423
  }
766
3424
  ```
767
3425
 
768
- ### body
769
- You can parse body, and get values.
3426
+ ### usePath
3427
+
3428
+ [← back](#hooks)
3429
+
3430
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3431
+ This hook returns current request URL path as a `string`.
3432
+
3433
+ *src/Component.tsx*
770
3434
 
771
3435
  ```typescript jsx
772
- import { useAction } from '@innet/server'
3436
+ import { usePath } from '@innet/sever'
773
3437
 
774
- async function Body () {
775
- const action = useAction()
776
-
777
- await action.parseBody()
3438
+ export function Component () {
3439
+ const path = usePath()
778
3440
 
779
- return <success>{action.body}</success>
3441
+ return <success>{{ path }}</success>
780
3442
  }
781
3443
  ```
782
3444
 
783
- ### files
784
- You can get files from a user.
3445
+ ### useParams
3446
+
3447
+ [← back](#hooks)
3448
+
3449
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3450
+ This hook returns an object of URL params you set by [\<param>](#param).
785
3451
 
3452
+ *src/Component.tsx*
786
3453
  ```typescript jsx
787
- import { useAction } from '@innet/server'
3454
+ import { useParams } from '@innet/sever'
788
3455
 
789
- async function Body () {
790
- const action = useAction()
791
-
792
- await action.parseBody()
3456
+ export function Component () {
3457
+ const params = useParams()
793
3458
 
794
- return <success>{action.files}</success>
3459
+ return <success>{params}</success>
795
3460
  }
796
3461
  ```
797
3462
 
798
- ## useRouter
3463
+ ### useSearch
799
3464
 
800
- You can get router data in a component
3465
+ [← back](#hooks)
801
3466
 
3467
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3468
+ This hook returns an object of URL query params.
3469
+
3470
+ *src/Component.tsx*
802
3471
  ```typescript jsx
803
- import { useRouter } from '@innet/server'
3472
+ import { useSearch } from '@innet/sever'
804
3473
 
805
- function Router () {
806
- const { prefix, params } = useRouter()
3474
+ export function Component () {
3475
+ const search = useSearch()
807
3476
 
808
- return <success>{{ prefix, params }}</success>
3477
+ return <success>{search}</success>
809
3478
  }
810
3479
  ```
811
3480
 
812
- Use named capturing groups of regex in a route path prop to add the `params`.
3481
+ ### useBody
3482
+
3483
+ [← back](#hooks)
3484
+
3485
+ This hook MUST be used in a component placed in [\<request>](#request) or [\<fallback>](#fallback).
3486
+ This hook returns current request body.
813
3487
 
3488
+ *src/Component.tsx*
814
3489
  ```typescript jsx
815
- export default (
816
- <server>
817
- <router path='/user/(?<id>[\w-]+)'>
818
- <Router />
819
- </router>
820
- </server>
821
- )
822
- ```
3490
+ import { useBody } from '@innet/sever'
3491
+
3492
+ export function Component () {
3493
+ const body = useBody()
823
3494
 
824
- In this case, you will get `id` equals `test` in the params on `/user/test` path.
3495
+ return <success>{body}</success>
3496
+ }
3497
+ ```
825
3498
 
826
3499
  ## Issues
827
3500
  If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innet-server/issues).