@innet/server 1.7.1 → 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 (756) hide show
  1. package/README.md +3065 -476
  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 -45
  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 -43
  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/{action → main/api}/index.js +2 -2
  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/index.es6.js +1 -0
  307. package/plugins/{proxy → request/proxy}/index.js +0 -1
  308. package/plugins/request/proxy/proxy.d.ts +6 -0
  309. package/plugins/request/proxy/proxy.es6.js +20 -0
  310. package/plugins/request/proxy/proxy.js +28 -0
  311. package/plugins/{redirect → request/redirect}/index.d.ts +1 -1
  312. package/plugins/{redirect → request/redirect}/redirect.d.ts +17 -19
  313. package/plugins/request/redirect/redirect.es6.js +41 -0
  314. package/plugins/request/redirect/redirect.js +46 -0
  315. package/plugins/{success → request/success}/index.d.ts +1 -1
  316. package/plugins/{success → request/success}/success.d.ts +17 -19
  317. package/plugins/request/success/success.es6.js +33 -0
  318. package/plugins/request/success/success.js +38 -0
  319. package/plugins/schema/array/array.d.ts +5 -0
  320. package/plugins/schema/array/array.es6.js +58 -0
  321. package/plugins/schema/array/array.js +66 -0
  322. package/plugins/schema/array/index.d.ts +1 -0
  323. package/plugins/schema/array/index.es6.js +1 -0
  324. package/plugins/schema/array/index.js +9 -0
  325. package/plugins/schema/binary/binary.d.ts +9 -0
  326. package/plugins/schema/binary/binary.es6.js +39 -0
  327. package/plugins/schema/binary/binary.js +43 -0
  328. package/plugins/schema/binary/index.d.ts +1 -0
  329. package/plugins/schema/binary/index.es6.js +1 -0
  330. package/plugins/schema/binary/index.js +9 -0
  331. package/plugins/schema/boolean/boolean.d.ts +5 -0
  332. package/plugins/schema/boolean/boolean.es6.js +32 -0
  333. package/plugins/schema/boolean/boolean.js +36 -0
  334. package/plugins/schema/boolean/index.d.ts +1 -0
  335. package/plugins/schema/boolean/index.es6.js +1 -0
  336. package/plugins/schema/boolean/index.js +9 -0
  337. package/plugins/schema/date/date.d.ts +8 -0
  338. package/plugins/schema/date/date.es6.js +64 -0
  339. package/plugins/schema/date/date.js +68 -0
  340. package/plugins/schema/date/index.d.ts +1 -0
  341. package/plugins/schema/date/index.es6.js +1 -0
  342. package/plugins/schema/date/index.js +9 -0
  343. package/plugins/schema/field/field.d.ts +6 -0
  344. package/plugins/schema/field/field.es6.js +46 -0
  345. package/plugins/schema/field/field.js +54 -0
  346. package/plugins/schema/field/index.d.ts +1 -0
  347. package/plugins/schema/field/index.es6.js +1 -0
  348. package/plugins/schema/field/index.js +9 -0
  349. package/plugins/schema/index.d.ts +12 -0
  350. package/plugins/schema/index.es6.js +12 -0
  351. package/plugins/schema/index.js +15 -0
  352. package/plugins/schema/integer/index.d.ts +1 -0
  353. package/plugins/schema/integer/index.es6.js +1 -0
  354. package/plugins/schema/integer/index.js +9 -0
  355. package/plugins/schema/integer/integer.d.ts +8 -0
  356. package/plugins/schema/integer/integer.es6.js +46 -0
  357. package/plugins/schema/integer/integer.js +50 -0
  358. package/plugins/schema/null/index.d.ts +1 -0
  359. package/plugins/schema/null/index.es6.js +1 -0
  360. package/plugins/schema/null/index.js +9 -0
  361. package/plugins/schema/null/null.d.ts +5 -0
  362. package/plugins/schema/null/null.es6.js +15 -0
  363. package/plugins/schema/null/null.js +19 -0
  364. package/plugins/schema/number/index.d.ts +1 -0
  365. package/plugins/schema/number/index.es6.js +1 -0
  366. package/plugins/schema/number/index.js +9 -0
  367. package/plugins/schema/number/number.d.ts +9 -0
  368. package/plugins/schema/number/number.es6.js +46 -0
  369. package/plugins/schema/number/number.js +50 -0
  370. package/plugins/schema/object/index.d.ts +1 -0
  371. package/plugins/schema/object/index.es6.js +1 -0
  372. package/plugins/schema/object/index.js +9 -0
  373. package/plugins/schema/object/object.d.ts +5 -0
  374. package/plugins/schema/object/object.es6.js +54 -0
  375. package/plugins/schema/object/object.js +62 -0
  376. package/plugins/schema/string/index.d.ts +1 -0
  377. package/plugins/schema/string/index.es6.js +1 -0
  378. package/plugins/schema/string/index.js +9 -0
  379. package/plugins/schema/string/string.d.ts +9 -0
  380. package/plugins/schema/string/string.es6.js +51 -0
  381. package/plugins/schema/string/string.js +55 -0
  382. package/plugins/schema/tuple/index.d.ts +1 -0
  383. package/plugins/schema/tuple/index.es6.js +1 -0
  384. package/plugins/schema/tuple/index.js +9 -0
  385. package/plugins/schema/tuple/tuple.d.ts +5 -0
  386. package/plugins/schema/tuple/tuple.es6.js +54 -0
  387. package/plugins/schema/tuple/tuple.js +62 -0
  388. package/plugins/schema/uuid/index.d.ts +1 -0
  389. package/plugins/schema/uuid/index.es6.js +1 -0
  390. package/plugins/schema/uuid/index.js +9 -0
  391. package/plugins/schema/uuid/uuid.d.ts +6 -0
  392. package/plugins/schema/uuid/uuid.es6.js +39 -0
  393. package/plugins/schema/uuid/uuid.js +43 -0
  394. package/plugins/utils/dev/dev.d.ts +4 -0
  395. package/plugins/utils/dev/dev.es6.js +10 -0
  396. package/plugins/utils/dev/dev.js +18 -0
  397. package/plugins/utils/dev/index.d.ts +1 -0
  398. package/plugins/utils/dev/index.es6.js +1 -0
  399. package/plugins/utils/dev/index.js +9 -0
  400. package/plugins/utils/dts/dts.d.ts +6 -0
  401. package/plugins/utils/dts/dts.es6.js +35 -0
  402. package/plugins/utils/dts/dts.js +44 -0
  403. package/plugins/utils/dts/index.d.ts +1 -0
  404. package/plugins/utils/dts/index.es6.js +1 -0
  405. package/plugins/utils/dts/index.js +9 -0
  406. package/plugins/utils/index.d.ts +4 -0
  407. package/plugins/utils/index.es6.js +4 -0
  408. package/plugins/utils/index.js +7 -0
  409. package/plugins/utils/prod/index.d.ts +1 -0
  410. package/plugins/utils/prod/index.es6.js +1 -0
  411. package/plugins/utils/prod/index.js +9 -0
  412. package/plugins/utils/prod/prod.d.ts +4 -0
  413. package/plugins/utils/prod/prod.es6.js +10 -0
  414. package/plugins/utils/prod/prod.js +18 -0
  415. package/plugins/utils/swagger/index.d.ts +1 -0
  416. package/plugins/utils/swagger/index.es6.js +1 -0
  417. package/plugins/utils/swagger/index.js +9 -0
  418. package/plugins/utils/swagger/swagger.d.ts +5 -0
  419. package/plugins/utils/swagger/swagger.es6.js +28 -0
  420. package/plugins/utils/swagger/swagger.html.es6.js +3 -0
  421. package/plugins/utils/swagger/swagger.html.js +7 -0
  422. package/plugins/utils/swagger/swagger.js +32 -0
  423. package/types.d.ts +76 -0
  424. package/types.es6.js +1 -0
  425. package/types.js +2 -0
  426. package/utils/FileData/Bin.d.ts +47 -0
  427. package/utils/FileData/Bin.es6.js +19 -0
  428. package/utils/FileData/Bin.js +23 -0
  429. package/utils/FileData/index.d.ts +1 -0
  430. package/utils/FileData/index.es6.js +1 -0
  431. package/utils/FileData/index.js +9 -0
  432. package/utils/JSONString/JSONString.d.ts +1 -0
  433. package/utils/JSONString/JSONString.es6.js +10 -0
  434. package/utils/JSONString/JSONString.js +14 -0
  435. package/utils/JSONString/index.d.ts +1 -0
  436. package/utils/JSONString/index.es6.js +1 -0
  437. package/utils/JSONString/index.js +9 -0
  438. package/utils/action/Action.d.ts +29 -0
  439. package/utils/action/Action.es6.js +125 -0
  440. package/utils/action/Action.js +134 -0
  441. package/utils/action/index.d.ts +1 -1
  442. package/utils/action/index.es6.js +1 -1
  443. package/utils/action/index.js +1 -3
  444. package/utils/dateFormat/dateFormat.d.ts +2 -0
  445. package/utils/dateFormat/dateFormat.es6.js +11 -0
  446. package/utils/dateFormat/dateFormat.js +15 -0
  447. package/utils/dateFormat/index.d.ts +1 -0
  448. package/utils/dateFormat/index.es6.js +1 -0
  449. package/utils/dateFormat/index.js +9 -0
  450. package/utils/decorators/index.d.ts +1 -0
  451. package/utils/decorators/index.es6.js +1 -0
  452. package/utils/decorators/index.js +4 -0
  453. package/utils/decorators/once/index.d.ts +1 -0
  454. package/utils/decorators/once/index.es6.js +1 -0
  455. package/utils/decorators/once/index.js +9 -0
  456. package/utils/decorators/once/once.d.ts +4 -0
  457. package/utils/decorators/once/once.es6.js +28 -0
  458. package/utils/decorators/once/once.js +32 -0
  459. package/utils/decorators/once/once.test.d.ts +1 -0
  460. package/utils/getEndpoint/getEndpoint.d.ts +2 -0
  461. package/utils/getEndpoint/getEndpoint.es6.js +31 -0
  462. package/utils/getEndpoint/getEndpoint.js +35 -0
  463. package/utils/getEndpoint/index.d.ts +1 -0
  464. package/utils/getEndpoint/index.es6.js +1 -0
  465. package/utils/getEndpoint/index.js +9 -0
  466. package/utils/getOrAdd/getOrAdd.d.ts +1 -0
  467. package/utils/getOrAdd/getOrAdd.es6.js +14 -0
  468. package/utils/getOrAdd/getOrAdd.js +18 -0
  469. package/utils/getOrAdd/index.d.ts +1 -0
  470. package/utils/getOrAdd/index.es6.js +1 -0
  471. package/utils/getOrAdd/index.js +9 -0
  472. package/utils/httpOnStart/httpOnStart.d.ts +2 -0
  473. package/utils/httpOnStart/httpOnStart.es6.js +5 -0
  474. package/utils/httpOnStart/httpOnStart.js +9 -0
  475. package/utils/httpOnStart/index.d.ts +1 -0
  476. package/utils/httpOnStart/index.es6.js +1 -0
  477. package/utils/httpOnStart/index.js +9 -0
  478. package/utils/index.d.ts +12 -3
  479. package/utils/index.es6.js +12 -3
  480. package/utils/index.js +12 -13
  481. package/{plugins → utils}/parseBody/index.d.ts +1 -1
  482. package/utils/parseBody/parseBody.d.ts +3 -0
  483. package/utils/parseBody/parseBody.es6.js +23 -0
  484. package/utils/parseBody/parseBody.js +27 -0
  485. package/utils/parseFormBody/index.d.ts +1 -0
  486. package/utils/parseFormBody/index.es6.js +1 -0
  487. package/utils/parseFormBody/index.js +9 -0
  488. package/utils/parseFormBody/parseFormBody.d.ts +3 -0
  489. package/utils/parseFormBody/parseFormBody.es6.js +56 -0
  490. package/utils/parseFormBody/parseFormBody.js +60 -0
  491. package/utils/parseSearch/index.d.ts +1 -1
  492. package/utils/parseSearch/index.es6.js +1 -1
  493. package/utils/parseSearch/index.js +1 -0
  494. package/utils/parseSearch/parseSearch.d.ts +3 -2
  495. package/utils/parseSearch/parseSearch.es6.js +6 -3
  496. package/utils/parseSearch/parseSearch.js +6 -3
  497. package/utils/parseSearch/parseSearch.test.d.ts +1 -0
  498. package/utils/rules/any/any.d.ts +1 -0
  499. package/utils/rules/any/any.es6.js +5 -0
  500. package/utils/rules/any/any.js +9 -0
  501. package/utils/rules/any/index.d.ts +1 -0
  502. package/utils/rules/any/index.es6.js +1 -0
  503. package/utils/rules/any/index.js +9 -0
  504. package/utils/rules/arrayOf/arrayOf.d.ts +2 -0
  505. package/utils/rules/arrayOf/arrayOf.es6.js +15 -0
  506. package/utils/rules/arrayOf/arrayOf.js +19 -0
  507. package/utils/rules/arrayOf/index.d.ts +1 -0
  508. package/utils/rules/arrayOf/index.es6.js +1 -0
  509. package/utils/rules/arrayOf/index.js +9 -0
  510. package/utils/rules/bin/bin.d.ts +2 -0
  511. package/utils/rules/bin/bin.es6.js +12 -0
  512. package/utils/rules/bin/bin.js +16 -0
  513. package/utils/rules/bin/index.d.ts +1 -0
  514. package/utils/rules/bin/index.es6.js +1 -0
  515. package/utils/rules/bin/index.js +9 -0
  516. package/utils/rules/binaryAccept/binaryAccept.d.ts +2 -0
  517. package/utils/rules/binaryAccept/binaryAccept.es6.js +32 -0
  518. package/utils/rules/binaryAccept/binaryAccept.js +36 -0
  519. package/utils/rules/binaryAccept/index.d.ts +1 -0
  520. package/utils/rules/binaryAccept/index.es6.js +1 -0
  521. package/utils/rules/binaryAccept/index.js +9 -0
  522. package/utils/rules/constants.d.ts +1 -0
  523. package/utils/rules/constants.es6.js +28 -0
  524. package/utils/rules/constants.js +32 -0
  525. package/utils/rules/dateTo/dateTo.d.ts +2 -0
  526. package/utils/rules/dateTo/dateTo.es6.js +11 -0
  527. package/utils/rules/dateTo/dateTo.js +15 -0
  528. package/utils/rules/dateTo/index.d.ts +1 -0
  529. package/utils/rules/dateTo/index.es6.js +1 -0
  530. package/utils/rules/dateTo/index.js +9 -0
  531. package/utils/rules/defaultTo/defaultTo.d.ts +1 -0
  532. package/utils/rules/defaultTo/defaultTo.es6.js +9 -0
  533. package/utils/rules/defaultTo/defaultTo.js +13 -0
  534. package/utils/rules/defaultTo/index.d.ts +1 -0
  535. package/utils/rules/defaultTo/index.es6.js +1 -0
  536. package/utils/rules/defaultTo/index.js +9 -0
  537. package/utils/rules/helpers.d.ts +8 -0
  538. package/utils/rules/helpers.es6.js +11 -0
  539. package/utils/rules/helpers.js +16 -0
  540. package/utils/rules/index.d.ts +29 -0
  541. package/utils/rules/index.es6.js +29 -0
  542. package/utils/rules/index.js +39 -0
  543. package/utils/rules/int/index.d.ts +1 -0
  544. package/utils/rules/int/index.es6.js +1 -0
  545. package/utils/rules/int/index.js +9 -0
  546. package/utils/rules/int/int.d.ts +2 -0
  547. package/utils/rules/int/int.es6.js +36 -0
  548. package/utils/rules/int/int.js +40 -0
  549. package/utils/rules/max/index.d.ts +1 -0
  550. package/utils/rules/max/index.es6.js +1 -0
  551. package/utils/rules/max/index.js +9 -0
  552. package/utils/rules/max/max.d.ts +1 -0
  553. package/utils/rules/max/max.es6.js +16 -0
  554. package/utils/rules/max/max.js +20 -0
  555. package/utils/rules/maxBin/index.d.ts +1 -0
  556. package/utils/rules/maxBin/index.es6.js +1 -0
  557. package/utils/rules/maxBin/index.js +9 -0
  558. package/utils/rules/maxBin/maxBin.d.ts +2 -0
  559. package/utils/rules/maxBin/maxBin.es6.js +13 -0
  560. package/utils/rules/maxBin/maxBin.js +17 -0
  561. package/utils/rules/maxDate/index.d.ts +1 -0
  562. package/utils/rules/maxDate/index.es6.js +1 -0
  563. package/utils/rules/maxDate/index.js +9 -0
  564. package/utils/rules/maxDate/maxDate.d.ts +1 -0
  565. package/utils/rules/maxDate/maxDate.es6.js +15 -0
  566. package/utils/rules/maxDate/maxDate.js +19 -0
  567. package/utils/rules/maxLength/index.d.ts +1 -0
  568. package/utils/rules/maxLength/index.es6.js +1 -0
  569. package/utils/rules/maxLength/index.js +9 -0
  570. package/utils/rules/maxLength/maxLength.d.ts +1 -0
  571. package/utils/rules/maxLength/maxLength.es6.js +16 -0
  572. package/utils/rules/maxLength/maxLength.js +20 -0
  573. package/utils/rules/min/index.d.ts +1 -0
  574. package/utils/rules/min/index.es6.js +1 -0
  575. package/utils/rules/min/index.js +9 -0
  576. package/utils/rules/min/min.d.ts +1 -0
  577. package/utils/rules/min/min.es6.js +16 -0
  578. package/utils/rules/min/min.js +20 -0
  579. package/utils/rules/minBin/index.d.ts +1 -0
  580. package/utils/rules/minBin/index.es6.js +1 -0
  581. package/utils/rules/minBin/index.js +9 -0
  582. package/utils/rules/minBin/minBin.d.ts +2 -0
  583. package/utils/rules/minBin/minBin.es6.js +13 -0
  584. package/utils/rules/minBin/minBin.js +17 -0
  585. package/utils/rules/minDate/index.d.ts +1 -0
  586. package/utils/rules/minDate/index.es6.js +1 -0
  587. package/utils/rules/minDate/index.js +9 -0
  588. package/utils/rules/minDate/minDate.d.ts +1 -0
  589. package/utils/rules/minDate/minDate.es6.js +15 -0
  590. package/utils/rules/minDate/minDate.js +19 -0
  591. package/utils/rules/minLength/index.d.ts +1 -0
  592. package/utils/rules/minLength/index.es6.js +1 -0
  593. package/utils/rules/minLength/index.js +9 -0
  594. package/utils/rules/minLength/minLength.d.ts +1 -0
  595. package/utils/rules/minLength/minLength.es6.js +16 -0
  596. package/utils/rules/minLength/minLength.js +20 -0
  597. package/utils/rules/nullable/index.d.ts +1 -0
  598. package/utils/rules/nullable/index.es6.js +1 -0
  599. package/utils/rules/nullable/index.js +9 -0
  600. package/utils/rules/nullable/nullable.d.ts +1 -0
  601. package/utils/rules/nullable/nullable.es6.js +10 -0
  602. package/utils/rules/nullable/nullable.js +14 -0
  603. package/utils/rules/num/index.d.ts +1 -0
  604. package/utils/rules/num/index.es6.js +1 -0
  605. package/utils/rules/num/index.js +9 -0
  606. package/utils/rules/num/num.d.ts +1 -0
  607. package/utils/rules/num/num.es6.js +11 -0
  608. package/utils/rules/num/num.js +15 -0
  609. package/utils/rules/objectOf/index.d.ts +1 -0
  610. package/utils/rules/objectOf/index.es6.js +1 -0
  611. package/utils/rules/objectOf/index.js +9 -0
  612. package/utils/rules/objectOf/objectOf.d.ts +3 -0
  613. package/utils/rules/objectOf/objectOf.es6.js +16 -0
  614. package/utils/rules/objectOf/objectOf.js +20 -0
  615. package/utils/rules/oneOf/index.d.ts +1 -0
  616. package/utils/rules/oneOf/index.es6.js +1 -0
  617. package/utils/rules/oneOf/index.js +9 -0
  618. package/utils/rules/oneOf/oneOf.d.ts +2 -0
  619. package/utils/rules/oneOf/oneOf.es6.js +18 -0
  620. package/utils/rules/oneOf/oneOf.js +22 -0
  621. package/utils/rules/optional/index.d.ts +1 -0
  622. package/utils/rules/optional/index.es6.js +1 -0
  623. package/utils/rules/optional/index.js +9 -0
  624. package/utils/rules/optional/optional.d.ts +2 -0
  625. package/utils/rules/optional/optional.es6.js +9 -0
  626. package/utils/rules/optional/optional.js +13 -0
  627. package/utils/rules/pattern/index.d.ts +1 -0
  628. package/utils/rules/pattern/index.es6.js +1 -0
  629. package/utils/rules/pattern/index.js +9 -0
  630. package/utils/rules/pattern/pattern.d.ts +1 -0
  631. package/utils/rules/pattern/pattern.es6.js +13 -0
  632. package/utils/rules/pattern/pattern.js +17 -0
  633. package/utils/rules/pipe/index.d.ts +1 -0
  634. package/utils/rules/pipe/index.es6.js +1 -0
  635. package/utils/rules/pipe/index.js +9 -0
  636. package/utils/rules/pipe/pipe.d.ts +2 -0
  637. package/utils/rules/pipe/pipe.es6.js +7 -0
  638. package/utils/rules/pipe/pipe.js +11 -0
  639. package/utils/rules/required/index.d.ts +1 -0
  640. package/utils/rules/required/index.es6.js +1 -0
  641. package/utils/rules/required/index.js +9 -0
  642. package/utils/rules/required/required.d.ts +2 -0
  643. package/utils/rules/required/required.es6.js +12 -0
  644. package/utils/rules/required/required.js +16 -0
  645. package/utils/rules/tupleOf/index.d.ts +1 -0
  646. package/utils/rules/tupleOf/index.es6.js +1 -0
  647. package/utils/rules/tupleOf/index.js +9 -0
  648. package/utils/rules/tupleOf/tupleOf.d.ts +2 -0
  649. package/utils/rules/tupleOf/tupleOf.es6.js +19 -0
  650. package/utils/rules/tupleOf/tupleOf.js +23 -0
  651. package/utils/rules/types.d.ts +4 -0
  652. package/utils/rules/types.es6.js +1 -0
  653. package/utils/rules/types.js +2 -0
  654. package/utils/rules/uuidTo/index.d.ts +1 -0
  655. package/utils/rules/uuidTo/index.es6.js +1 -0
  656. package/utils/rules/uuidTo/index.js +9 -0
  657. package/utils/rules/uuidTo/uuidTo.d.ts +1 -0
  658. package/utils/rules/uuidTo/uuidTo.es6.js +11 -0
  659. package/utils/rules/uuidTo/uuidTo.js +15 -0
  660. package/utils/rules/values/index.d.ts +1 -0
  661. package/utils/rules/values/index.es6.js +1 -0
  662. package/utils/rules/values/index.js +9 -0
  663. package/utils/rules/values/values.d.ts +1 -0
  664. package/utils/rules/values/values.es6.js +13 -0
  665. package/utils/rules/values/values.js +17 -0
  666. package/utils/stringifySearch/index.d.ts +1 -1
  667. package/utils/stringifySearch/stringifySearch.d.ts +2 -2
  668. package/utils/stringifySearch/stringifySearch.es6.js +2 -2
  669. package/utils/stringifySearch/stringifySearch.js +2 -3
  670. package/experimental/serverFn/serverFn.d.ts +0 -2
  671. package/experimental/serverFn/serverFn.es6.js +0 -12
  672. package/hooks/useFiles/index.d.ts +0 -1
  673. package/hooks/useFiles/index.es6.js +0 -1
  674. package/hooks/useFiles/useFiles.d.ts +0 -1
  675. package/hooks/useFiles/useFiles.es6.js +0 -7
  676. package/plugins/access/access.d.ts +0 -14
  677. package/plugins/access/access.es6.js +0 -24
  678. package/plugins/access/access.js +0 -34
  679. package/plugins/access/index.d.ts +0 -1
  680. package/plugins/access/index.es6.js +0 -1
  681. package/plugins/access/index.js +0 -10
  682. package/plugins/action/action.d.ts +0 -10
  683. package/plugins/action/action.es6.js +0 -38
  684. package/plugins/action/action.js +0 -60
  685. package/plugins/action/index.d.ts +0 -1
  686. package/plugins/action/index.es6.js +0 -1
  687. package/plugins/cms/cms.d.ts +0 -9
  688. package/plugins/cms/cms.es6.js +0 -25
  689. package/plugins/cms/cms.js +0 -34
  690. package/plugins/cookie/cookie.d.ts +0 -14
  691. package/plugins/cookie/cookie.es6.js +0 -21
  692. package/plugins/cookie/cookie.js +0 -29
  693. package/plugins/file/file.d.ts +0 -7
  694. package/plugins/file/file.es6.js +0 -39
  695. package/plugins/file/file.js +0 -50
  696. package/plugins/formatter/formatter.d.ts +0 -16
  697. package/plugins/formatter/formatter.es6.js +0 -30
  698. package/plugins/formatter/formatter.js +0 -51
  699. package/plugins/formatter/index.d.ts +0 -1
  700. package/plugins/formatter/index.es6.js +0 -1
  701. package/plugins/formatter/index.js +0 -9
  702. package/plugins/header/header.d.ts +0 -12
  703. package/plugins/header/header.es6.js +0 -14
  704. package/plugins/header/header.js +0 -23
  705. package/plugins/parseBody/parseBody.d.ts +0 -7
  706. package/plugins/parseBody/parseBody.es6.js +0 -9
  707. package/plugins/parseBody/parseBody.js +0 -18
  708. package/plugins/proxy/index.es6.js +0 -1
  709. package/plugins/proxy/proxy.d.ts +0 -9
  710. package/plugins/proxy/proxy.es6.js +0 -18
  711. package/plugins/proxy/proxy.js +0 -28
  712. package/plugins/redirect/redirect.es6.js +0 -34
  713. package/plugins/redirect/redirect.js +0 -40
  714. package/plugins/router/index.d.ts +0 -1
  715. package/plugins/router/index.es6.js +0 -1
  716. package/plugins/router/index.js +0 -12
  717. package/plugins/router/router.d.ts +0 -20
  718. package/plugins/router/router.es6.js +0 -51
  719. package/plugins/router/router.js +0 -63
  720. package/plugins/server/server.d.ts +0 -22
  721. package/plugins/server/server.es6.js +0 -43
  722. package/plugins/server/server.js +0 -55
  723. package/plugins/success/success.es6.js +0 -34
  724. package/plugins/success/success.js +0 -44
  725. package/plugins/validation/index.d.ts +0 -1
  726. package/plugins/validation/index.es6.js +0 -1
  727. package/plugins/validation/index.js +0 -10
  728. package/plugins/validation/validation.d.ts +0 -16
  729. package/plugins/validation/validation.es6.js +0 -31
  730. package/plugins/validation/validation.js +0 -41
  731. package/utils/action/Action/Action.d.ts +0 -48
  732. package/utils/action/Action/Action.es6.js +0 -134
  733. package/utils/action/Action/Action.js +0 -165
  734. package/utils/action/Action/index.d.ts +0 -1
  735. package/utils/action/Action/index.es6.js +0 -1
  736. package/utils/action/Action/index.js +0 -12
  737. /package/{experimental → plugins/handler}/serverFn/index.es6.js +0 -0
  738. /package/{experimental → plugins/handler}/serverFn/index.js +0 -0
  739. /package/plugins/{server → main/server}/index.es6.js +0 -0
  740. /package/plugins/{server → main/server}/index.js +0 -0
  741. /package/plugins/{cms → request/cms}/index.es6.js +0 -0
  742. /package/plugins/{cms → request/cms}/index.js +0 -0
  743. /package/plugins/{cookie → request/cookie}/index.es6.js +0 -0
  744. /package/plugins/{cookie → request/cookie}/index.js +0 -0
  745. /package/plugins/{error → request/error}/index.es6.js +0 -0
  746. /package/plugins/{error → request/error}/index.js +0 -0
  747. /package/plugins/{file → request/file}/index.es6.js +0 -0
  748. /package/plugins/{file → request/file}/index.js +0 -0
  749. /package/plugins/{header → request/header}/index.es6.js +0 -0
  750. /package/plugins/{header → request/header}/index.js +0 -0
  751. /package/plugins/{redirect → request/redirect}/index.es6.js +0 -0
  752. /package/plugins/{redirect → request/redirect}/index.js +0 -0
  753. /package/plugins/{success → request/success}/index.es6.js +0 -0
  754. /package/plugins/{success → request/success}/index.js +0 -0
  755. /package/{plugins → utils}/parseBody/index.es6.js +0 -0
  756. /package/{plugins → utils}/parseBody/index.js +0 -0
package/README.md CHANGED
@@ -13,899 +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`
27
46
 
28
- ```shell
29
- npx innetjs init my-app -t be
47
+ [← back](#index)
48
+
49
+ The simplest way to start working with `@innet/server`, it is `innetjs` usage.
50
+
51
+ ```shell
52
+ npx innetjs init my-app -t api
53
+ ```
54
+ *change my-app to work folder name*
55
+
56
+ Go into `my-app` and check `README.md`
57
+
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)
2073
+
2074
+ `<tuple>` element specifies schema parameter as a tuple of children elements.
2075
+
2076
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
2077
+
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
+ )
2094
+ ```
2095
+
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`.
2098
+
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*
2104
+ ```typescript jsx
2105
+ export default (
2106
+ <server>
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>
2118
+ </server>
2119
+ )
2120
+ ```
2121
+
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`.
2124
+
2125
+ `/products?rating=text` or `/products?rating=1&rating=6` returns an error.
2126
+
2127
+ #### default
2128
+
2129
+ Defines default `<tuple>` value.
2130
+
2131
+ *src/app.tsx*
2132
+ ```typescript jsx
2133
+ export default (
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>
2146
+ </server>
2147
+ )
2148
+ ```
2149
+
2150
+ #### example
2151
+
2152
+ Defines an example of the `<tuple>` value.
2153
+
2154
+ *src/app.tsx*
2155
+ ```typescript jsx
2156
+ export default (
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>
2169
+ </server>
2170
+ )
30
2171
  ```
31
- *change my-app to work folder name*
32
2172
 
33
- Go into `my-app` and check `README.md`
2173
+ #### description
34
2174
 
35
- ## Handler
2175
+ Defines the `<tuple>` description.
36
2176
 
37
- Use `server` handler to start an application.
38
- ```typescript
39
- import innet from 'innet'
40
- import server from '@innet/server'
2177
+ *src/app.tsx*
2178
+ ```typescript jsx
2179
+ export default (
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>
2195
+ </server>
2196
+ )
2197
+ ```
41
2198
 
42
- import app from './app'
2199
+ ### \<array>
43
2200
 
44
- innet(app, server)
45
- ```
2201
+ [← back](#list-of-data)
46
2202
 
47
- ## Server
48
- To start http(s) server, use `server` element.
2203
+ `<array>` element specifies schema parameter as an array of children elements.
49
2204
 
50
- Try it out in `app.tsx`
2205
+ The element MUST be placed inside one of [\<response>](#response), [\<param>](#param), [\<body>](#body).
2206
+
2207
+ *src/app.tsx*
51
2208
  ```typescript jsx
52
2209
  export default (
53
2210
  <server>
54
- <action>
55
- Hello World!
56
- </action>
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>
57
2220
  </server>
58
2221
  )
59
2222
  ```
60
2223
 
61
- Any content inside the server will be turned back to user.
62
- In this case the user will get `Hello World` on any request.
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.
63
2228
 
64
- Use `npm start` to run this server.
2229
+ #### default
65
2230
 
66
- ### Port
67
- To change the port of the web server you can use `port` prop.
2231
+ Defines default `<array>` value.
68
2232
 
2233
+ *src/app.tsx*
69
2234
  ```typescript jsx
70
2235
  export default (
71
- <server port={80}>
72
- <action>
73
- Hello World!
74
- </action>
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>
75
2246
  </server>
76
2247
  )
77
2248
  ```
78
2249
 
79
- or you can use `PORT` environment variable.
2250
+ #### example
80
2251
 
81
- ### SSL
82
- To have https connection you should provide SSL certificate.
2252
+ Defines an example of the `<array>` value.
83
2253
 
2254
+ *src/app.tsx*
84
2255
  ```typescript jsx
85
- const ssl = {
86
- key: 'local.key',
87
- cert: 'local.crt'
88
- }
89
-
90
2256
  export default (
91
- <server ssl={ssl}>
92
- <action>
93
- Hello World!
94
- </action>
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>
95
2267
  </server>
96
2268
  )
97
2269
  ```
98
2270
 
99
- or you can use `SSL_CRT` and `SSL_KEY` environment variables.
2271
+ #### description
100
2272
 
101
- ### onStart
102
- You can show some message or do something right after the server starts.
2273
+ Defines the `<array>` description.
2274
+
2275
+ *src/app.tsx*
103
2276
  ```typescript jsx
104
2277
  export default (
105
- <server onStart={console.log}>
106
- <action>
107
- Hello World!
108
- </action>
2278
+ <server>
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>
109
2290
  </server>
110
2291
  )
111
2292
  ```
112
2293
 
113
- ### onError
114
- You can log errors or do something else, when the server get an error.
2294
+ ### \<object>
2295
+
2296
+ [← back](#list-of-data)
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).
115
2301
 
2302
+ *src/app.tsx*
116
2303
  ```typescript jsx
117
2304
  export default (
118
- <server onError={console.error}>
119
- <action>
120
- Hello World!
121
- </action>
2305
+ <server>
2306
+ <api>
2307
+ <endpoint method='post' path='/users'>
2308
+ <body>
2309
+ <object />
2310
+ </body>
2311
+ </endpoint>
2312
+ </api>
122
2313
  </server>
123
2314
  )
124
2315
  ```
125
2316
 
126
- ### onRequest
127
- You can log any request with `onRequest` prop.
2317
+ #### default
2318
+
2319
+ A default value for the `object`.
128
2320
 
2321
+ *src/app.tsx*
129
2322
  ```typescript jsx
130
2323
  export default (
131
- <server onRequest={console.log}>
132
- <action>
133
- Hello World!
134
- </action>
2324
+ <server>
2325
+ <api>
2326
+ <endpoint method='post' path='/users'>
2327
+ <body>
2328
+ <object
2329
+ default={{name: 'John'}}
2330
+ />
2331
+ </body>
2332
+ </endpoint>
2333
+ </api>
135
2334
  </server>
136
2335
  )
137
2336
  ```
138
2337
 
139
- ### onDestroy
140
- You can react on destroy the server with `onDestroy` prop.
2338
+ #### example
2339
+
2340
+ An example value.
141
2341
 
2342
+ *src/app.tsx*
142
2343
  ```typescript jsx
143
2344
  export default (
144
- <server
145
- onDestroy={() => console.log('destroy')}>
146
- <action>
147
- Hello World!
148
- </action>
2345
+ <server>
2346
+ <api>
2347
+ <endpoint method='post' path='/users'>
2348
+ <body>
2349
+ <object
2350
+ example={{name: 'John'}}
2351
+ />
2352
+ </body>
2353
+ </endpoint>
2354
+ </api>
149
2355
  </server>
150
2356
  )
151
2357
  ```
152
2358
 
153
- ## HTML
154
- You can use `html` element to return html content.
2359
+ #### description
155
2360
 
2361
+ A description of the `object`.
2362
+
2363
+ *src/app.tsx*
156
2364
  ```typescript jsx
157
2365
  export default (
158
2366
  <server>
159
- <action>
160
- <html>
161
- <head>
162
- <title>Innet App</title>
163
- </head>
2367
+ <api>
2368
+ <endpoint method='post' path='/users'>
164
2369
  <body>
165
- Hello World!
2370
+ <object
2371
+ description='The object of a user'
2372
+ />
166
2373
  </body>
167
- </html>
168
- </action>
2374
+ </endpoint>
2375
+ </api>
169
2376
  </server>
170
2377
  )
171
2378
  ```
172
2379
 
173
- You can use variables to split it anyhow.
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).
2387
+
2388
+ `key` is REQUIRED prop of `<field>`, it defines a field name of the `<object>`.
174
2389
 
2390
+ *src/app.tsx*
175
2391
  ```typescript jsx
176
- const content = (
177
- <html>
178
- <head>
179
- <title>Innet App</title>
180
- </head>
181
- <body>
182
- Hello World!
183
- </body>
184
- </html>
2392
+ export default (
2393
+ <server>
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>
2405
+ </server>
185
2406
  )
2407
+ ```
2408
+
2409
+ #### optional
2410
+
2411
+ By default, any field is required. You can set it as `optional` by this prop.
186
2412
 
2413
+ *src/app.tsx*
2414
+ ```typescript jsx
187
2415
  export default (
188
2416
  <server>
189
- <action>
190
- {content}
191
- </action>
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>
192
2428
  </server>
193
2429
  )
194
2430
  ```
195
2431
 
196
- ## Header
197
- You can add an HTTP header into response with `header` element.
2432
+ ## Run-Time
198
2433
 
199
- ```typescript jsx
200
- const content = (
201
- <html.../>
202
- ) // check prev example
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
+ ---
203
2454
 
2455
+ ### \<fallback>
2456
+
2457
+ [← back](#run-time)
2458
+
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*
2466
+ ```typescript jsx
204
2467
  export default (
205
2468
  <server>
206
- <action>
207
- <header name='content-type' value='text/html'>
208
- {content}
209
- </header>
210
- </action>
2469
+ <api>
2470
+ <fallback>
2471
+ <error
2472
+ code='unknownEndpoint'
2473
+ />
2474
+ </fallback>
2475
+ </api>
211
2476
  </server>
212
2477
  )
213
2478
  ```
214
2479
 
215
- Also, you can put header around the content, it works the same.
2480
+ If you open the application on any URL except for `/`, you can see the next response.
216
2481
 
217
- ```typescript jsx
218
- const content = (
219
- <html.../>
220
- ) // check prev example
2482
+ ```json
2483
+ {
2484
+ "error": "unknownEndpoint"
2485
+ }
2486
+ ```
2487
+
2488
+ The next elements are placed in [\<request>](#request) or [\<fallback>](#fallback)
221
2489
 
2490
+ ### \<request>
2491
+
2492
+ [← back](#run-time)
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*
2498
+ ```typescript jsx
222
2499
  export default (
223
2500
  <server>
224
- <action>
225
- <header name='content-type' value='text/html' />
226
- {content}
227
- </action>
2501
+ <api>
2502
+ <endpoint method='get' path='/partners'>
2503
+ <request>
2504
+ <success>
2505
+ {{partners: []}}
2506
+ </success>
2507
+ </request>
2508
+ </endpoint>
2509
+ </api>
228
2510
  </server>
229
2511
  )
230
2512
  ```
231
2513
 
232
- ## File
233
- You can return a file as a response.
2514
+ You can place a component inside it.
2515
+ The component will run when the endpoint will be triggered.
234
2516
 
2517
+ *src/app.tsx*
235
2518
  ```typescript jsx
2519
+ import { GetPartners } from './GetPartners'
2520
+
236
2521
  export default (
237
2522
  <server>
238
- <action>
239
- <header name='cache-control' value='max-age=300'>
240
- <file path='index.html' />
241
- </header>
242
- </action>
2523
+ <api>
2524
+ <endpoint method='get' path='/partners'>
2525
+ <request>
2526
+ <GetPartners />
2527
+ </request>
2528
+ </endpoint>
2529
+ </api>
243
2530
  </server>
244
2531
  )
245
2532
  ```
246
2533
 
247
- In this case `cache-control` will be equal to `max-age=300` even if the file does not exist.
2534
+ *src/GetPartners.tsx*
2535
+ ```typescript jsx
2536
+ export const GetPartners = () => (
2537
+ <success>
2538
+ {{partners: []}}
2539
+ </success>
2540
+ )
2541
+ ```
2542
+
2543
+ ### \<success>
2544
+
2545
+ [← back](#run-time)
248
2546
 
249
- You can put content into the file to apply it only if the file does exist.
2547
+ This is a base element to return a success data.
250
2548
 
2549
+ *src/app.tsx*
251
2550
  ```typescript jsx
252
2551
  export default (
253
2552
  <server>
254
- <action>
255
- <file path='index.html'>
256
- <header name='cache-control' value='max-age=300' />
257
- </file>
258
- </action>
2553
+ <api>
2554
+ <fallback>
2555
+ <success />
2556
+ </fallback>
2557
+ </api>
259
2558
  </server>
260
2559
  )
261
2560
  ```
262
2561
 
263
- Put `index.html` in the root of the project (`my-app` folder).
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.
264
2565
 
265
- ## Router
266
- The router helps to handle requests by route.
2566
+ *src/app.tsx*
267
2567
  ```typescript jsx
2568
+ const data = {...}
2569
+
268
2570
  export default (
269
2571
  <server>
270
- <action>
271
- <router>
272
- <file path='index.html' />
273
- </router>
274
- </action>
2572
+ <api>
2573
+ <fallback>
2574
+ <success>
2575
+ {data}
2576
+ </success>
2577
+ </fallback>
2578
+ </api>
275
2579
  </server>
276
2580
  )
277
2581
  ```
278
2582
 
279
- The router does nothing and returns self content.
280
- It starts work only with the next props.
2583
+ You will get `200` status (`ok`), with body equals data.
2584
+
2585
+ #### status
281
2586
 
282
- ### method
283
- This property says that the content of the route should be run if the request method equals to the prop.
2587
+ You can set response status by `status` prop of `<success>`.
284
2588
 
2589
+ *src/app.tsx*
285
2590
  ```typescript jsx
2591
+ const data = {...}
2592
+
286
2593
  export default (
287
2594
  <server>
288
- <action>
289
- <router method='GET'>
290
- <file path='index.html' />
291
- </router>
292
- </action>
2595
+ <api>
2596
+ <fallback>
2597
+ <success status='created'>
2598
+ {data}
2599
+ </success>
2600
+ </fallback>
2601
+ </api>
293
2602
  </server>
294
2603
  )
295
2604
  ```
296
2605
 
297
- ### path
298
- You can set `path` to match with it.
2606
+ You will get `201` status (`created`), with data as a content.
2607
+
2608
+ You can use a number of `status` prop.
299
2609
 
2610
+ *src/app.tsx*
300
2611
  ```typescript jsx
2612
+ const data = {...}
2613
+
301
2614
  export default (
302
2615
  <server>
303
- <action>
304
- <router method='GET' path='/'>
305
- <file path='index.html' />
306
- </router>
307
- </action>
2616
+ <api>
2617
+ <fallback>
2618
+ <success status={201}>
2619
+ {data}
2620
+ </success>
2621
+ </fallback>
2622
+ </api>
308
2623
  </server>
309
2624
  )
310
2625
  ```
311
2626
 
312
- You will get the `index.html` only on the root path with `GET` method.
2627
+ ### \<error>
313
2628
 
314
- This prop has regex like syntax, so you can set the path as you wish.
2629
+ [← back](#run-time)
315
2630
 
2631
+ Returns an error.
2632
+ This element MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
2633
+
2634
+ *src/app.tsx*
316
2635
  ```typescript jsx
317
2636
  export default (
318
2637
  <server>
319
- <action>
320
- <router path='/user/[0-9]+'>
321
- <file path='index.html' />
322
- </router>
323
- </action>
2638
+ <api>
2639
+ <fallback>
2640
+ <error />
2641
+ </fallback>
2642
+ </api>
324
2643
  </server>
325
2644
  )
326
2645
  ```
327
2646
 
328
- To provide named params from url, use named capturing groups of regex.
2647
+ Place a data into the element to return an error with the data.
329
2648
 
2649
+ *src/app.tsx*
330
2650
  ```typescript jsx
2651
+ const data = {...}
2652
+
331
2653
  export default (
332
2654
  <server>
333
- <action>
334
- <router path='/user/(?<id>[\w-]+)'>
335
- <file path='index.html' />
336
- </router>
337
- </action>
2655
+ <api>
2656
+ <fallback>
2657
+ <error>
2658
+ {data}
2659
+ </error>
2660
+ </fallback>
2661
+ </api>
338
2662
  </server>
339
2663
  )
340
2664
  ```
341
2665
 
342
- ### ish
343
- You can react on any path which starts with provided one.
2666
+ #### status
2667
+ You can change response status by `status` prop. By default, it is `520` (`unknownError`)
344
2668
 
2669
+ *src/app.tsx*
345
2670
  ```typescript jsx
2671
+ const data = {
2672
+ message: 'User not found!'
2673
+ }
2674
+
346
2675
  export default (
347
2676
  <server>
348
- <action>
349
- <router path='/test' ish>
350
- <file path='index.html' />
351
- </router>
352
- </action>
2677
+ <api>
2678
+ <fallback>
2679
+ <error status='notFound'>
2680
+ {data}
2681
+ </error>
2682
+ </fallback>
2683
+ </api>
353
2684
  </server>
354
2685
  )
355
2686
  ```
356
2687
 
357
- `/`, `/something`, `/test1` do not match.
358
- `/test`, `/test/something` matches.
359
-
360
- ### prefix
361
-
362
- You can use a router inside another one and `prefix` helps reduce path prop.
2688
+ You can use a number with the status prop.
363
2689
 
2690
+ *src/app.tsx*
364
2691
  ```typescript jsx
2692
+ const data = {
2693
+ message: 'User not found!'
2694
+ }
2695
+
365
2696
  export default (
366
2697
  <server>
367
- <action>
368
- <router path='/test' prefix='/test' ish>
369
- <router path='/'>
370
- <file path='index.html' />
371
- </router>
372
- <router path='/404'>
373
- <file path='404.html' />
374
- </router>
375
- </router>
376
- </action>
2698
+ <api>
2699
+ <fallback>
2700
+ <error status={404}>
2701
+ {data}
2702
+ </error>
2703
+ </fallback>
2704
+ </api>
377
2705
  </server>
378
2706
  )
379
2707
  ```
380
2708
 
381
- Here you can get `index.html` on `/test` and `404.html` on `/test/404`.
2709
+ #### code
2710
+ When you use `<error>` element a user get next response body.
382
2711
 
383
- ### onMatch
2712
+ *for the previous example*
2713
+ ```json
2714
+ {
2715
+ "error": "undefined",
2716
+ "data": {
2717
+ "message": "User not found!"
2718
+ }
2719
+ }
2720
+ ```
384
2721
 
385
- You can log the requests of any router.
2722
+ You can change the `error` code by `code` property.
386
2723
 
2724
+ *src/app.tsx*
387
2725
  ```typescript jsx
2726
+ const data = {
2727
+ message: 'User not found!'
2728
+ }
2729
+
388
2730
  export default (
389
2731
  <server>
390
- <action>
391
- <router path='/test' onMatch={console.log}>
392
- <file path='index.html' />
393
- </router>
394
- </action>
2732
+ <api>
2733
+ <fallback>
2734
+ <error
2735
+ code='noUser'
2736
+ status='notFound'>
2737
+ {data}
2738
+ </error>
2739
+ </fallback>
2740
+ </api>
395
2741
  </server>
396
2742
  )
397
2743
  ```
398
2744
 
399
- ## switch
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>
400
2765
 
401
- By default,
402
- routers in the same router runs one by one
403
- independent to result of the previous route.
2766
+ [← back](#run-time)
404
2767
 
405
- To avoid this you can use switch element.
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*
406
2773
  ```typescript jsx
407
2774
  export default (
408
2775
  <server>
409
- <action>
410
- <switch>
411
- <router path='/'>
412
- <file path='index.html' />
413
- </router>
414
- <file path='404.html' />
415
- </switch>
416
- </action>
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>
417
2788
  </server>
418
2789
  )
419
2790
  ```
420
2791
 
421
- You will get `index.html` only on the root path,
422
- any other path will return `404.html`.
2792
+ ### \<redirect>
423
2793
 
424
- ## cms
2794
+ [← back](#run-time)
425
2795
 
426
- CMS helps to return files from a folder by path.
2796
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
427
2797
 
2798
+ You can redirect users to another resource. It adds `Cache-Control` header by default.
2799
+
2800
+ *src/app.tsx*
428
2801
  ```typescript jsx
429
2802
  export default (
430
2803
  <server>
431
- <action>
432
- <switch>
433
- <cms dir='cms' />
434
- <file path='404.html' />
435
- </switch>
436
- </action>
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
- It will check if the file exist in cms folder then returns the file else returns `404.html`.
2820
+ #### status
442
2821
 
443
- You can use prefix with router to handle specific path.
2822
+ `<redirect>` element returns status `301` by default.
2823
+ You can change it by `status` property.
444
2824
 
2825
+ *src/app.tsx*
445
2826
  ```typescript jsx
446
2827
  export default (
447
2828
  <server>
448
- <action>
449
- <switch>
450
- <router path='/cms' ish>
451
- <cms dir='cms' prefix='/cms' />
452
- </router>
453
- <file path='404.html' />
454
- </switch>
455
- </action>
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>
456
2847
  </server>
457
2848
  )
458
2849
  ```
459
2850
 
460
- You can input something into `cms`, if requested file is exist then the content should be used.
2851
+ ### \<cms>
2852
+
2853
+ [← back](#run-time)
461
2854
 
2855
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
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*
462
2860
  ```typescript jsx
463
2861
  export default (
464
2862
  <server>
465
- <action>
466
- <switch>
467
- <cms dir='cms'>
468
- <header name='cache-control' value='max-age=300' />
469
- </cms>
470
- <file path='404.html' />
471
- </switch>
472
- </action>
2863
+ <api>
2864
+ <fallback>
2865
+ <cms />
2866
+ </fallback>
2867
+ </api>
473
2868
  </server>
474
2869
  )
475
2870
  ```
476
2871
 
477
- ## proxy
478
- You can proxy request.
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.
479
2877
 
2878
+ You can change root folder by `dir` property.
2879
+
2880
+ *src/app.tsx*
480
2881
  ```typescript jsx
481
2882
  export default (
482
2883
  <server>
483
- <action>
484
- <switch>
485
- <cms dir='cms' />
486
- <proxy to='https://site.com' />
487
- </switch>
488
- </action>
2884
+ <api>
2885
+ <fallback>
2886
+ <cms dir='src' />
2887
+ </fallback>
2888
+ </api>
489
2889
  </server>
490
2890
  )
491
2891
  ```
492
2892
 
493
- In this case, if you have a file in cms folder then the file will return
494
- else makes request to the `site.com`.
2893
+ Now you can try [http://localhost/index.tsx](http://localhost/index.tsx)
2894
+ you get the index file in `src` folder.
2895
+
2896
+ #### prefix
495
2897
 
496
- ## redirect
497
- You can redirect users to another resource.
2898
+ `<cms>` matches full `path`, you should take it into account if you add `prefix` on `<api>`.
498
2899
 
2900
+ *src/app.tsx*
499
2901
  ```typescript jsx
500
2902
  export default (
501
2903
  <server>
502
- <action>
503
- <switch>
504
- <cms dir='cms' />
505
- <redirect to='https://site.com' />
506
- </switch>
507
- </action>
2904
+ <api prefix='/src'>
2905
+ <fallback>
2906
+ <cms />
2907
+ </fallback>
2908
+ </api>
508
2909
  </server>
509
2910
  )
510
2911
  ```
511
2912
 
512
- ### status
513
- By default, status is `301`, you can change it with `status` prop.
2913
+ Here you can try [http://localhost/src/index.tsx](http://localhost/src/index.tsx)
2914
+ you get the index file in `src` folder.
514
2915
 
2916
+ You can reduce the path for matching by prefix property of `<cms>`.
2917
+
2918
+ *src/app.tsx*
515
2919
  ```typescript jsx
516
2920
  export default (
517
2921
  <server>
518
- <action>
519
- <switch>
520
- <cms dir='cms' />
521
- <redirect to='https://site.com' status={302} />
522
- </switch>
523
- </action>
2922
+ <api prefix='/api'>
2923
+ <fallback>
2924
+ <cms prefix='/api' />
2925
+ </fallback>
2926
+ </api>
524
2927
  </server>
525
2928
  )
526
2929
  ```
527
2930
 
528
- Also, you can use string key of status.
2931
+ Now you can try [http://localhost/api/package.json](http://localhost/api/package.json)
2932
+
2933
+ #### children
529
2934
 
2935
+ You can handle if a file was not found by children elements of `<cms>`.
2936
+
2937
+ *src/app.tsx*
530
2938
  ```typescript jsx
531
2939
  export default (
532
2940
  <server>
533
- <action>
534
- <switch>
535
- <cms dir='cms' />
536
- <redirect to='https://site.com' status='found'/>
537
- </switch>
538
- </action>
2941
+ <api prefix='/src'>
2942
+ <fallback>
2943
+ <cms>
2944
+ <error status={404} />
2945
+ </cms>
2946
+ </fallback>
2947
+ </api>
539
2948
  </server>
540
2949
  )
541
2950
  ```
542
2951
 
543
- ## Components
2952
+ ### \<file>
2953
+
2954
+ [← back](#run-time)
544
2955
 
545
- Any component is just a function which returns content that should be run.
2956
+ It returns a file. MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
546
2957
 
547
- `server.tsx`
2958
+ It adds `Content-Length` and `Content-Type` automatically.
2959
+
2960
+ It has a REQUIRED property of `path`.
2961
+
2962
+ *src/app.tsx*
548
2963
  ```typescript jsx
549
- export const Server = ({ cmsPrefix }) => (
2964
+ export default (
550
2965
  <server>
551
- <action>
552
- <switch>
553
- <router path={cmsPrefix} ish>
554
- <cms dir='cms' prefix={cmsPrefix} />
555
- </router>
556
- <file path='404.html' />
557
- </switch>
558
- </action>
2966
+ <api>
2967
+ <fallback>
2968
+ <file
2969
+ path='package.json'
2970
+ />
2971
+ </fallback>
2972
+ </api>
559
2973
  </server>
560
2974
  )
561
2975
  ```
562
2976
 
563
- and then you can use it inside `app.tsx`.
2977
+ For this example you get `package.json` file of the project on any path except for `/`.
564
2978
 
565
- ```typescript jsx
566
- import { Server } from './server'
2979
+ #### children
2980
+
2981
+ You can handle if a file was not found by children elements of `<file>`.
567
2982
 
568
- export default <Server cmsPrefix='/cms' />
2983
+ *src/app.tsx*
2984
+ ```typescript jsx
2985
+ export default (
2986
+ <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>
2995
+ )
569
2996
  ```
570
2997
 
571
- You can use it with any other functionality, for example with `html`.
2998
+ ### \<header>
572
2999
 
573
- ```typescript jsx
574
- import { useChildren } from '@innet/jsx'
3000
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
575
3001
 
576
- function Html ({ title }) {
577
- const children = useChildren()
3002
+ [← back](#run-time)
578
3003
 
579
- return (
580
- <header name='content-type' value='text/html'>
581
- <html>
582
- <head>
583
- <title>{title}</title>
584
- </head>
585
- <body>
586
- {children}
587
- </body>
588
- </html>
589
- </header>
590
- )
591
- }
3004
+ You can add an HTTP header into response by `<header>` element.
592
3005
 
3006
+ *src/app.tsx*
3007
+ ```typescript jsx
593
3008
  export default (
594
3009
  <server>
595
- <action>
596
- <Html title='main'>
597
- Hello World!
598
- </Html>
599
- </action>
600
- </server>
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>
3019
+ </server>
601
3020
  )
602
3021
  ```
603
3022
 
604
- The first argument is props, the second is children and the last one is a handler.
3023
+ ### \<cookie>
605
3024
 
606
- You can use components inside another component.
3025
+ MUST be placed in [\<request>](#request) or [\<fallback>](#fallback).
607
3026
 
608
- ## success
609
- If you work on REST API, you can use `success` or `error` as an answer
3027
+ [← back](#run-time)
610
3028
 
3029
+ You can add/remove a cookie into response by `<cookie>` element.
3030
+
3031
+ *src/app.tsx*
611
3032
  ```typescript jsx
612
3033
  export default (
613
3034
  <server>
614
- <action>
615
- <success />
616
- </action>
617
- </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>
618
3048
  )
619
3049
  ```
620
3050
 
621
- You will get `204` status (`noContent`), without content.
3051
+ #### domain
622
3052
 
623
- You can provide some data to the user by children.
624
- ```typescript jsx
625
- const data = {
626
- posts: []
627
- }
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.
628
3055
 
3056
+ *src/app.tsx*
3057
+ ```typescript jsx
629
3058
  export default (
630
3059
  <server>
631
- <action>
632
- <success>
633
- {data}
634
- </success>
635
- </action>
3060
+ <api prefix='/src'>
3061
+ <fallback>
3062
+ <cookie
3063
+ domain='.example.com'
3064
+ key='token'
3065
+ value='...'
3066
+ />
3067
+ <success />
3068
+ </fallback>
3069
+ </api>
636
3070
  </server>
637
3071
  )
638
3072
  ```
639
- You will get `200` status (`ok`), with body equals data.
640
3073
 
641
- ### status
642
- You can set status by status prop.
3074
+ #### encode
643
3075
 
644
- ```typescript jsx
645
- const data = {
646
- id: '123'
647
- }
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.
3078
+
3079
+ #### expires
648
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*
3085
+ ```typescript jsx
649
3086
  export default (
650
3087
  <server>
651
- <action>
652
- <success status='created'>
653
- {data}
654
- </success>
655
- </action>
656
- </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>
657
3099
  )
658
3100
  ```
659
3101
 
660
- You will get `201` status (`created`), with data as a content.
3102
+ #### httpOnly
661
3103
 
662
- You can use a number with `status` prop.
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.
663
3106
 
3107
+ *src/app.tsx*
664
3108
  ```typescript jsx
665
- const data = {
666
- id: '123'
667
- }
668
-
669
3109
  export default (
670
3110
  <server>
671
- <action>
672
- <success status={201}>
673
- {data}
674
- </success>
675
- </action>
676
- </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>
677
3122
  )
678
3123
  ```
679
3124
 
680
- ## error
681
- You can return an error to the user.
3125
+ #### maxAge
682
3126
 
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.
3129
+
3130
+ *src/app.tsx*
683
3131
  ```typescript jsx
684
3132
  export default (
685
3133
  <server>
686
- <action>
687
- <error />
688
- </action>
689
- </server>
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>
3145
+ </server>
690
3146
  )
691
3147
  ```
692
3148
 
693
- You will get `520` status (`unknownError`).
3149
+ #### path
694
3150
 
695
- You can provide some data to the user by children.
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”.
696
3153
 
3154
+ *src/app.tsx*
697
3155
  ```typescript jsx
698
- const data = {
699
- message: 'Some error!'
700
- }
701
-
702
3156
  export default (
703
3157
  <server>
704
- <action>
705
- <error>
706
- {data}
707
- </error>
708
- </action>
709
- </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>
710
3171
  )
711
3172
  ```
712
3173
 
713
- ### status
714
- You can change response status by `status` prop.
3174
+ #### priority
715
3175
 
716
- ```typescript jsx
717
- const data = {
718
- message: 'User not found!'
719
- }
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.
720
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
721
3186
  export default (
722
3187
  <server>
723
- <action>
724
- <error status='notFound'>
725
- {data}
726
- </error>
727
- </action>
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>
728
3200
  </server>
729
3201
  )
730
3202
  ```
731
- Also, you can use a number with the status prop.
732
3203
 
733
- ```typescript jsx
734
- const data = {
735
- message: 'User not found!'
736
- }
3204
+ #### sameSite
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.
737
3216
 
3217
+ *src/app.tsx*
3218
+ ```typescript jsx
738
3219
  export default (
739
3220
  <server>
740
- <action>
741
- <error status={404}>
742
- {data}
743
- </error>
744
- </action>
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>
745
3234
  </server>
746
3235
  )
747
3236
  ```
748
3237
 
749
- ## cookie
750
- You can set cookie by `cookie` element.
3238
+ #### secure
751
3239
 
752
- ```typescript jsx
753
- const Login = ({ token }) => (
754
- <cookie key='token' value={token}>
755
- <success />
756
- </cookie>
757
- )
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.
758
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
759
3248
  export default (
760
3249
  <server>
761
- <action>
762
- <Login token='test' />
763
- </action>
764
- </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
+ />
765
3282
  )
766
3283
  ```
767
3284
 
768
- To remove cookie just provide key without value.
3285
+ and then you can use it inside `app.tsx`.
769
3286
 
3287
+ *src/app.tsx*
770
3288
  ```typescript jsx
3289
+ import { SetToken } from './SetToken'
3290
+
771
3291
  export default (
772
3292
  <server>
773
- <action>
774
- <cookie key='token'>
3293
+ <api prefix='/src'>
3294
+ <fallback>
3295
+ <SetToken
3296
+ value='...'
3297
+ />
775
3298
  <success />
776
- </cookie>
777
- </action>
778
- </server>
3299
+ </fallback>
3300
+ </api>
3301
+ </server>
779
3302
  )
780
3303
  ```
781
3304
 
782
- ## useAction
783
- Action is an object which contains `request` and `response`.
784
- Also, it contains a couple of fields and methods.
3305
+ You can use [hooks](#hooks) inside components.
3306
+
3307
+ ## Hooks
785
3308
 
786
- 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*
787
3333
 
788
3334
  ```typescript jsx
789
- import { useAction } from '@innet/server'
3335
+ import { useServer } from '@innet/sever'
3336
+
3337
+ export function Component () {
3338
+ const server = useServer()
790
3339
 
791
- function Test () {
792
- const { req, res } = useAction()
3340
+ console.log(server)
793
3341
 
794
- console.log(req, res)
3342
+ return <success />
795
3343
  }
796
3344
  ```
797
3345
 
798
- ### cookies
799
- 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*
800
3354
 
801
3355
  ```typescript jsx
802
- import { useAction } from '@innet/server'
3356
+ import { useRequest } from '@innet/sever'
3357
+
3358
+ export function Component () {
3359
+ const request = useRequest()
803
3360
 
804
- function Cookies () {
805
- const { cookies } = useAction()
3361
+ console.log(request)
806
3362
 
807
- return <success>{cookies}</success>
3363
+ return <success />
808
3364
  }
809
3365
  ```
810
3366
 
811
- ### setCookie
812
- 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*
813
3375
 
814
3376
  ```typescript jsx
815
- import { useAction } from '@innet/server'
3377
+ import { useResponse } from '@innet/sever'
3378
+
3379
+ export function Component () {
3380
+ const response = useResponse()
816
3381
 
817
- function Login () {
818
- const action = useAction()
3382
+ console.log(response)
819
3383
 
820
- action.setCookie('user', 'token')
3384
+ return <success />
821
3385
  }
822
3386
  ```
823
3387
 
824
- ### path
825
- 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*
826
3396
 
827
3397
  ```typescript jsx
828
- import { useAction } from '@innet/server'
3398
+ import { useHeaders } from '@innet/sever'
829
3399
 
830
- function Path () {
831
- const { path } = useAction()
3400
+ export function Component () {
3401
+ const headers = useHeaders()
832
3402
 
833
- return path
3403
+ return <success>{{ headers }}</success>
834
3404
  }
835
3405
  ```
836
3406
 
837
- ### search
838
- 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*
839
3415
 
840
3416
  ```typescript jsx
841
- import { useAction } from '@innet/server'
3417
+ import { useCookies } from '@innet/sever'
842
3418
 
843
- function Search () {
844
- const { search } = useAction()
3419
+ export function Component () {
3420
+ const cookies = useCookies()
845
3421
 
846
- return <success>{search}</success>
3422
+ return <success>{{ cookies }}</success>
847
3423
  }
848
3424
  ```
849
3425
 
850
- ### body
851
- 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*
852
3434
 
853
3435
  ```typescript jsx
854
- import { useAction } from '@innet/server'
3436
+ import { usePath } from '@innet/sever'
855
3437
 
856
- async function Body () {
857
- const action = useAction()
858
-
859
- await action.parseBody()
3438
+ export function Component () {
3439
+ const path = usePath()
860
3440
 
861
- return <success>{action.body}</success>
3441
+ return <success>{{ path }}</success>
862
3442
  }
863
3443
  ```
864
3444
 
865
- ### files
866
- 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).
867
3451
 
3452
+ *src/Component.tsx*
868
3453
  ```typescript jsx
869
- import { useAction } from '@innet/server'
3454
+ import { useParams } from '@innet/sever'
870
3455
 
871
- async function Body () {
872
- const action = useAction()
873
-
874
- await action.parseBody()
3456
+ export function Component () {
3457
+ const params = useParams()
875
3458
 
876
- return <success>{action.files}</success>
3459
+ return <success>{params}</success>
877
3460
  }
878
3461
  ```
879
3462
 
880
- ## useRouter
3463
+ ### useSearch
881
3464
 
882
- You can get router data in a component
3465
+ [← back](#hooks)
883
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*
884
3471
  ```typescript jsx
885
- import { useRouter } from '@innet/server'
3472
+ import { useSearch } from '@innet/sever'
886
3473
 
887
- function Router () {
888
- const { prefix, params } = useRouter()
3474
+ export function Component () {
3475
+ const search = useSearch()
889
3476
 
890
- return <success>{{ prefix, params }}</success>
3477
+ return <success>{search}</success>
891
3478
  }
892
3479
  ```
893
3480
 
894
- 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.
895
3487
 
3488
+ *src/Component.tsx*
896
3489
  ```typescript jsx
897
- export default (
898
- <server>
899
- <action>
900
- <router path='/user/(?<id>[\w-]+)'>
901
- <Router />
902
- </router>
903
- </action>
904
- </server>
905
- )
906
- ```
3490
+ import { useBody } from '@innet/sever'
3491
+
3492
+ export function Component () {
3493
+ const body = useBody()
907
3494
 
908
- In this case, you will get `id` equals `test` in the params on `/user/test` path.
3495
+ return <success>{body}</success>
3496
+ }
3497
+ ```
909
3498
 
910
3499
  ## Issues
911
3500
  If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innet-server/issues).