@based/server 3.4.6 → 4.0.1

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 (269) 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/authorize.d.ts +2 -0
  5. package/dist/auth/authorize.js +8 -0
  6. package/dist/auth/authorize.js.map +1 -0
  7. package/dist/auth/dummyAuth.d.ts +2 -0
  8. package/dist/auth/dummyAuth.js +8 -0
  9. package/dist/auth/dummyAuth.js.map +1 -0
  10. package/dist/auth/index.d.ts +15 -0
  11. package/dist/auth/index.js +49 -0
  12. package/dist/auth/index.js.map +1 -0
  13. package/dist/auth/parseAuthState.d.ts +2 -0
  14. package/dist/auth/parseAuthState.js +16 -0
  15. package/dist/auth/parseAuthState.js.map +1 -0
  16. package/dist/auth/types.d.ts +10 -0
  17. package/dist/auth/types.js +3 -0
  18. package/dist/auth/types.js.map +1 -0
  19. package/dist/clientContext.d.ts +0 -0
  20. package/dist/clientContext.js +83 -0
  21. package/dist/clientContext.js.map +1 -0
  22. package/dist/compress.d.ts +5 -0
  23. package/dist/compress.js +52 -0
  24. package/dist/compress.js.map +1 -0
  25. package/dist/context.d.ts +54 -0
  26. package/dist/context.js +18 -0
  27. package/dist/context.js.map +1 -0
  28. package/dist/createSimpleServer.d.ts +22 -0
  29. package/dist/createSimpleServer.js +120 -0
  30. package/dist/createSimpleServer.js.map +1 -0
  31. package/dist/error/errorTypeHandlers.d.ts +6 -0
  32. package/dist/error/errorTypeHandlers.js +130 -0
  33. package/dist/error/errorTypeHandlers.js.map +1 -0
  34. package/dist/error/index.d.ts +5 -0
  35. package/dist/error/index.js +61 -0
  36. package/dist/error/index.js.map +1 -0
  37. package/dist/error/types.d.ts +105 -0
  38. package/dist/error/types.js +30 -0
  39. package/dist/error/types.js.map +1 -0
  40. package/dist/error.d.ts +66 -0
  41. package/dist/error.js +149 -0
  42. package/dist/error.js.map +1 -0
  43. package/dist/functions/index.d.ts +34 -0
  44. package/dist/functions/index.js +210 -0
  45. package/dist/functions/index.js.map +1 -0
  46. package/dist/functions/timeout.d.ts +3 -0
  47. package/dist/functions/timeout.js +23 -0
  48. package/dist/functions/timeout.js.map +1 -0
  49. package/dist/functions/types.d.ts +67 -0
  50. package/dist/functions/types.js +15 -0
  51. package/dist/functions/types.js.map +1 -0
  52. package/dist/functions/workerPool.d.ts +0 -0
  53. package/dist/functions/workerPool.js +5 -0
  54. package/dist/functions/workerPool.js.map +1 -0
  55. package/dist/handlers/configuration/index.d.ts +1 -1
  56. package/dist/incoming/http/authorize.d.ts +4 -0
  57. package/dist/incoming/http/authorize.js +37 -0
  58. package/dist/incoming/http/authorize.js.map +1 -0
  59. package/dist/incoming/http/function.d.ts +4 -0
  60. package/dist/incoming/http/function.js +47 -0
  61. package/dist/incoming/http/function.js.map +1 -0
  62. package/dist/incoming/http/get.d.ts +4 -0
  63. package/dist/incoming/http/get.js +155 -0
  64. package/dist/incoming/http/get.js.map +1 -0
  65. package/dist/incoming/http/index.d.ts +3 -0
  66. package/dist/incoming/http/index.js +134 -0
  67. package/dist/incoming/http/index.js.map +1 -0
  68. package/dist/incoming/http/parseQuery.d.ts +4 -0
  69. package/dist/incoming/http/parseQuery.js +25 -0
  70. package/dist/incoming/http/parseQuery.js.map +1 -0
  71. package/dist/incoming/http/readBody.d.ts +4 -0
  72. package/dist/incoming/http/readBody.js +107 -0
  73. package/dist/incoming/http/readBody.js.map +1 -0
  74. package/dist/incoming/http/streamFunction/DataStream.d.ts +7 -0
  75. package/dist/incoming/http/streamFunction/DataStream.js +19 -0
  76. package/dist/incoming/http/streamFunction/DataStream.js.map +1 -0
  77. package/dist/incoming/http/streamFunction/getExtension.d.ts +2 -0
  78. package/dist/incoming/http/streamFunction/getExtension.js +29 -0
  79. package/dist/incoming/http/streamFunction/getExtension.js.map +1 -0
  80. package/dist/incoming/http/streamFunction/index.d.ts +4 -0
  81. package/dist/incoming/http/streamFunction/index.js +106 -0
  82. package/dist/incoming/http/streamFunction/index.js.map +1 -0
  83. package/dist/incoming/http/streamFunction/multipartStream.d.ts +13 -0
  84. package/dist/incoming/http/streamFunction/multipartStream.js +208 -0
  85. package/dist/incoming/http/streamFunction/multipartStream.js.map +1 -0
  86. package/dist/incoming/http/streamFunction/stream.d.ts +6 -0
  87. package/dist/incoming/http/streamFunction/stream.js +108 -0
  88. package/dist/incoming/http/streamFunction/stream.js.map +1 -0
  89. package/dist/incoming/index.d.ts +3 -0
  90. package/dist/incoming/index.js +84 -0
  91. package/dist/incoming/index.js.map +1 -0
  92. package/dist/incoming/upgrade.d.ts +4 -0
  93. package/dist/incoming/upgrade.js +64 -0
  94. package/dist/incoming/upgrade.js.map +1 -0
  95. package/dist/incoming/ws/auth.d.ts +5 -0
  96. package/dist/incoming/ws/auth.js +40 -0
  97. package/dist/incoming/ws/auth.js.map +1 -0
  98. package/dist/incoming/ws/function.d.ts +3 -0
  99. package/dist/incoming/ws/function.js +107 -0
  100. package/dist/incoming/ws/function.js.map +1 -0
  101. package/dist/incoming/ws/get.d.ts +3 -0
  102. package/dist/incoming/ws/get.js +136 -0
  103. package/dist/incoming/ws/get.js.map +1 -0
  104. package/dist/incoming/ws/index.d.ts +3 -0
  105. package/dist/incoming/ws/index.js +61 -0
  106. package/dist/incoming/ws/index.js.map +1 -0
  107. package/dist/incoming/ws/observable.d.ts +6 -0
  108. package/dist/incoming/ws/observable.js +112 -0
  109. package/dist/incoming/ws/observable.js.map +1 -0
  110. package/dist/index.d.ts +11 -35
  111. package/dist/index.js +19 -196
  112. package/dist/index.js.map +1 -1
  113. package/dist/ip.d.ts +2 -0
  114. package/dist/ip.js +8 -0
  115. package/dist/ip.js.map +1 -0
  116. package/dist/network/http/authorize.d.ts +3 -0
  117. package/dist/network/http/authorize.js +28 -0
  118. package/dist/network/http/authorize.js.map +1 -0
  119. package/dist/network/http/compress.d.ts +6 -0
  120. package/dist/network/http/compress.js +56 -0
  121. package/dist/network/http/compress.js.map +1 -0
  122. package/dist/network/http/end.d.ts +4 -0
  123. package/dist/network/http/end.js +19 -0
  124. package/dist/network/http/end.js.map +1 -0
  125. package/dist/network/http/function.d.ts +3 -0
  126. package/dist/network/http/function.js +47 -0
  127. package/dist/network/http/function.js.map +1 -0
  128. package/dist/network/http/get.d.ts +3 -0
  129. package/dist/network/http/get.js +129 -0
  130. package/dist/network/http/get.js.map +1 -0
  131. package/dist/network/http/index.d.ts +3 -0
  132. package/dist/network/http/index.js +122 -0
  133. package/dist/network/http/index.js.map +1 -0
  134. package/dist/network/http/readBody.d.ts +3 -0
  135. package/dist/network/http/readBody.js +112 -0
  136. package/dist/network/http/readBody.js.map +1 -0
  137. package/dist/network/http/send.d.ts +5 -0
  138. package/dist/network/http/send.js +60 -0
  139. package/dist/network/http/send.js.map +1 -0
  140. package/dist/network/http/streamFunction/DataStream.d.ts +7 -0
  141. package/dist/network/http/streamFunction/DataStream.js +19 -0
  142. package/dist/network/http/streamFunction/DataStream.js.map +1 -0
  143. package/dist/network/http/streamFunction/getExtension.d.ts +2 -0
  144. package/dist/network/http/streamFunction/getExtension.js +29 -0
  145. package/dist/network/http/streamFunction/getExtension.js.map +1 -0
  146. package/dist/network/http/streamFunction/index.d.ts +3 -0
  147. package/dist/network/http/streamFunction/index.js +81 -0
  148. package/dist/network/http/streamFunction/index.js.map +1 -0
  149. package/dist/network/http/streamFunction/multipartStream.d.ts +12 -0
  150. package/dist/network/http/streamFunction/multipartStream.js +208 -0
  151. package/dist/network/http/streamFunction/multipartStream.js.map +1 -0
  152. package/dist/network/http/streamFunction/stream.d.ts +5 -0
  153. package/dist/network/http/streamFunction/stream.js +103 -0
  154. package/dist/network/http/streamFunction/stream.js.map +1 -0
  155. package/dist/network/index.d.ts +4 -0
  156. package/dist/network/index.js +84 -0
  157. package/dist/network/index.js.map +1 -0
  158. package/dist/network/message/auth.d.ts +4 -0
  159. package/dist/network/message/auth.js +32 -0
  160. package/dist/network/message/auth.js.map +1 -0
  161. package/dist/network/message/function.d.ts +3 -0
  162. package/dist/network/message/function.js +67 -0
  163. package/dist/network/message/function.js.map +1 -0
  164. package/dist/network/message/get.d.ts +3 -0
  165. package/dist/network/message/get.js +109 -0
  166. package/dist/network/message/get.js.map +1 -0
  167. package/dist/network/message/index.d.ts +3 -0
  168. package/dist/network/message/index.js +62 -0
  169. package/dist/network/message/index.js.map +1 -0
  170. package/dist/network/message/observable.d.ts +5 -0
  171. package/dist/network/message/observable.js +103 -0
  172. package/dist/network/message/observable.js.map +1 -0
  173. package/dist/network/message/send.d.ts +4 -0
  174. package/dist/network/message/send.js +11 -0
  175. package/dist/network/message/send.js.map +1 -0
  176. package/dist/network/upgrade.d.ts +4 -0
  177. package/dist/network/upgrade.js +49 -0
  178. package/dist/network/upgrade.js.map +1 -0
  179. package/dist/network/worker/get.d.ts +0 -0
  180. package/dist/network/worker/get.js +122 -0
  181. package/dist/network/worker/get.js.map +1 -0
  182. package/dist/network/worker/observable.d.ts +0 -0
  183. package/dist/network/worker/observable.js +120 -0
  184. package/dist/network/worker/observable.js.map +1 -0
  185. package/dist/observable/create.d.ts +3 -0
  186. package/dist/observable/create.js +30 -0
  187. package/dist/observable/create.js.map +1 -0
  188. package/dist/observable/destroy.d.ts +2 -0
  189. package/dist/observable/destroy.js +51 -0
  190. package/dist/observable/destroy.js.map +1 -0
  191. package/dist/observable/error.d.ts +4 -0
  192. package/dist/observable/error.js +17 -0
  193. package/dist/observable/error.js.map +1 -0
  194. package/dist/observable/extendCache.d.ts +2 -0
  195. package/dist/observable/extendCache.js +11 -0
  196. package/dist/observable/extendCache.js.map +1 -0
  197. package/dist/observable/genObservableId.d.ts +1 -0
  198. package/dist/observable/genObservableId.js +9 -0
  199. package/dist/observable/genObservableId.js.map +1 -0
  200. package/dist/observable/get.d.ts +4 -0
  201. package/dist/observable/get.js +15 -0
  202. package/dist/observable/get.js.map +1 -0
  203. package/dist/observable/index.d.ts +11 -0
  204. package/dist/observable/index.js +28 -0
  205. package/dist/observable/index.js.map +1 -0
  206. package/dist/observable/send.d.ts +6 -0
  207. package/dist/observable/send.js +32 -0
  208. package/dist/observable/send.js.map +1 -0
  209. package/dist/observable/start/error.d.ts +3 -0
  210. package/dist/observable/start/error.js +36 -0
  211. package/dist/observable/start/error.js.map +1 -0
  212. package/dist/observable/start/index.d.ts +2 -0
  213. package/dist/observable/start/index.js +46 -0
  214. package/dist/observable/start/index.js.map +1 -0
  215. package/dist/observable/start/update.d.ts +6 -0
  216. package/dist/observable/start/update.js +104 -0
  217. package/dist/observable/start/update.js.map +1 -0
  218. package/dist/observable/subscribe.d.ts +7 -0
  219. package/dist/observable/subscribe.js +54 -0
  220. package/dist/observable/subscribe.js.map +1 -0
  221. package/dist/observable/types.d.ts +26 -0
  222. package/dist/observable/types.js +3 -0
  223. package/dist/observable/types.js.map +1 -0
  224. package/dist/observable/unsub.d.ts +6 -0
  225. package/dist/observable/unsub.js +43 -0
  226. package/dist/observable/unsub.js.map +1 -0
  227. package/dist/observable/verify.d.ts +4 -0
  228. package/dist/observable/verify.js +18 -0
  229. package/dist/observable/verify.js.map +1 -0
  230. package/dist/protocol.d.ts +21 -0
  231. package/dist/protocol.js +233 -0
  232. package/dist/protocol.js.map +1 -0
  233. package/dist/security/index.d.ts +3 -0
  234. package/dist/security/index.js +66 -0
  235. package/dist/security/index.js.map +1 -0
  236. package/dist/security.d.ts +6 -0
  237. package/dist/security.js +95 -0
  238. package/dist/security.js.map +1 -0
  239. package/dist/sendError.d.ts +5 -0
  240. package/dist/sendError.js +42 -0
  241. package/dist/sendError.js.map +1 -0
  242. package/dist/sendHttpResponse.d.ts +4 -0
  243. package/dist/sendHttpResponse.js +53 -0
  244. package/dist/sendHttpResponse.js.map +1 -0
  245. package/dist/server.d.ts +69 -0
  246. package/dist/server.js +113 -0
  247. package/dist/server.js.map +1 -0
  248. package/dist/worker/authorize.d.ts +5 -0
  249. package/dist/worker/authorize.js +15 -0
  250. package/dist/worker/authorize.js.map +1 -0
  251. package/dist/worker/fnMap.d.ts +2 -0
  252. package/dist/worker/fnMap.js +5 -0
  253. package/dist/worker/fnMap.js.map +1 -0
  254. package/dist/worker/functions.d.ts +3 -0
  255. package/dist/worker/functions.js +8 -0
  256. package/dist/worker/functions.js.map +1 -0
  257. package/dist/worker/http/function.d.ts +4 -0
  258. package/dist/worker/http/function.js +75 -0
  259. package/dist/worker/http/function.js.map +1 -0
  260. package/dist/worker/index.d.ts +1 -0
  261. package/dist/worker/index.js +101 -0
  262. package/dist/worker/index.js.map +1 -0
  263. package/dist/worker/observable.d.ts +15 -0
  264. package/dist/worker/observable.js +110 -0
  265. package/dist/worker/observable.js.map +1 -0
  266. package/dist/worker/ws/function.d.ts +3 -0
  267. package/dist/worker/ws/function.js +42 -0
  268. package/dist/worker/ws/function.js.map +1 -0
  269. package/package.json +16 -14
package/dist/index.js CHANGED
@@ -13,203 +13,26 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
13
13
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
- var __importDefault = (this && this.__importDefault) || function (mod) {
17
- return (mod && mod.__esModule) ? mod : { "default": mod };
18
- };
19
16
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.BasedServer = exports.User = exports.BasedServerClient = exports.Params = void 0;
21
- const uws_1 = __importDefault(require("@based/uws"));
22
- const events_1 = require("events");
23
- const upgradeListener_1 = __importDefault(require("./upgradeListener"));
24
- const handlers_1 = __importDefault(require("./handlers"));
25
- const openListener_1 = __importDefault(require("./openListener"));
26
- const closeListener_1 = __importDefault(require("./closeListener"));
27
- const Client_1 = __importDefault(require("./Client"));
28
- exports.User = Client_1.default;
29
- const selva_1 = require("@saulx/selva");
30
- const utils_1 = require("@saulx/utils");
31
- const rest_1 = __importDefault(require("./handlers/rest"));
32
- const BasedServerClient_1 = __importDefault(require("./BasedServerClient"));
33
- exports.BasedServerClient = BasedServerClient_1.default;
34
- const Params_1 = require("./Params");
35
- Object.defineProperty(exports, "Params", { enumerable: true, get: function () { return Params_1.Params; } });
36
- const getFromConfig_1 = require("./getFromConfig");
37
- const pkg = require('../package.json');
38
- __exportStar(require("./types"), exports);
39
- class BasedServer extends events_1.EventEmitter {
40
- constructor({ key, cert, useLessMemory, port, db, config, state, }) {
41
- super();
42
- this.subscriptions = {};
43
- // will be clients
44
- this.clients = {};
45
- if (state) {
46
- this.state = state;
47
- }
48
- else {
49
- this.state = {};
50
- }
51
- if (config?.functionConfig) {
52
- const interval = ~~(config.functionConfig.idleTimeout / 2);
53
- const clear = async () => {
54
- if (config.functions) {
55
- for (const key in config.functions) {
56
- // & key !== open && key !== close
57
- // good name ?
58
- // based init - will ask project env org (all optional ofc)
59
- if (key !== 'authorize' && !key.startsWith('event-')) {
60
- if (config.functions[key].cnt === 2) {
61
- await config.functionConfig.clear(this, key);
62
- delete config.functions[key];
63
- }
64
- else {
65
- if (config.functions[key].cnt !== undefined) {
66
- config.functions[key].cnt++;
67
- }
68
- }
69
- }
70
- }
71
- }
72
- setTimeout(clear, interval);
73
- };
74
- setTimeout(clear, interval);
75
- }
76
- if (config?.secretsConfig) {
77
- config.secretsConfig.secretTimeouts = {};
78
- const interval = ~~(config.secretsConfig.idleTimeout / 2);
79
- const clear = async () => {
80
- if (config.secrets) {
81
- for (const key in config.secretsConfig.secretTimeouts) {
82
- if (config.secretsConfig.secretTimeouts[key] === 2) {
83
- // await config.secretsConfig.clear(this, key)
84
- delete config.secretsConfig.secretTimeouts[key];
85
- // delete config.secrets[key]
86
- }
87
- else {
88
- if (config.secretsConfig.secretTimeouts[key] !== undefined) {
89
- config.secretsConfig.secretTimeouts[key]++;
90
- }
91
- }
92
- }
93
- }
94
- setTimeout(clear, interval);
95
- };
96
- setTimeout(clear, interval);
97
- }
98
- const app = key && cert
99
- ? uws_1.default.SSLApp({
100
- key_file_name: key,
101
- cert_file_name: cert,
102
- ssl_prefer_low_memory_usage: useLessMemory,
103
- })
104
- : uws_1.default.App();
105
- if (port) {
106
- this.port = port;
107
- }
108
- app
109
- .ws('/*', {
110
- maxPayloadLength: 1024 * 1024 * 16 * 1000,
111
- idleTimeout: 100,
112
- compression: uws_1.default.SHARED_COMPRESSOR,
113
- upgrade: (res, req, ctx) => {
114
- (0, upgradeListener_1.default)(this, res, req, ctx);
115
- },
116
- message: (ws, msg) => {
117
- (0, handlers_1.default)(this, ws, msg);
118
- },
119
- open: (ws) => {
120
- (0, openListener_1.default)(this, ws);
121
- },
122
- close: (ws) => {
123
- (0, closeListener_1.default)(this, ws);
124
- },
125
- drain: (ws) => {
126
- // call client.drain can be much more efficient
127
- if (ws.client && ws.client.backpressureQueue) {
128
- ws.client.drain();
129
- }
130
- },
131
- })
132
- // /with name
133
- .get('/*', (res, req) => (0, rest_1.default)(this, req, res))
134
- .post('/*', (res, req) => (0, rest_1.default)(this, req, res))
135
- .options('/*', (res, req) => (0, rest_1.default)(this, req, res));
136
- this.uwsApp = app;
137
- this.db = (0, selva_1.connect)(db);
138
- if (config) {
139
- const based = new BasedServerClient_1.default(new Params_1.Params(this, {
140
- payload: {},
141
- callStack: ['server'],
142
- }), true);
143
- this.based = based;
144
- this.on('open', (client) => {
145
- if (config.onOpen) {
146
- config.onOpen({ user: client, based });
147
- }
148
- });
149
- this.on('close', (client) => {
150
- if (config.onClose) {
151
- config.onClose({ user: client, based });
152
- }
153
- });
154
- this.config = config;
155
- }
156
- }
157
- restartSubscription(name) {
158
- for (const id in this.subscriptions) {
159
- const sub = this.subscriptions[id];
160
- // @ts-ignore
161
- if (sub.name === name) {
162
- // @ts-ignore
163
- sub.restart();
164
- }
165
- }
166
- }
167
- start(port) {
168
- if (!port) {
169
- port = this.port;
170
- }
171
- else {
172
- this.port = port;
173
- }
174
- return new Promise((resolve, reject) => {
175
- this.uwsApp.listen(this.port, (listenSocket) => {
176
- if (listenSocket) {
177
- console.info(`💫 Based-server ${pkg.version} listening on port:`, this.port);
178
- // do this better wrap a nice thing arround it
179
- this.listenSocket = listenSocket;
180
- resolve(this);
181
- }
182
- else {
183
- console.info('🤮 Based-server error on port:', this.port);
184
- reject(new Error('Cannot start based-server on port: ' + this.port));
185
- }
186
- });
187
- });
188
- }
189
- async getFunction(name) {
190
- return (0, getFromConfig_1.getFunction)(this, name);
191
- }
192
- async destroy() {
193
- console.info('🔥 Destroy based-server');
194
- for (const c in this.clients) {
195
- this.clients[c].destroy();
196
- delete this.clients[c];
197
- }
198
- if (this.listenSocket) {
199
- uws_1.default.us_listen_socket_close(this.listenSocket);
200
- this.listenSocket = null;
201
- }
202
- this.listenSocket = null;
203
- this.uwsApp = null;
204
- await this.db.destroy();
205
- this.db = null;
206
- await (0, utils_1.wait)(1000);
207
- }
208
- }
209
- exports.BasedServer = BasedServer;
210
- const createServer = async (props) => {
211
- const basedServer = new BasedServer(props);
212
- return props.port ? basedServer.start() : basedServer;
17
+ exports.createSimpleServer = exports.sendError = exports.sendHttpResponse = exports.compress = exports.BasedServer = void 0;
18
+ const server_1 = require("./server");
19
+ Object.defineProperty(exports, "BasedServer", { enumerable: true, get: function () { return server_1.BasedServer; } });
20
+ const createServer = async (props, sharedSocket) => {
21
+ const basedServer = new server_1.BasedServer(props);
22
+ return props.port ? basedServer.start(props.port, sharedSocket) : basedServer;
213
23
  };
214
24
  exports.default = createServer;
25
+ // maybe send responsed
26
+ var compress_1 = require("./compress");
27
+ Object.defineProperty(exports, "compress", { enumerable: true, get: function () { return compress_1.compress; } });
28
+ var sendHttpResponse_1 = require("./sendHttpResponse");
29
+ Object.defineProperty(exports, "sendHttpResponse", { enumerable: true, get: function () { return sendHttpResponse_1.sendHttpResponse; } });
30
+ var sendError_1 = require("./sendError");
31
+ Object.defineProperty(exports, "sendError", { enumerable: true, get: function () { return sendError_1.sendError; } });
32
+ var createSimpleServer_1 = require("./createSimpleServer");
33
+ Object.defineProperty(exports, "createSimpleServer", { enumerable: true, get: function () { return createSimpleServer_1.createSimpleServer; } });
34
+ __exportStar(require("./auth/types"), exports);
35
+ __exportStar(require("./functions/types"), exports);
36
+ __exportStar(require("./error"), exports);
37
+ __exportStar(require("./api"), exports);
215
38
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,qDAA4B;AAC5B,mCAAqC;AACrC,wEAAuC;AACvC,0DAAgC;AAChC,kEAAiC;AACjC,oEAAmC;AACnC,sDAA6B;AAiBiB,eAjBvC,gBAAM,CAiBqC;AAhBlD,wCAAmD;AAEnD,wCAAmC;AAMnC,2DAAyC;AACzC,4EAAmD;AAOlC,4BAPV,2BAAiB,CAOU;AANlC,qCAAiC;AAMxB,uFANA,eAAM,OAMA;AAJf,mDAA6C;AAE7C,MAAM,GAAG,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAA;AAItC,0CAAuB;AAEvB,MAAa,WAAY,SAAQ,qBAAY;IA4B3C,YAAY,EACV,GAAG,EACH,IAAI,EACJ,aAAa,EACb,IAAI,EACJ,EAAE,EACF,MAAM,EACN,KAAK,GACS;QACd,KAAK,EAAE,CAAA;QA9BF,kBAAa,GAMhB,EAAE,CAAA;QAIN,kBAAkB;QACX,YAAO,GAA6B,EAAE,CAAA;QAqB3C,IAAI,KAAK,EAAE;YACT,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;SACnB;aAAM;YACL,IAAI,CAAC,KAAK,GAAG,EAAE,CAAA;SAChB;QAED,IAAI,MAAM,EAAE,cAAc,EAAE;YAC1B,MAAM,QAAQ,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,cAAc,CAAC,WAAW,GAAG,CAAC,CAAC,CAAA;YAC1D,MAAM,KAAK,GAAG,KAAK,IAAI,EAAE;gBACvB,IAAI,MAAM,CAAC,SAAS,EAAE;oBACpB,KAAK,MAAM,GAAG,IAAI,MAAM,CAA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Y,GAAG,KAAK,EACxB,KAAoB,EACpB,YAAsB,EACA,EAAE;IACxB,MAAM,WAAW,GAAG,IAAI,oBAAW,CAAC,KAAK,CAAC,CAAA;IAC1C,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;AAC/E,CAAC,CAAA;AAID,kBAAe,YAAY,CAAA;AAE3B,uBAAuB;AACvB,uCAAqC;AAA5B,oGAAA,QAAQ,OAAA;AACjB,uDAAqD;AAA5C,oHAAA,gBAAgB,OAAA;AACzB,yCAAuC;AAA9B,sGAAA,SAAS,OAAA;AAClB,2DAAyD;AAAhD,wHAAA,kBAAkB,OAAA;AAE3B,+CAA4B;AAC5B,oDAAiC;AACjC,0CAAuB;AACvB,wCAAqB"}
package/dist/ip.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import uws from '@based/uws';
2
+ export declare const getIp: (res: uws.HttpResponse) => string;
package/dist/ip.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getIp = void 0;
4
+ const getIp = (res) => {
5
+ return Buffer.from(res.getRemoteAddressAsText()).toString();
6
+ };
7
+ exports.getIp = getIp;
8
+ //# sourceMappingURL=ip.js.map
package/dist/ip.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ip.js","sourceRoot":"","sources":["../src/ip.ts"],"names":[],"mappings":";;;AAEO,MAAM,KAAK,GAAG,CAAC,GAAqB,EAAU,EAAE;IACrD,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAA;AAC7D,CAAC,CAAA;AAFY,QAAA,KAAK,SAEjB"}
@@ -0,0 +1,3 @@
1
+ import { BasedServer } from '../../server';
2
+ import { BasedFunctionRoute, HttpClient } from '../../types';
3
+ export declare const authorizeRequest: (server: BasedServer, client: HttpClient, payload: any, route: BasedFunctionRoute, authorized: (payload: any) => void) => void;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.authorizeRequest = void 0;
4
+ const send_1 = require("./send");
5
+ const error_1 = require("../../error");
6
+ const authorizeRequest = (server, client, payload, route, authorized) => {
7
+ server.auth
8
+ .authorize(client.context, route.name, payload)
9
+ .then((ok) => {
10
+ if (!client.res) {
11
+ return;
12
+ }
13
+ if (!ok) {
14
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.AuthorizeRejectedError, route);
15
+ }
16
+ else {
17
+ authorized(payload);
18
+ }
19
+ })
20
+ .catch((err) => {
21
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.AuthorizeFunctionError, {
22
+ route,
23
+ err,
24
+ });
25
+ });
26
+ };
27
+ exports.authorizeRequest = authorizeRequest;
28
+ //# sourceMappingURL=authorize.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorize.js","sourceRoot":"","sources":["../../../src/network/http/authorize.ts"],"names":[],"mappings":";;;AAEA,iCAAsC;AACtC,uCAA4C;AAErC,MAAM,gBAAgB,GAAG,CAC9B,MAAmB,EACnB,MAAkB,EAClB,OAAY,EACZ,KAAyB,EACzB,UAAkC,EAClC,EAAE;IACF,MAAM,CAAC,IAAI;SACR,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC;SAC9C,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE;QACX,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,OAAM;SACP;QACD,IAAI,CAAC,EAAE,EAAE;YACP,IAAA,oBAAa,EACX,MAAM,EACN,MAAM,EACN,sBAAc,CAAC,sBAAsB,EACrC,KAAK,CACN,CAAA;SACF;aAAM;YACL,UAAU,CAAC,OAAO,CAAC,CAAA;SACpB;IACH,CAAC,CAAC;SACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;QACb,IAAA,oBAAa,EAAC,MAAM,EAAE,MAAM,EAAE,sBAAc,CAAC,sBAAsB,EAAE;YACnE,KAAK;YACL,GAAG;SACJ,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACN,CAAC,CAAA;AA9BY,QAAA,gBAAgB,oBA8B5B"}
@@ -0,0 +1,6 @@
1
+ /// <reference types="node" />
2
+ import { HttpClient } from '../../types';
3
+ export declare const compress: (client: HttpClient, payload: string | Buffer) => Promise<{
4
+ payload: Buffer | string;
5
+ encoding?: string;
6
+ }>;
@@ -0,0 +1,56 @@
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.compress = void 0;
7
+ const node_zlib_1 = __importDefault(require("node:zlib"));
8
+ const node_util_1 = require("node:util");
9
+ const protocol_1 = require("../../protocol");
10
+ const deflate = (0, node_util_1.promisify)(node_zlib_1.default.deflate);
11
+ const gzip = (0, node_util_1.promisify)(node_zlib_1.default.gzip);
12
+ const br = (0, node_util_1.promisify)(node_zlib_1.default.brotliCompress);
13
+ /*
14
+ Content-Encoding: gzip
15
+ Content-Encoding: compress
16
+ Content-Encoding: deflate
17
+ Content-Encoding: br
18
+ */
19
+ const COMPRESS_STRING_LEN = Math.ceil(protocol_1.COMPRESS_FROM_BYTES / 1.5);
20
+ const compress = async (client, payload) => {
21
+ if (!client.res) {
22
+ return;
23
+ }
24
+ const encoding = client.context.headers.encoding;
25
+ if (payload instanceof Buffer && payload.byteLength <= protocol_1.COMPRESS_FROM_BYTES) {
26
+ return { payload };
27
+ }
28
+ if (payload.length < COMPRESS_STRING_LEN) {
29
+ return { payload };
30
+ }
31
+ if (encoding && typeof encoding === 'string') {
32
+ let responseEncoding;
33
+ let compressed;
34
+ if (!(payload instanceof Buffer)) {
35
+ payload = Buffer.from(payload);
36
+ }
37
+ if (encoding.includes('deflate')) {
38
+ responseEncoding = 'deflate';
39
+ compressed = await deflate(payload);
40
+ }
41
+ else if (encoding.includes('gzip')) {
42
+ responseEncoding = 'gzip';
43
+ compressed = await gzip(payload);
44
+ }
45
+ else if (encoding.includes('br')) {
46
+ responseEncoding = 'br';
47
+ compressed = await br(payload);
48
+ }
49
+ if (compressed) {
50
+ return { payload: compressed, encoding: responseEncoding };
51
+ }
52
+ }
53
+ return { payload };
54
+ };
55
+ exports.compress = compress;
56
+ //# sourceMappingURL=compress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compress.js","sourceRoot":"","sources":["../../../src/network/http/compress.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA4B;AAC5B,yCAAqC;AAErC,6CAAoD;AAEpD,MAAM,OAAO,GAAG,IAAA,qBAAS,EAAC,mBAAI,CAAC,OAAO,CAAC,CAAA;AACvC,MAAM,IAAI,GAAG,IAAA,qBAAS,EAAC,mBAAI,CAAC,IAAI,CAAC,CAAA;AACjC,MAAM,EAAE,GAAG,IAAA,qBAAS,EAAC,mBAAI,CAAC,cAAc,CAAC,CAAA;AAEzC;;;;;EAKE;AAEF,MAAM,mBAAmB,GAAG,IAAI,CAAC,IAAI,CAAC,8BAAmB,GAAG,GAAG,CAAC,CAAA;AAEzD,MAAM,QAAQ,GAAG,KAAK,EAC3B,MAAkB,EAClB,OAAwB,EACkC,EAAE;IAC5D,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;QACf,OAAM;KACP;IAED,MAAM,QAAQ,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAA;IAEhD,IAAI,OAAO,YAAY,MAAM,IAAI,OAAO,CAAC,UAAU,IAAI,8BAAmB,EAAE;QAC1E,OAAO,EAAE,OAAO,EAAE,CAAA;KACnB;IAED,IAAI,OAAO,CAAC,MAAM,GAAG,mBAAmB,EAAE;QACxC,OAAO,EAAE,OAAO,EAAE,CAAA;KACnB;IAED,IAAI,QAAQ,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;QAC5C,IAAI,gBAAwB,CAAA;QAC5B,IAAI,UAAkB,CAAA;QACtB,IAAI,CAAC,CAAC,OAAO,YAAY,MAAM,CAAC,EAAE;YAChC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAA;SAC/B;QACD,IAAI,QAAQ,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE;YAChC,gBAAgB,GAAG,SAAS,CAAA;YAC5B,UAAU,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,CAAA;SACpC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;YACpC,gBAAgB,GAAG,MAAM,CAAA;YACzB,UAAU,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,CAAA;SACjC;aAAM,IAAI,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE;YAClC,gBAAgB,GAAG,IAAI,CAAA;YACvB,UAAU,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,CAAA;SAC/B;QACD,IAAI,UAAU,EAAE;YACd,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAA;SAC3D;KACF;IACD,OAAO,EAAE,OAAO,EAAE,CAAA;AACpB,CAAC,CAAA;AAvCY,QAAA,QAAQ,YAuCpB"}
@@ -0,0 +1,4 @@
1
+ /// <reference types="node" />
2
+ import { HttpClient } from '../../types';
3
+ declare const _default: (client: HttpClient, payload?: string | Buffer | Uint8Array) => void;
4
+ export default _default;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.default = (client, payload) => {
4
+ if (client.res) {
5
+ client.res.writeHeader('Access-Control-Allow-Origin', '*');
6
+ // only allowed headers
7
+ client.res.writeHeader('Access-Control-Allow-Headers', '*');
8
+ if (payload === undefined) {
9
+ client.res.end();
10
+ }
11
+ else {
12
+ client.res.end(payload);
13
+ }
14
+ client.res = null;
15
+ client.req = null;
16
+ client.context = null;
17
+ }
18
+ };
19
+ //# sourceMappingURL=end.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"end.js","sourceRoot":"","sources":["../../../src/network/http/end.ts"],"names":[],"mappings":";;AAEA,kBAAe,CAAC,MAAkB,EAAE,OAAsC,EAAE,EAAE;IAC5E,IAAI,MAAM,CAAC,GAAG,EAAE;QACd,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,6BAA6B,EAAE,GAAG,CAAC,CAAA;QAC1D,uBAAuB;QACvB,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,8BAA8B,EAAE,GAAG,CAAC,CAAA;QAC3D,IAAI,OAAO,KAAK,SAAS,EAAE;YACzB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAA;SACjB;aAAM;YACL,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;SACxB;QACD,MAAM,CAAC,GAAG,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,GAAG,GAAG,IAAI,CAAA;QACjB,MAAM,CAAC,OAAO,GAAG,IAAI,CAAA;KACtB;AACH,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { BasedServer } from '../../server';
2
+ import { BasedFunctionRoute, HttpClient } from '../../types';
3
+ export declare const httpFunction: (method: string, route: BasedFunctionRoute, client: HttpClient, server: BasedServer, payload?: Uint8Array) => void;
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.httpFunction = void 0;
4
+ const functions_1 = require("../../functions");
5
+ const send_1 = require("./send");
6
+ const error_1 = require("../../error");
7
+ const httpFunction = (method, route, client, server, payload) => {
8
+ if (!client.res) {
9
+ return;
10
+ }
11
+ const name = route.name;
12
+ server.functions
13
+ .install(name)
14
+ .then((spec) => {
15
+ if (!client.res) {
16
+ return;
17
+ }
18
+ 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)
22
+ .then(async (result) => {
23
+ if (!client.res) {
24
+ return;
25
+ }
26
+ if (spec.customHttpResponse) {
27
+ if (await spec.customHttpResponse(result, payload, client)) {
28
+ return;
29
+ }
30
+ (0, send_1.sendHttpResponse)(client, result);
31
+ }
32
+ else {
33
+ (0, send_1.sendHttpResponse)(client, result);
34
+ }
35
+ })
36
+ .catch((err) => {
37
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionError, {
38
+ err,
39
+ route,
40
+ });
41
+ });
42
+ }
43
+ })
44
+ .catch(() => (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route));
45
+ };
46
+ exports.httpFunction = httpFunction;
47
+ //# sourceMappingURL=function.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/network/http/function.ts"],"names":[],"mappings":";;;AAAA,+CAA0D;AAG1D,iCAAwD;AACxD,uCAA4C;AAErC,MAAM,YAAY,GAAG,CAC1B,MAAc,EACd,KAAyB,EACzB,MAAkB,EAClB,MAAmB,EACnB,OAAoB,EACd,EAAE;IACR,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;QACf,OAAM;KACP;IACD,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;IACvB,MAAM,CAAC,SAAS;SACb,OAAO,CAAC,IAAI,CAAC;SACb,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;QACb,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;YACf,OAAM;SACP;QACD,IAAI,IAAI,IAAI,CAAC,IAAA,oCAAwB,EAAC,IAAI,CAAC,EAAE;YAC3C,mDAAmD;YACnD,MAAM,CAAC,SAAS;iBACb,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,CAAC;iBACrE,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE;gBACrB,IAAI,CAAC,MAAM,CAAC,GAAG,EAAE;oBACf,OAAM;iBACP;gBACD,IAAI,IAAI,CAAC,kBAAkB,EAAE;oBAC3B,IAAI,MAAM,IAAI,CAAC,kBAAkB,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE;wBAC1D,OAAM;qBACP;oBACD,IAAA,uBAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;iBACjC;qBAAM;oBACL,IAAA,uBAAgB,EAAC,MAAM,EAAE,MAAM,CAAC,CAAA;iBACjC;YACH,CAAC,CAAC;iBACD,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,IAAA,oBAAa,EAAC,MAAM,EAAE,MAAM,EAAE,sBAAc,CAAC,aAAa,EAAE;oBAC1D,GAAG;oBACH,KAAK;iBACN,CAAC,CAAA;YACJ,CAAC,CAAC,CAAA;SACL;IACH,CAAC,CAAC;SACD,KAAK,CAAC,GAAG,EAAE,CACV,IAAA,oBAAa,EAAC,MAAM,EAAE,MAAM,EAAE,sBAAc,CAAC,gBAAgB,EAAE,KAAK,CAAC,CACtE,CAAA;AACL,CAAC,CAAA;AA7CY,QAAA,YAAY,gBA6CxB"}
@@ -0,0 +1,3 @@
1
+ import { BasedServer } from '../../server';
2
+ import { HttpClient, BasedFunctionRoute } from '../../types';
3
+ export declare const httpGet: (route: BasedFunctionRoute, payload: any, client: HttpClient, server: BasedServer, checksum: number) => void;
@@ -0,0 +1,129 @@
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 end_1 = __importDefault(require("./end"));
9
+ const compress_1 = require("./compress");
10
+ const send_1 = require("./send");
11
+ const hash_1 = require("@saulx/hash");
12
+ const observable_1 = require("../../observable");
13
+ const node_zlib_1 = __importDefault(require("node:zlib"));
14
+ const error_1 = require("../../error");
15
+ const sendGetResponse = (route, server, id, obs, checksum, client) => {
16
+ if (!client.res) {
17
+ return;
18
+ }
19
+ const encoding = client.context.headers.encoding;
20
+ try {
21
+ if (checksum === 0 || checksum !== obs.checksum) {
22
+ if (!obs.cache) {
23
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.NoOservableCacheAvailable, {
24
+ observableId: id,
25
+ name: obs.name,
26
+ });
27
+ }
28
+ else {
29
+ if (obs.isDeflate) {
30
+ if (typeof encoding === 'string' && encoding.includes('deflate')) {
31
+ client.res.cork(() => {
32
+ client.res.writeStatus('200 OK');
33
+ client.res.writeHeader('ETag', String(obs.checksum));
34
+ client.res.writeHeader('Content-Encoding', 'deflate');
35
+ (0, end_1.default)(client, obs.cache.slice(4 + 8 + 8));
36
+ });
37
+ }
38
+ else {
39
+ (0, compress_1.compress)(client, node_zlib_1.default.inflateRawSync(obs.cache.slice(4 + 8 + 8))).then(({ payload, encoding }) => {
40
+ client.res.cork(() => {
41
+ client.res.writeStatus('200 OK');
42
+ if (encoding) {
43
+ client.res.writeHeader('Content-Encoding', encoding);
44
+ }
45
+ client.res.writeHeader('ETag', String(obs.checksum));
46
+ (0, end_1.default)(client, payload);
47
+ });
48
+ });
49
+ }
50
+ }
51
+ else {
52
+ client.res.cork(() => {
53
+ client.res.writeStatus('200 OK');
54
+ client.res.writeHeader('ETag', String(obs.checksum));
55
+ (0, end_1.default)(client, obs.cache.slice(4 + 8 + 8));
56
+ });
57
+ }
58
+ }
59
+ }
60
+ else {
61
+ client.res.cork(() => {
62
+ client.res.writeStatus('304 Not Modified');
63
+ (0, end_1.default)(client);
64
+ });
65
+ }
66
+ }
67
+ catch (err) {
68
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionError, {
69
+ err,
70
+ observableId: id,
71
+ route,
72
+ });
73
+ }
74
+ if (obs.clients.size === 0) {
75
+ (0, observable_1.destroy)(server, id);
76
+ }
77
+ };
78
+ const httpGet = (route, payload, client, server, checksum) => {
79
+ if (!client.res) {
80
+ return;
81
+ }
82
+ const name = route.name;
83
+ server.functions
84
+ .install(name)
85
+ .then((spec) => {
86
+ if (!client.res) {
87
+ return;
88
+ }
89
+ if (spec && (0, functions_1.isObservableFunctionSpec)(spec)) {
90
+ const id = (0, hash_1.hashObjectIgnoreKeyOrder)([name, payload]);
91
+ if (server.activeObservablesById.has(id)) {
92
+ const obs = server.activeObservablesById.get(id);
93
+ if (obs.beingDestroyed) {
94
+ clearTimeout(obs.beingDestroyed);
95
+ obs.beingDestroyed = null;
96
+ }
97
+ if (obs.cache) {
98
+ sendGetResponse(route, server, id, obs, checksum, client);
99
+ }
100
+ else {
101
+ if (!obs.onNextData) {
102
+ obs.onNextData = new Set();
103
+ }
104
+ obs.onNextData.add(() => {
105
+ sendGetResponse(route, server, id, obs, checksum, client);
106
+ });
107
+ }
108
+ }
109
+ else {
110
+ const obs = (0, observable_1.create)(server, name, id, payload);
111
+ if (!obs.onNextData) {
112
+ obs.onNextData = new Set();
113
+ }
114
+ obs.onNextData.add(() => {
115
+ sendGetResponse(route, server, id, obs, checksum, client);
116
+ });
117
+ }
118
+ }
119
+ else if (spec && (0, functions_1.isObservableFunctionSpec)(spec)) {
120
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionIsNotObservable, route);
121
+ }
122
+ else {
123
+ (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route);
124
+ }
125
+ })
126
+ .catch(() => (0, send_1.sendHttpError)(server, client, error_1.BasedErrorCode.FunctionNotFound, route));
127
+ };
128
+ exports.httpGet = httpGet;
129
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../../../src/network/http/get.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA0D;AAG1D,gD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} from '../../server';
3
+ export declare const httpHandler: (server: BasedServer, req: uws.HttpRequest, res: uws.HttpResponse) => void;