@based/server 3.4.5 → 4.0.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 (396) hide show
  1. package/dist/api/index.d.ts +7 -0
  2. package/dist/api/index.js +173 -0
  3. package/dist/api/index.js.map +1 -0
  4. package/dist/auth/dummyAuth.d.ts +1 -1
  5. package/dist/auth/dummyAuth.js +3 -2
  6. package/dist/auth/dummyAuth.js.map +1 -1
  7. package/dist/auth/index.d.ts +8 -4
  8. package/dist/auth/index.js +28 -23
  9. package/dist/auth/index.js.map +1 -1
  10. package/dist/auth/parseAuthState.d.ts +2 -0
  11. package/dist/auth/parseAuthState.js +16 -0
  12. package/dist/auth/parseAuthState.js.map +1 -0
  13. package/dist/auth/types.d.ts +10 -0
  14. package/dist/{handlers/rest/file → auth}/types.js +0 -0
  15. package/dist/auth/types.js.map +1 -0
  16. package/dist/compress.d.ts +5 -0
  17. package/dist/{network/http/compress.js → compress.js} +2 -6
  18. package/dist/compress.js.map +1 -0
  19. package/dist/context.d.ts +54 -0
  20. package/dist/context.js +18 -0
  21. package/dist/context.js.map +1 -0
  22. package/dist/error/errorTypeHandlers.d.ts +6 -0
  23. package/dist/error/errorTypeHandlers.js +130 -0
  24. package/dist/error/errorTypeHandlers.js.map +1 -0
  25. package/dist/error/index.d.ts +5 -0
  26. package/dist/error/index.js +61 -0
  27. package/dist/error/index.js.map +1 -0
  28. package/dist/error/types.d.ts +105 -0
  29. package/dist/error/types.js +30 -0
  30. package/dist/error/types.js.map +1 -0
  31. package/dist/functions/index.d.ts +10 -24
  32. package/dist/functions/index.js +98 -287
  33. package/dist/functions/index.js.map +1 -1
  34. package/dist/functions/timeout.d.ts +1 -1
  35. package/dist/functions/types.d.ts +69 -0
  36. package/dist/functions/types.js +15 -0
  37. package/dist/functions/types.js.map +1 -0
  38. package/dist/incoming/http/authorize.d.ts +4 -0
  39. package/dist/incoming/http/authorize.js +37 -0
  40. package/dist/incoming/http/authorize.js.map +1 -0
  41. package/dist/incoming/http/function.d.ts +4 -0
  42. package/dist/{network → incoming}/http/function.js +13 -13
  43. package/dist/incoming/http/function.js.map +1 -0
  44. package/dist/incoming/http/get.d.ts +4 -0
  45. package/dist/incoming/http/get.js +155 -0
  46. package/dist/incoming/http/get.js.map +1 -0
  47. package/dist/{network → incoming}/http/index.d.ts +0 -0
  48. package/dist/incoming/http/index.js +134 -0
  49. package/dist/incoming/http/index.js.map +1 -0
  50. package/dist/incoming/http/parseQuery.d.ts +4 -0
  51. package/dist/incoming/http/parseQuery.js +25 -0
  52. package/dist/incoming/http/parseQuery.js.map +1 -0
  53. package/dist/incoming/http/readBody.d.ts +4 -0
  54. package/dist/{network → incoming}/http/readBody.js +27 -32
  55. package/dist/incoming/http/readBody.js.map +1 -0
  56. package/dist/{handlers/rest/file → incoming/http/streamFunction}/DataStream.d.ts +0 -0
  57. package/dist/{network → incoming}/http/streamFunction/DataStream.js +0 -0
  58. package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
  59. package/dist/{network → incoming}/http/streamFunction/getExtension.d.ts +0 -0
  60. package/dist/{network → incoming}/http/streamFunction/getExtension.js +0 -0
  61. package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
  62. package/dist/incoming/http/streamFunction/index.d.ts +4 -0
  63. package/dist/incoming/http/streamFunction/index.js +106 -0
  64. package/dist/incoming/http/streamFunction/index.js.map +1 -0
  65. package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
  66. package/dist/{network → incoming}/http/streamFunction/multipartStream.js +12 -12
  67. package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
  68. package/dist/{network → incoming}/http/streamFunction/stream.d.ts +3 -2
  69. package/dist/{network → incoming}/http/streamFunction/stream.js +16 -11
  70. package/dist/incoming/http/streamFunction/stream.js.map +1 -0
  71. package/dist/incoming/index.d.ts +3 -0
  72. package/dist/{network → incoming}/index.js +28 -28
  73. package/dist/incoming/index.js.map +1 -0
  74. package/dist/incoming/upgrade.d.ts +4 -0
  75. package/dist/{network → incoming}/upgrade.js +24 -9
  76. package/dist/incoming/upgrade.js.map +1 -0
  77. package/dist/incoming/ws/auth.d.ts +5 -0
  78. package/dist/incoming/ws/auth.js +40 -0
  79. package/dist/incoming/ws/auth.js.map +1 -0
  80. package/dist/incoming/ws/function.d.ts +3 -0
  81. package/dist/incoming/ws/function.js +107 -0
  82. package/dist/incoming/ws/function.js.map +1 -0
  83. package/dist/incoming/ws/get.d.ts +3 -0
  84. package/dist/incoming/ws/get.js +136 -0
  85. package/dist/incoming/ws/get.js.map +1 -0
  86. package/dist/incoming/ws/index.d.ts +3 -0
  87. package/dist/{network/message → incoming/ws}/index.js +17 -18
  88. package/dist/incoming/ws/index.js.map +1 -0
  89. package/dist/incoming/ws/observable.d.ts +6 -0
  90. package/dist/incoming/ws/observable.js +112 -0
  91. package/dist/incoming/ws/observable.js.map +1 -0
  92. package/dist/index.d.ts +10 -35
  93. package/dist/index.js +17 -196
  94. package/dist/index.js.map +1 -1
  95. package/dist/ip.d.ts +2 -0
  96. package/dist/ip.js +8 -0
  97. package/dist/ip.js.map +1 -0
  98. package/dist/observable/create.d.ts +3 -0
  99. package/dist/observable/create.js +30 -0
  100. package/dist/observable/create.js.map +1 -0
  101. package/dist/observable/destroy.d.ts +2 -0
  102. package/dist/observable/destroy.js +51 -0
  103. package/dist/observable/destroy.js.map +1 -0
  104. package/dist/observable/error.d.ts +4 -0
  105. package/dist/observable/error.js +17 -0
  106. package/dist/observable/error.js.map +1 -0
  107. package/dist/observable/extendCache.d.ts +2 -0
  108. package/dist/observable/extendCache.js +11 -0
  109. package/dist/observable/extendCache.js.map +1 -0
  110. package/dist/observable/genObservableId.d.ts +1 -0
  111. package/dist/observable/genObservableId.js +9 -0
  112. package/dist/observable/genObservableId.js.map +1 -0
  113. package/dist/observable/get.d.ts +4 -0
  114. package/dist/observable/get.js +15 -0
  115. package/dist/observable/get.js.map +1 -0
  116. package/dist/observable/index.d.ts +11 -8
  117. package/dist/observable/index.js +25 -151
  118. package/dist/observable/index.js.map +1 -1
  119. package/dist/observable/send.d.ts +6 -0
  120. package/dist/observable/send.js +32 -0
  121. package/dist/observable/send.js.map +1 -0
  122. package/dist/observable/start/error.d.ts +3 -0
  123. package/dist/observable/start/error.js +36 -0
  124. package/dist/observable/start/error.js.map +1 -0
  125. package/dist/observable/start/index.d.ts +2 -0
  126. package/dist/observable/start/index.js +46 -0
  127. package/dist/observable/start/index.js.map +1 -0
  128. package/dist/observable/start/update.d.ts +6 -0
  129. package/dist/observable/start/update.js +104 -0
  130. package/dist/observable/start/update.js.map +1 -0
  131. package/dist/observable/subscribe.d.ts +7 -0
  132. package/dist/observable/subscribe.js +54 -0
  133. package/dist/observable/subscribe.js.map +1 -0
  134. package/dist/observable/types.d.ts +26 -0
  135. package/dist/observable/types.js +3 -0
  136. package/dist/observable/types.js.map +1 -0
  137. package/dist/observable/unsub.d.ts +6 -0
  138. package/dist/observable/unsub.js +43 -0
  139. package/dist/observable/unsub.js.map +1 -0
  140. package/dist/observable/verify.d.ts +4 -0
  141. package/dist/observable/verify.js +18 -0
  142. package/dist/observable/verify.js.map +1 -0
  143. package/dist/protocol.d.ts +2 -0
  144. package/dist/protocol.js +32 -11
  145. package/dist/protocol.js.map +1 -1
  146. package/dist/security.d.ts +6 -0
  147. package/dist/security.js +95 -0
  148. package/dist/security.js.map +1 -0
  149. package/dist/sendError.d.ts +5 -0
  150. package/dist/sendError.js +42 -0
  151. package/dist/sendError.js.map +1 -0
  152. package/dist/sendHttpResponse.d.ts +4 -0
  153. package/dist/sendHttpResponse.js +53 -0
  154. package/dist/sendHttpResponse.js.map +1 -0
  155. package/dist/server.d.ts +42 -8
  156. package/dist/server.js +26 -12
  157. package/dist/server.js.map +1 -1
  158. package/package.json +16 -14
  159. package/.turbo/turbo-build.log +0 -4
  160. package/dist/BasedServerClient.d.ts +0 -71
  161. package/dist/BasedServerClient.js +0 -390
  162. package/dist/BasedServerClient.js.map +0 -1
  163. package/dist/Client.d.ts +0 -75
  164. package/dist/Client.js +0 -277
  165. package/dist/Client.js.map +0 -1
  166. package/dist/Params.d.ts +0 -20
  167. package/dist/Params.js +0 -48
  168. package/dist/Params.js.map +0 -1
  169. package/dist/auth/authorize.d.ts +0 -2
  170. package/dist/auth/authorize.js +0 -8
  171. package/dist/auth/authorize.js.map +0 -1
  172. package/dist/clientContext.d.ts +0 -0
  173. package/dist/clientContext.js +0 -83
  174. package/dist/clientContext.js.map +0 -1
  175. package/dist/closeListener.d.ts +0 -4
  176. package/dist/closeListener.js +0 -13
  177. package/dist/closeListener.js.map +0 -1
  178. package/dist/error.d.ts +0 -66
  179. package/dist/error.js +0 -149
  180. package/dist/error.js.map +0 -1
  181. package/dist/findPrefix.d.ts +0 -3
  182. package/dist/findPrefix.js +0 -20
  183. package/dist/findPrefix.js.map +0 -1
  184. package/dist/functions/workerPool.d.ts +0 -0
  185. package/dist/functions/workerPool.js +0 -5
  186. package/dist/functions/workerPool.js.map +0 -1
  187. package/dist/getFromConfig.d.ts +0 -3
  188. package/dist/getFromConfig.js +0 -50
  189. package/dist/getFromConfig.js.map +0 -1
  190. package/dist/handlers/authorize.d.ts +0 -5
  191. package/dist/handlers/authorize.js +0 -196
  192. package/dist/handlers/authorize.js.map +0 -1
  193. package/dist/handlers/bulkUpdate/index.d.ts +0 -5
  194. package/dist/handlers/bulkUpdate/index.js +0 -26
  195. package/dist/handlers/bulkUpdate/index.js.map +0 -1
  196. package/dist/handlers/configuration/index.d.ts +0 -10
  197. package/dist/handlers/configuration/index.js +0 -74
  198. package/dist/handlers/configuration/index.js.map +0 -1
  199. package/dist/handlers/configuration/observable/index.d.ts +0 -46
  200. package/dist/handlers/configuration/observable/index.js +0 -277
  201. package/dist/handlers/configuration/observable/index.js.map +0 -1
  202. package/dist/handlers/configure/index.d.ts +0 -5
  203. package/dist/handlers/configure/index.js +0 -44
  204. package/dist/handlers/configure/index.js.map +0 -1
  205. package/dist/handlers/copy/index.d.ts +0 -8
  206. package/dist/handlers/copy/index.js +0 -135
  207. package/dist/handlers/copy/index.js.map +0 -1
  208. package/dist/handlers/delete/index.d.ts +0 -5
  209. package/dist/handlers/delete/index.js +0 -34
  210. package/dist/handlers/delete/index.js.map +0 -1
  211. package/dist/handlers/digest/index.d.ts +0 -5
  212. package/dist/handlers/digest/index.js +0 -23
  213. package/dist/handlers/digest/index.js.map +0 -1
  214. package/dist/handlers/functions/call.d.ts +0 -6
  215. package/dist/handlers/functions/call.js +0 -54
  216. package/dist/handlers/functions/call.js.map +0 -1
  217. package/dist/handlers/functions/observable/Observable.d.ts +0 -49
  218. package/dist/handlers/functions/observable/Observable.js +0 -290
  219. package/dist/handlers/functions/observable/Observable.js.map +0 -1
  220. package/dist/handlers/functions/observable/SharedObservable.d.ts +0 -45
  221. package/dist/handlers/functions/observable/SharedObservable.js +0 -291
  222. package/dist/handlers/functions/observable/SharedObservable.js.map +0 -1
  223. package/dist/handlers/functions/observable/index.d.ts +0 -14
  224. package/dist/handlers/functions/observable/index.js +0 -130
  225. package/dist/handlers/functions/observable/index.js.map +0 -1
  226. package/dist/handlers/get/index.d.ts +0 -5
  227. package/dist/handlers/get/index.js +0 -23
  228. package/dist/handlers/get/index.js.map +0 -1
  229. package/dist/handlers/getConfig/index.d.ts +0 -5
  230. package/dist/handlers/getConfig/index.js +0 -38
  231. package/dist/handlers/getConfig/index.js.map +0 -1
  232. package/dist/handlers/handleRequests.d.ts +0 -5
  233. package/dist/handlers/handleRequests.js +0 -78
  234. package/dist/handlers/handleRequests.js.map +0 -1
  235. package/dist/handlers/index.d.ts +0 -4
  236. package/dist/handlers/index.js +0 -49
  237. package/dist/handlers/index.js.map +0 -1
  238. package/dist/handlers/messageParser.d.ts +0 -5
  239. package/dist/handlers/messageParser.js +0 -122
  240. package/dist/handlers/messageParser.js.map +0 -1
  241. package/dist/handlers/removeField/index.d.ts +0 -5
  242. package/dist/handlers/removeField/index.js +0 -42
  243. package/dist/handlers/removeField/index.js.map +0 -1
  244. package/dist/handlers/removeType/index.d.ts +0 -5
  245. package/dist/handlers/removeType/index.js +0 -30
  246. package/dist/handlers/removeType/index.js.map +0 -1
  247. package/dist/handlers/rest/file/DataStream.js +0 -17
  248. package/dist/handlers/rest/file/DataStream.js.map +0 -1
  249. package/dist/handlers/rest/file/formStream.d.ts +0 -4
  250. package/dist/handlers/rest/file/formStream.js +0 -188
  251. package/dist/handlers/rest/file/formStream.js.map +0 -1
  252. package/dist/handlers/rest/file/getExtenstion.d.ts +0 -2
  253. package/dist/handlers/rest/file/getExtenstion.js +0 -22
  254. package/dist/handlers/rest/file/getExtenstion.js.map +0 -1
  255. package/dist/handlers/rest/file/index.d.ts +0 -4
  256. package/dist/handlers/rest/file/index.js +0 -53
  257. package/dist/handlers/rest/file/index.js.map +0 -1
  258. package/dist/handlers/rest/file/storeFile.d.ts +0 -6
  259. package/dist/handlers/rest/file/storeFile.js +0 -44
  260. package/dist/handlers/rest/file/storeFile.js.map +0 -1
  261. package/dist/handlers/rest/file/stream.d.ts +0 -5
  262. package/dist/handlers/rest/file/stream.js +0 -105
  263. package/dist/handlers/rest/file/stream.js.map +0 -1
  264. package/dist/handlers/rest/file/types.d.ts +0 -9
  265. package/dist/handlers/rest/file/types.js.map +0 -1
  266. package/dist/handlers/rest/getReqMessage.d.ts +0 -3
  267. package/dist/handlers/rest/getReqMessage.js +0 -92
  268. package/dist/handlers/rest/getReqMessage.js.map +0 -1
  269. package/dist/handlers/rest/index.d.ts +0 -4
  270. package/dist/handlers/rest/index.js +0 -121
  271. package/dist/handlers/rest/index.js.map +0 -1
  272. package/dist/handlers/rest/invalidReq.d.ts +0 -4
  273. package/dist/handlers/rest/invalidReq.js +0 -20
  274. package/dist/handlers/rest/invalidReq.js.map +0 -1
  275. package/dist/handlers/rest/parseResponse.d.ts +0 -6
  276. package/dist/handlers/rest/parseResponse.js +0 -230
  277. package/dist/handlers/rest/parseResponse.js.map +0 -1
  278. package/dist/handlers/rest/playground/index.d.ts +0 -5
  279. package/dist/handlers/rest/playground/index.js +0 -308
  280. package/dist/handlers/rest/playground/index.js.map +0 -1
  281. package/dist/handlers/rest/readBody.d.ts +0 -3
  282. package/dist/handlers/rest/readBody.js +0 -45
  283. package/dist/handlers/rest/readBody.js.map +0 -1
  284. package/dist/handlers/set/index.d.ts +0 -5
  285. package/dist/handlers/set/index.js +0 -20
  286. package/dist/handlers/set/index.js.map +0 -1
  287. package/dist/handlers/subscription/index.d.ts +0 -32
  288. package/dist/handlers/subscription/index.js +0 -223
  289. package/dist/handlers/subscription/index.js.map +0 -1
  290. package/dist/handlers/token.d.ts +0 -5
  291. package/dist/handlers/token.js +0 -122
  292. package/dist/handlers/token.js.map +0 -1
  293. package/dist/handlers/track/index.d.ts +0 -7
  294. package/dist/handlers/track/index.js +0 -102
  295. package/dist/handlers/track/index.js.map +0 -1
  296. package/dist/handlers/userAuth/index.d.ts +0 -5
  297. package/dist/handlers/userAuth/index.js +0 -78
  298. package/dist/handlers/userAuth/index.js.map +0 -1
  299. package/dist/network/http/authorize.d.ts +0 -3
  300. package/dist/network/http/authorize.js +0 -28
  301. package/dist/network/http/authorize.js.map +0 -1
  302. package/dist/network/http/compress.d.ts +0 -6
  303. package/dist/network/http/compress.js.map +0 -1
  304. package/dist/network/http/end.d.ts +0 -4
  305. package/dist/network/http/end.js +0 -19
  306. package/dist/network/http/end.js.map +0 -1
  307. package/dist/network/http/function.d.ts +0 -3
  308. package/dist/network/http/function.js.map +0 -1
  309. package/dist/network/http/get.d.ts +0 -3
  310. package/dist/network/http/get.js +0 -129
  311. package/dist/network/http/get.js.map +0 -1
  312. package/dist/network/http/index.js +0 -122
  313. package/dist/network/http/index.js.map +0 -1
  314. package/dist/network/http/readBody.d.ts +0 -3
  315. package/dist/network/http/readBody.js.map +0 -1
  316. package/dist/network/http/send.d.ts +0 -5
  317. package/dist/network/http/send.js +0 -60
  318. package/dist/network/http/send.js.map +0 -1
  319. package/dist/network/http/streamFunction/DataStream.d.ts +0 -7
  320. package/dist/network/http/streamFunction/DataStream.js.map +0 -1
  321. package/dist/network/http/streamFunction/getExtension.js.map +0 -1
  322. package/dist/network/http/streamFunction/index.d.ts +0 -3
  323. package/dist/network/http/streamFunction/index.js +0 -81
  324. package/dist/network/http/streamFunction/index.js.map +0 -1
  325. package/dist/network/http/streamFunction/multipartStream.d.ts +0 -12
  326. package/dist/network/http/streamFunction/multipartStream.js.map +0 -1
  327. package/dist/network/http/streamFunction/stream.js.map +0 -1
  328. package/dist/network/index.d.ts +0 -4
  329. package/dist/network/index.js.map +0 -1
  330. package/dist/network/message/auth.d.ts +0 -4
  331. package/dist/network/message/auth.js +0 -32
  332. package/dist/network/message/auth.js.map +0 -1
  333. package/dist/network/message/function.d.ts +0 -3
  334. package/dist/network/message/function.js +0 -67
  335. package/dist/network/message/function.js.map +0 -1
  336. package/dist/network/message/get.d.ts +0 -3
  337. package/dist/network/message/get.js +0 -109
  338. package/dist/network/message/get.js.map +0 -1
  339. package/dist/network/message/index.d.ts +0 -3
  340. package/dist/network/message/index.js.map +0 -1
  341. package/dist/network/message/observable.d.ts +0 -5
  342. package/dist/network/message/observable.js +0 -103
  343. package/dist/network/message/observable.js.map +0 -1
  344. package/dist/network/message/send.d.ts +0 -4
  345. package/dist/network/message/send.js +0 -11
  346. package/dist/network/message/send.js.map +0 -1
  347. package/dist/network/upgrade.d.ts +0 -4
  348. package/dist/network/upgrade.js.map +0 -1
  349. package/dist/network/worker/get.d.ts +0 -0
  350. package/dist/network/worker/get.js +0 -122
  351. package/dist/network/worker/get.js.map +0 -1
  352. package/dist/network/worker/observable.d.ts +0 -0
  353. package/dist/network/worker/observable.js +0 -120
  354. package/dist/network/worker/observable.js.map +0 -1
  355. package/dist/openListener.d.ts +0 -4
  356. package/dist/openListener.js +0 -13
  357. package/dist/openListener.js.map +0 -1
  358. package/dist/secrets.d.ts +0 -9
  359. package/dist/secrets.js +0 -150
  360. package/dist/secrets.js.map +0 -1
  361. package/dist/security/index.d.ts +0 -2
  362. package/dist/security/index.js +0 -57
  363. package/dist/security/index.js.map +0 -1
  364. package/dist/types.d.ts +0 -129
  365. package/dist/types.js +0 -17
  366. package/dist/types.js.map +0 -1
  367. package/dist/upgradeListener.d.ts +0 -4
  368. package/dist/upgradeListener.js +0 -47
  369. package/dist/upgradeListener.js.map +0 -1
  370. package/dist/worker/authorize.d.ts +0 -5
  371. package/dist/worker/authorize.js +0 -15
  372. package/dist/worker/authorize.js.map +0 -1
  373. package/dist/worker/fnMap.d.ts +0 -2
  374. package/dist/worker/fnMap.js +0 -5
  375. package/dist/worker/fnMap.js.map +0 -1
  376. package/dist/worker/functions.d.ts +0 -3
  377. package/dist/worker/functions.js +0 -8
  378. package/dist/worker/functions.js.map +0 -1
  379. package/dist/worker/http/function.d.ts +0 -4
  380. package/dist/worker/http/function.js +0 -75
  381. package/dist/worker/http/function.js.map +0 -1
  382. package/dist/worker/index.d.ts +0 -1
  383. package/dist/worker/index.js +0 -101
  384. package/dist/worker/index.js.map +0 -1
  385. package/dist/worker/observable.d.ts +0 -15
  386. package/dist/worker/observable.js +0 -110
  387. package/dist/worker/observable.js.map +0 -1
  388. package/dist/worker/ws/function.d.ts +0 -3
  389. package/dist/worker/ws/function.js +0 -42
  390. package/dist/worker/ws/function.js.map +0 -1
  391. package/dist/workers/index.d.ts +0 -0
  392. package/dist/workers/index.js +0 -20
  393. package/dist/workers/index.js.map +0 -1
  394. package/dist/workers/workerCode.d.ts +0 -12
  395. package/dist/workers/workerCode.js +0 -46
  396. package/dist/workers/workerCode.js.map +0 -1
@@ -2,46 +2,46 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.httpFunction = void 0;
4
4
  const functions_1 = require("../../functions");
5
- const send_1 = require("./send");
5
+ const sendHttpResponse_1 = require("../../sendHttpResponse");
6
6
  const error_1 = require("../../error");
7
- const httpFunction = (method, route, client, server, payload) => {
8
- if (!client.res) {
7
+ const sendError_1 = require("../../sendError");
8
+ const httpFunction = (route, ctx, server, payload) => {
9
+ if (!ctx.session) {
9
10
  return;
10
11
  }
11
12
  const name = route.name;
12
13
  server.functions
13
14
  .install(name)
14
15
  .then((spec) => {
15
- if (!client.res) {
16
+ if (!ctx.session) {
16
17
  return;
17
18
  }
18
19
  if (spec && !(0, functions_1.isObservableFunctionSpec)(spec)) {
19
- // TODO: way too much copy but this is tmp solution
20
- server.functions
21
- .runFunction(method === 'post' ? 3 : 4, spec, client.context, payload)
20
+ spec
21
+ .function(payload, ctx)
22
22
  .then(async (result) => {
23
- if (!client.res) {
23
+ if (!ctx.session) {
24
24
  return;
25
25
  }
26
26
  if (spec.customHttpResponse) {
27
- if (await spec.customHttpResponse(result, payload, client)) {
27
+ if (await spec.customHttpResponse(result, payload, ctx)) {
28
28
  return;
29
29
  }
30
- (0, send_1.sendHttpResponse)(client, result);
30
+ (0, sendHttpResponse_1.sendHttpResponse)(ctx, result);
31
31
  }
32
32
  else {
33
- (0, send_1.sendHttpResponse)(client, result);
33
+ (0, sendHttpResponse_1.sendHttpResponse)(ctx, result);
34
34
  }
35
35
  })
36
36
  .catch((err) => {
37
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionError, {
37
+ (0, sendError_1.sendError)(server, ctx, err.code, {
38
38
  err,
39
39
  route,
40
40
  });
41
41
  });
42
42
  }
43
43
  })
44
- .catch(() => (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route));
44
+ .catch(() => (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route));
45
45
  };
46
46
  exports.httpFunction = httpFunction;
47
47
  //# sourceMappingURL=function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/incoming/http/function.ts"],"names":[],"mappings":";;;AACA,+CAA8E;AAE9E,6DAAyD;AACzD,uCAA4C;AAC5C,+CAA2C;AAEpC,MAAM,YAAY,GAAG,CAC1B,KAAyB,EACzB,GAAyB,EACzB,MAAmB,EACnB,OAAoB,EACd,EAAE;IAC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, Context } from '../../context';
3
+ import { BasedFunctionRoute } from '../../functions';
4
+ export declare const httpGet: (route: BasedFunctionRoute, payload: any, ctx: Context<HttpSession>, server: BasedServer, checksum: number) => void;
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.httpGet = void 0;
7
+ const functions_1 = require("../../functions");
8
+ const sendHttpResponse_1 = require("../../sendHttpResponse");
9
+ const compress_1 = require("../../compress");
10
+ const observable_1 = require("../../observable");
11
+ const node_zlib_1 = __importDefault(require("node:zlib"));
12
+ const utils_1 = require("@saulx/utils");
13
+ const error_1 = require("../../error");
14
+ const sendError_1 = require("../../sendError");
15
+ const node_util_1 = require("node:util");
16
+ const inflate = (0, node_util_1.promisify)(node_zlib_1.default.inflate);
17
+ const sendCacheSwapEncoding = async (server, route, ctx, buffer, checksum) => {
18
+ try {
19
+ const inflated = await inflate(buffer.slice(20));
20
+ const { payload, encoding } = await (0, compress_1.compress)(inflated, ctx.session.headers.encoding);
21
+ if (!ctx.session.res) {
22
+ return;
23
+ }
24
+ ctx.session.res.cork(() => {
25
+ ctx.session.res.writeStatus('200 OK');
26
+ if (encoding) {
27
+ ctx.session.res.writeHeader('Content-Encoding', encoding);
28
+ }
29
+ ctx.session.res.writeHeader('ETag', String(checksum));
30
+ (0, sendHttpResponse_1.end)(ctx, payload);
31
+ });
32
+ }
33
+ catch (err) {
34
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.UnsupportedContentEncoding, route);
35
+ }
36
+ };
37
+ const sendCache = (ctx, buffer, checksum, isDeflate) => {
38
+ ctx.session.res.cork(() => {
39
+ ctx.session.res.writeStatus('200 OK');
40
+ ctx.session.res.writeHeader('ETag', String(checksum));
41
+ if (isDeflate) {
42
+ ctx.session.res.writeHeader('Content-Encoding', 'deflate');
43
+ }
44
+ (0, sendHttpResponse_1.end)(ctx, buffer.slice(20));
45
+ });
46
+ };
47
+ const sendNotModified = (ctx) => {
48
+ ctx.session.res.cork(() => {
49
+ ctx.session.res.writeStatus('304 Not Modified');
50
+ (0, sendHttpResponse_1.end)(ctx);
51
+ });
52
+ };
53
+ const sendGetResponse = (route, server, id, obs, checksum, ctx) => {
54
+ if (!ctx.session) {
55
+ return;
56
+ }
57
+ const encoding = ctx.session.headers.encoding;
58
+ if (checksum === 0 || checksum !== obs.checksum) {
59
+ if (!obs.cache) {
60
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.NoOservableCacheAvailable, {
61
+ observableId: id,
62
+ route: { name: obs.name },
63
+ });
64
+ }
65
+ else if (obs.isDeflate) {
66
+ if (typeof encoding === 'string' && encoding.includes('deflate')) {
67
+ sendCache(ctx, obs.cache, obs.checksum, true);
68
+ }
69
+ else {
70
+ sendCacheSwapEncoding(server, route, ctx, obs.cache, obs.checksum);
71
+ }
72
+ }
73
+ else {
74
+ sendCache(ctx, obs.cache, obs.checksum, false);
75
+ }
76
+ }
77
+ else {
78
+ sendNotModified(ctx);
79
+ }
80
+ (0, observable_1.destroyObs)(server, id);
81
+ };
82
+ const getFromExisting = (server, id, ctx, route, checksum) => {
83
+ const obs = (0, observable_1.getObs)(server, id);
84
+ if (obs.error) {
85
+ (0, observable_1.sendObsGetError)(server, ctx, obs.id, obs.name, obs.error);
86
+ return;
87
+ }
88
+ if (obs.cache) {
89
+ sendGetResponse(route, server, id, obs, checksum, ctx);
90
+ return;
91
+ }
92
+ (0, observable_1.subscribeNext)(obs, (err) => {
93
+ if (!ctx.session) {
94
+ return;
95
+ }
96
+ if (err) {
97
+ (0, observable_1.sendObsGetError)(server, ctx, obs.id, obs.name, err);
98
+ }
99
+ else {
100
+ sendGetResponse(route, server, id, obs, checksum, ctx);
101
+ }
102
+ });
103
+ };
104
+ const httpGet = (route, payload, ctx, server, checksum) => {
105
+ if (!ctx.session) {
106
+ return;
107
+ }
108
+ if (payload === undefined && 'query' in ctx.session) {
109
+ try {
110
+ payload = (0, utils_1.parseQuery)(decodeURIComponent(ctx.session.query));
111
+ }
112
+ catch (err) { }
113
+ }
114
+ const name = route.name;
115
+ const id = (0, observable_1.genObservableId)(name, payload);
116
+ if ((0, observable_1.hasObs)(server, id)) {
117
+ getFromExisting(server, id, ctx, route, checksum);
118
+ return;
119
+ }
120
+ server.functions
121
+ .install(name)
122
+ .then((spec) => {
123
+ if (!ctx.session) {
124
+ return;
125
+ }
126
+ if (!spec) {
127
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
128
+ return;
129
+ }
130
+ if (!(0, functions_1.isObservableFunctionSpec)(spec)) {
131
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionIsNotObservable, route);
132
+ return;
133
+ }
134
+ if ((0, observable_1.hasObs)(server, id)) {
135
+ getFromExisting(server, id, ctx, route, checksum);
136
+ return;
137
+ }
138
+ const obs = (0, observable_1.createObs)(server, name, id, payload);
139
+ (0, observable_1.subscribeNext)(obs, (err) => {
140
+ if (err) {
141
+ (0, observable_1.sendObsGetError)(server, ctx, obs.id, obs.name, err);
142
+ }
143
+ else {
144
+ sendGetResponse(route, server, id, obs, checksum, ctx);
145
+ }
146
+ });
147
+ })
148
+ .catch((err) => {
149
+ // TODO: error type
150
+ console.error('Internal: Unxpected error in observable', err);
151
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.FunctionNotFound, route);
152
+ });
153
+ };
154
+ exports.httpGet = httpGet;
155
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/incoming/http/get.ts"],"names":[],"mappings":";;;;;;AAEA,+CAA8E;AAC9E,6DAA4C;AAC5C,6CAAyC;AACzC,iDASyB;AACzB,0DAA4B;AAC5B,wCAAyC;AACzC,uCAA4C;AAC5C,+CAA2C;AAC3C,yCAAqC;AAErC,MAAM,OAAO,GAAG,I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;QAED,IAAI,CAAC,IAAA,oCAAwB,EAAC,IAAI,CAAC,EAAE;YACnC,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,uBAAuB,EAAE,KAAK,CAAC,CAAA;YACrE,OAAM;SACP;QAED,IAAI,IAAA,mBAAM,EAAC,MAAM,EAAE,EAAE,CAAC,EAAE;YACtB,eAAe,CAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAA;YACjD,OAAM;SACP;QAED,MAAM,GAAG,GAAG,IAAA,sBAAS,EAAC,MAAM,EAAE,IAAI,EAAE,EAAE,EAAE,OAAO,CAAC,CAAA;QAChD,IAAA,0BAAa,EAAC,GAAG,EAAE,CAAC,GAAG,EAAE,EAAE;YACzB,IAAI,GAAG,EAAE;gBACP,IAAA,4BAAe,EAAC,MAAM,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,EAAE,GAAG,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;aACpD;iBAAM;gBACL,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAA;aACvD;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,mBAAmB;QACnB,OAAO,CAAC,KAAK,CAAC,yCAAyC,EAAE,GAAG,CAAC,CAAA;QAC7D,IAAA,qBAAS,EAAC,MAAM,EAAE,GAAG,EAAE,sBAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA;IAChE,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AA5DY,QAAA,OAAO,WA4DnB"}
File without changes
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.httpHandler = void 0;
7
+ const function_1 = require("./function");
8
+ const streamFunction_1 = require("./streamFunction");
9
+ const get_1 = require("./get");
10
+ const readBody_1 = require("./readBody");
11
+ const authorize_1 = require("./authorize");
12
+ const error_1 = require("../../error");
13
+ const sendError_1 = require("../../sendError");
14
+ const security_1 = require("../../security");
15
+ const auth_1 = require("../../auth");
16
+ const parseQuery_1 = __importDefault(require("./parseQuery"));
17
+ const ip_1 = require("../../ip");
18
+ let clientId = 0;
19
+ const handleRequest = (server, method, ctx, route, ready) => {
20
+ if (method === 'post') {
21
+ (0, readBody_1.readBody)(server, ctx, ready, route);
22
+ }
23
+ else {
24
+ ready((0, parseQuery_1.default)(ctx));
25
+ }
26
+ };
27
+ const httpHandler = (server, req, res) => {
28
+ res.onAborted(() => {
29
+ ctx.session.res = null;
30
+ ctx.session.req = null;
31
+ ctx.session = null;
32
+ });
33
+ const ip = (0, ip_1.getIp)(res);
34
+ if ((0, security_1.blockIncomingRequest)(server, ip, res, req, server.rateLimit.http, 1)) {
35
+ return;
36
+ }
37
+ const url = req.getUrl();
38
+ const path = url.split('/');
39
+ const route = server.functions.route(path[1], url);
40
+ const method = req.getMethod();
41
+ if (route === false) {
42
+ (0, sendError_1.sendError)(server, {
43
+ session: {
44
+ ua: req.getHeader('user-agent'),
45
+ ip,
46
+ method,
47
+ id: ++clientId,
48
+ headers: {},
49
+ res,
50
+ req,
51
+ },
52
+ }, error_1.BasedErrorCode.FunctionNotFound, path[1] ? { name: path[1] } : { name: '', path: url });
53
+ return;
54
+ }
55
+ const ctx = {
56
+ session: {
57
+ res,
58
+ req,
59
+ method,
60
+ ua: req.getHeader('user-agent'),
61
+ ip,
62
+ id: ++clientId,
63
+ authState: (0, auth_1.parseAuthState)(req.getHeader('authorization')),
64
+ headers: {
65
+ 'content-type': req.getHeader('content-type'),
66
+ 'content-encoding': req.getHeader('content-encoding'),
67
+ encoding: req.getHeader('accept-encoding'),
68
+ },
69
+ },
70
+ };
71
+ if ((0, security_1.rateLimitRequest)(server, ctx, route.rateLimitTokens, server.rateLimit.http)) {
72
+ return;
73
+ }
74
+ const query = req.getQuery();
75
+ if (query) {
76
+ ctx.session.query = query;
77
+ }
78
+ const len = req.getHeader('content-length');
79
+ const lenConverted = len ? Number(len) : undefined;
80
+ if (lenConverted !== undefined && !isNaN(lenConverted)) {
81
+ ctx.session.headers['content-length'] = lenConverted;
82
+ }
83
+ if (method === 'post' &&
84
+ ctx.session.headers['content-length'] === undefined) {
85
+ // zero allowed, but not for streams
86
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.LengthRequired, route);
87
+ return;
88
+ }
89
+ if (route.headers) {
90
+ for (const header of route.headers) {
91
+ const v = req.getHeader(header);
92
+ if (v) {
93
+ ctx.session.headers[header] = v;
94
+ }
95
+ }
96
+ }
97
+ if (route.observable === true) {
98
+ if (route.stream) {
99
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.CannotStreamToObservableFunction, route);
100
+ return;
101
+ }
102
+ const checksumRaw = req.getHeader('if-none-match');
103
+ const checksumNum = Number(checksumRaw);
104
+ const checksum = !isNaN(checksumNum) ? checksumNum : 0;
105
+ handleRequest(server, method, ctx, route, (payload) => {
106
+ (0, authorize_1.authorizeRequest)(server, ctx, payload, route, () => {
107
+ (0, get_1.httpGet)(route, payload, ctx, server, checksum);
108
+ });
109
+ });
110
+ }
111
+ else {
112
+ if (route.stream === true) {
113
+ if (method !== 'post') {
114
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.MethodNotAllowed, route);
115
+ return;
116
+ }
117
+ if (ctx.session.headers['content-length'] === 0) {
118
+ // zero is also not allowed for streams
119
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.LengthRequired, route);
120
+ return;
121
+ }
122
+ (0, streamFunction_1.httpStreamFunction)(server, ctx, (0, parseQuery_1.default)(ctx), route);
123
+ }
124
+ else {
125
+ handleRequest(server, method, ctx, route, (payload) => {
126
+ (0, authorize_1.authorizeRequest)(server, ctx, payload, route, () => {
127
+ (0, function_1.httpFunction)(route, ctx, server, payload);
128
+ });
129
+ });
130
+ }
131
+ }
132
+ };
133
+ exports.httpHandler = httpHandler;
134
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/incoming/http/index.ts"],"names":[],"mappings":";;;;;;AAGA,yCAAyC;AACzC,qDAAqD;AAErD,+BAA+B;AAC/B,yCAAqC;AACrC,2CAA8C;AAC9C,uCAA4C;AAC5C,+CAA2C;AAC3C,6CAAuE;AACvE,qCAA2C;AAC3C,8DAAqC;AACrC,iCAAgC;AAEhC,IAAI,QAAQ,GAAG,CAAC,CAAA;AAEhB,MAAM,aAAa,GAAG,CACpB,MAAmB,EACnB,MAAc,EACd,GAAyB,EACzB,KAAyB,EACzB,KAA8B,EAC9B,EAAE;IACF,IAAI,MAAM,KAAK,MAAM,EAAE;QACrB,IAAA,mBAAQ,EAAC,MAAM,EAAE,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,CAAA;KACpC;SAAM;QACL,KAAK,CAAC,IAAA,oBAAU,EAAC,GAAG,CAAC,CAAC,CAAA;KACvB;AACH,CAAC,CAAA;AAEM,MAAM,WAAW,GAAG,CACzB,MAAmB,EACnB,GAAoB,EACpB,GAAqB,EACrB,EAAE;IACF,GAAG,CAAC,SAAS,CAAC,GAAG,EAAE;QACjB,GAAG,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAA;QACtB,GAAG,CAAC,OAAO,CAAC,GAAG,GAAG,IAAI,CAAA;QACtB,GAAG,CAAC,OAAO,GAAG,IAAI,CAAA;IACpB,CAAC,CAAC,CAAA;IAEF,MAAM,EAAE,GAAG,IAAA,UAAK,EAAC,GAAG,CAAC,CAAA;IAErB,IAAI,IAAA,+BAAoB,EAAC,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC,EAAE;QAC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EAAE;gBACpD,IAAA,4BAAgB,EAAC,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE;oBACjD,IAAA,uBAAY,EAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;gBAC3C,CAAC,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACH;KACF;AACH,CAAC,CAAA;AArIY,QAAA,WAAW,eAqIvB"}
@@ -0,0 +1,4 @@
1
+ import { Context, HttpSession } from '../../context';
2
+ import { parseQuery } from '@saulx/utils';
3
+ declare const _default: (ctx: Context<HttpSession>) => ReturnType<typeof parseQuery>;
4
+ export default _default;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@saulx/utils");
4
+ const auth_1 = require("../../auth");
5
+ exports.default = (ctx) => {
6
+ if (!('query' in ctx.session)) {
7
+ return;
8
+ }
9
+ if ('parsedQuery' in ctx.session) {
10
+ return ctx.session.parsedQuery;
11
+ }
12
+ try {
13
+ ctx.session.parsedQuery = (0, utils_1.parseQuery)(ctx.session.query);
14
+ if (!ctx.session.authState &&
15
+ ctx.session.parsedQuery &&
16
+ 'token' in ctx.session.parsedQuery) {
17
+ ctx.session.authState = (0, auth_1.parseAuthState)(ctx.session.parsedQuery.token);
18
+ }
19
+ return ctx.session.parsedQuery;
20
+ }
21
+ catch (err) {
22
+ ctx.session.parsedQuery = undefined;
23
+ }
24
+ };
25
+ //# sourceMappingURL=parseQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseQuery.js","sourceRoot":"","sources":["../../../src/incoming/http/parseQuery.ts"],"names":[],"mappings":";;AACA,wCAAyC;AACzC,qCAA2C;AAE3C,kBAAe,CAAC,GAAyB,EAAiC,EAAE;IAC1E,IAAI,CAAC,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,EAAE;QAC7B,OAAM;KACP;IACD,IAAI,aAAa,IAAI,GAAG,CAAC,OAAO,EAAE;QAChC,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,CAAA;KAC/B;IACD,IAAI;QACF,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,IAAA,kBAAU,EAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;QAEvD,IACE,CAAC,GAAG,CAAC,OAAO,CAAC,SAAS;YACtB,GAAG,CAAC,OAAO,CAAC,WAAW;YACvB,OAAO,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,EAClC;YACA,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,IAAA,qBAAc,EAAC,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;SACtE;QAED,OAAO,GAAG,CAAC,OAAO,CAAC,WAAW,CAAA;KAC/B;IAAC,OAAO,GAAG,EAAE;QACZ,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,SAAS,CAAA;KACpC;AACH,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { HttpSession, Context } from '../../context';
2
+ import { BasedFunctionRoute } from '../../functions';
3
+ import { BasedServer } from '../../server';
4
+ export declare const readBody: (server: BasedServer, ctx: Context<HttpSession>, onData: (data: any | void) => void, route: BasedFunctionRoute) => void;
@@ -5,23 +5,24 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.readBody = void 0;
7
7
  const node_zlib_1 = __importDefault(require("node:zlib"));
8
- const send_1 = require("./send");
9
8
  const error_1 = require("../../error");
9
+ const sendError_1 = require("../../sendError");
10
+ // TODO: might be good to use worker stream as well for this
10
11
  const MAX_CHUNK_SIZE = 1024 * 1024;
11
12
  const UNCOMPRESS_OPTS = {
12
13
  // can be endless scince we limit by incoming
13
14
  chunkSize: 1024 * 1024 * 1000,
14
15
  };
15
- const readBody = (server, client, onData, route) => {
16
- if (!client.res) {
16
+ const readBody = (server, ctx, onData, route) => {
17
+ if (!ctx.session) {
17
18
  return;
18
19
  }
19
- const contentLen = client.context.headers['content-length'];
20
+ const contentLen = ctx.session.headers['content-length'];
20
21
  if (contentLen > route.maxPayloadSize) {
21
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.PayloadTooLarge, route);
22
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
22
23
  return;
23
24
  }
24
- const contentEncoding = client.context.headers['content-encoding'];
25
+ const contentEncoding = ctx.session.headers['content-encoding'];
25
26
  let size = 0;
26
27
  if (contentEncoding) {
27
28
  let uncompressStream;
@@ -35,16 +36,15 @@ const readBody = (server, client, onData, route) => {
35
36
  uncompressStream = node_zlib_1.default.createBrotliDecompress(UNCOMPRESS_OPTS);
36
37
  }
37
38
  if (uncompressStream) {
38
- client.res.onData((c, isLast) => {
39
+ ctx.session.res.onData((c, isLast) => {
39
40
  size += c.byteLength;
40
41
  if (size > route.maxPayloadSize) {
41
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.PayloadTooLarge, route);
42
- // sendHttpError(client, 'Payload Too Large', 413)
42
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
43
43
  uncompressStream.destroy();
44
44
  return;
45
45
  }
46
46
  if (c.byteLength > MAX_CHUNK_SIZE) {
47
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.ChunkTooLarge, route);
47
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.ChunkTooLarge, route);
48
48
  uncompressStream.destroy();
49
49
  return;
50
50
  }
@@ -58,51 +58,46 @@ const readBody = (server, client, onData, route) => {
58
58
  }
59
59
  }
60
60
  });
61
- // TODO: NEED TO READ CONTENT LEN OF UNCOMPRESSED....
62
- const data = new SharedArrayBuffer(contentLen);
63
- const buf = new Uint8Array(data);
64
- // let index = 0
61
+ // unfortunately need to make a copy of the data and decompress in the main thread
62
+ const chunks = [];
63
+ // will prob not work because shared data in uws
64
+ let len = 0;
65
65
  uncompressStream.on('data', (c) => {
66
- console.info('bytes written???', uncompressStream.bytesWritten, c);
67
- // FIX LATER
68
- // const len = c.byteLength
69
- // for (let i = 0; i < len; i++) {
70
- // console.log(c[i])
71
- // worng ofc..
72
- // maybe unpack in worker? - will not work like this...
73
- // Atomics.store(buf, index, c[i])
74
- // }
75
- // index += len
66
+ chunks.push(c);
67
+ len += c.byteLength;
76
68
  });
69
+ let i = 0;
77
70
  uncompressStream.on('end', () => {
78
71
  uncompressStream.destroy();
79
- // parseData(server, client, contentType, data, false, route)
72
+ const buf = new Uint8Array(len);
73
+ for (const c of chunks) {
74
+ buf.set(c, i);
75
+ i += c.byteLength;
76
+ }
80
77
  onData(buf);
81
78
  });
82
79
  }
83
80
  else {
84
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.InvalidPayload, route);
81
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.InvalidPayload, route);
85
82
  }
86
83
  }
87
84
  else {
88
- const data = new SharedArrayBuffer(contentLen);
89
- const buf = new Uint8Array(data);
85
+ const buf = new Uint8Array(contentLen);
90
86
  let index = 0;
91
- client.res.onData((c, isLast) => {
87
+ ctx.session.res.onData((c, isLast) => {
92
88
  const len = c.byteLength;
93
89
  size += len;
94
90
  if (size > route.maxPayloadSize) {
95
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.PayloadTooLarge, route);
91
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.PayloadTooLarge, route);
96
92
  return;
97
93
  }
98
94
  if (c.byteLength > MAX_CHUNK_SIZE) {
99
- (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.ChunkTooLarge, route);
95
+ (0, sendError_1.sendError)(server, ctx, error_1.BasedErrorCode.ChunkTooLarge, route);
100
96
  return;
101
97
  }
102
98
  buf.set(new Uint8Array(c), index);
103
99
  index += len;
104
100
  if (isLast) {
105
- console.info('shared buf time', buf);
106
101
  onData(buf);
107
102
  }
108
103
  });
@@ -0,0 +1 @@
1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AQ,YAgGpB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DataStream.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/DataStream.ts"],"names":[],"mappings":";;;AAAA,mCAA+B;AAE/B,qEAAqE;AAErE,2BAA2B;AAC3B,MAAa,UAAW,SAAQ,eAAM;IACpC,KAAK,KAAI,CAAC;IAEV,yBAAyB;IACzB,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,QAAQ;QAC9B,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAA;QACvC,QAAQ,EAAE,CAAA;IACZ,CAAC;IAED,MAAM;QACJ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IACjB,CAAC;CACF;AAZD,gCAYC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getExtension.js","sourceRoot":"","sources":["../../../../src/incoming/http/streamFunction/getExtension.ts"],"names":[],"mappings":";;;;;AAAA,4DAAkC;AAElC,kBAAe,CAAC,QAAgB,EAAE,EAAE;IAClC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACxC,IAAI,IAAI,KAAK,MAAM,EAAE;QACnB,OAAO,MAAM,CAAA;KACd;SAAM,IAAI,IAAI,KAAK,KAAK,EAAE;QACzB,OAAO,KAAK,CAAA;KACb;SAAM,IAAI,IAAI,KAAK,OAAO,EAAE;QAC3B,OAAO,OAAO,CAAA;KACf;SAAM;QACL,MAAM,CAAC,GAAG,oBAAS,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;QACvC,IAAI,CAAC,KAAK,UAAU,EAAE;YACpB,OAAO,IAAI,CAAA;SACZ;QACD,IAAI,CAAC,KAAK,IAAI,EAAE;YACd,OAAO,KAAK,CAAA;SACb;QACD,OAAO,CAAC,CAAA;KACT;AACH,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import { BasedServer } from '../../../server';
2
+ import { BasedFunctionRoute } from '../../../functions';
3
+ import { HttpSession, Context } from '../../../context';
4
+ export declare const httpStreamFunction: (server: BasedServer, ctx: Context<HttpSession>, payload: any, route: BasedFunctionRoute) => void;