jinaga-server 3.0.1 → 3.1.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 (35) hide show
  1. package/dist/http/line-reader.d.ts +2 -0
  2. package/dist/http/line-reader.js +68 -0
  3. package/dist/http/line-reader.js.map +1 -0
  4. package/dist/http/router.d.ts +4 -1
  5. package/dist/http/router.js +142 -21
  6. package/dist/http/router.js.map +1 -1
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +3 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/jinaga-server.d.ts +1 -0
  11. package/dist/jinaga-server.js +1 -1
  12. package/dist/jinaga-server.js.map +1 -1
  13. package/http/sans-auth/Feeds options.http +1 -0
  14. package/http/sans-auth/Load json.http +64 -0
  15. package/http/sans-auth/Save graph.http +6 -0
  16. package/http/sans-auth/Save json.http +13 -0
  17. package/http/with-auth/Create post with auth.http +24 -0
  18. package/http/with-auth/Define authorization rules.http +25 -0
  19. package/http/with-auth/Define distribution rules.http +30 -0
  20. package/http/with-auth/Feed sites.http +3 -0
  21. package/http/with-auth/Feeds options.http +1 -0
  22. package/http/with-auth/Feeds sites.http +32 -0
  23. package/http/with-auth/Get posts with auth.http +32 -0
  24. package/http/with-auth/Load titles.http +21 -0
  25. package/integration-test/jinaga-test/Dockerfile +1 -1
  26. package/integration-test/jinaga-test/package-lock.json +143 -55
  27. package/integration-test/jinaga-test/package.json +2 -2
  28. package/package.json +3 -3
  29. package/replicator/index.ts +0 -2
  30. package/replicator/package-lock.json +157 -86
  31. package/replicator/package.json +1 -3
  32. package/src/http/line-reader.ts +69 -0
  33. package/src/http/router.ts +180 -27
  34. package/src/index.ts +1 -0
  35. package/src/jinaga-server.ts +2 -1
@@ -9,12 +9,10 @@
9
9
  "version": "1.0.0",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
- "cors": "^2.8.5",
13
- "express": "^4.18.1",
14
- "pg": "^8.11.3"
12
+ "express": "^4.19.2",
13
+ "pg": "8.11.3"
15
14
  },
16
15
  "devDependencies": {
17
- "@types/cors": "^2.8.12",
18
16
  "@types/express": "^4.17.13",
19
17
  "typescript": "^4.7.4"
20
18
  }
@@ -38,23 +36,14 @@
38
36
  "@types/node": "*"
39
37
  }
40
38
  },
41
- "node_modules/@types/cors": {
42
- "version": "2.8.13",
43
- "resolved": "https://registry.npmjs.org/@types/cors/-/cors-2.8.13.tgz",
44
- "integrity": "sha512-RG8AStHlUiV5ysZQKq97copd2UmVYw3/pRMLefISZ3S1hK104Cwm7iLQ3fTKx+lsUH2CE8FlLaYeEA2LSeqYUA==",
45
- "dev": true,
46
- "dependencies": {
47
- "@types/node": "*"
48
- }
49
- },
50
39
  "node_modules/@types/express": {
51
- "version": "4.17.16",
52
- "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.16.tgz",
53
- "integrity": "sha512-LkKpqRZ7zqXJuvoELakaFYuETHjZkSol8EV6cNnyishutDBCCdv6+dsKPbKkCcIk57qRphOLY5sEgClw1bO3gA==",
40
+ "version": "4.17.21",
41
+ "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.21.tgz",
42
+ "integrity": "sha512-ejlPM315qwLpaQlQDTjPdsUFSc6ZsP4AN6AlWnogPjQ7CVi7PYF3YVz+CY3jE2pwYf7E/7HlDAN0rV2GxTG0HQ==",
54
43
  "dev": true,
55
44
  "dependencies": {
56
45
  "@types/body-parser": "*",
57
- "@types/express-serve-static-core": "^4.17.31",
46
+ "@types/express-serve-static-core": "^4.17.33",
58
47
  "@types/qs": "*",
59
48
  "@types/serve-static": "*"
60
49
  }
@@ -122,12 +111,12 @@
122
111
  "integrity": "sha512-PCVAQswWemu6UdxsDFFX/+gVeYqKAod3D3UVm91jHwynguOwAvYPhx8nNlM++NqRcK6CxxpUafjmhIdKiHibqg=="
123
112
  },
124
113
  "node_modules/body-parser": {
125
- "version": "1.20.1",
126
- "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.1.tgz",
127
- "integrity": "sha512-jWi7abTbYwajOytWCQc37VulmWiRae5RyTpaCyDcS5/lMdtwSz5lOpDE67srw/HYe35f1z3fDQw+3txg7gNtWw==",
114
+ "version": "1.20.2",
115
+ "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz",
116
+ "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==",
128
117
  "dependencies": {
129
118
  "bytes": "3.1.2",
130
- "content-type": "~1.0.4",
119
+ "content-type": "~1.0.5",
131
120
  "debug": "2.6.9",
132
121
  "depd": "2.0.0",
133
122
  "destroy": "1.2.0",
@@ -135,7 +124,7 @@
135
124
  "iconv-lite": "0.4.24",
136
125
  "on-finished": "2.4.1",
137
126
  "qs": "6.11.0",
138
- "raw-body": "2.5.1",
127
+ "raw-body": "2.5.2",
139
128
  "type-is": "~1.6.18",
140
129
  "unpipe": "1.0.0"
141
130
  },
@@ -161,12 +150,18 @@
161
150
  }
162
151
  },
163
152
  "node_modules/call-bind": {
164
- "version": "1.0.2",
165
- "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz",
166
- "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==",
167
- "dependencies": {
168
- "function-bind": "^1.1.1",
169
- "get-intrinsic": "^1.0.2"
153
+ "version": "1.0.7",
154
+ "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.7.tgz",
155
+ "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==",
156
+ "dependencies": {
157
+ "es-define-property": "^1.0.0",
158
+ "es-errors": "^1.3.0",
159
+ "function-bind": "^1.1.2",
160
+ "get-intrinsic": "^1.2.4",
161
+ "set-function-length": "^1.2.1"
162
+ },
163
+ "engines": {
164
+ "node": ">= 0.4"
170
165
  },
171
166
  "funding": {
172
167
  "url": "https://github.com/sponsors/ljharb"
@@ -184,17 +179,17 @@
184
179
  }
185
180
  },
186
181
  "node_modules/content-type": {
187
- "version": "1.0.4",
188
- "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz",
189
- "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==",
182
+ "version": "1.0.5",
183
+ "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.5.tgz",
184
+ "integrity": "sha512-nTjqfcBFEipKdXCv4YDQWCfmcLZKm81ldF0pAopTvyrFGVbcR6P/VAAd5G7N+0tTr8QqiU0tFadD6FK4NtJwOA==",
190
185
  "engines": {
191
186
  "node": ">= 0.6"
192
187
  }
193
188
  },
194
189
  "node_modules/cookie": {
195
- "version": "0.5.0",
196
- "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.5.0.tgz",
197
- "integrity": "sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw==",
190
+ "version": "0.6.0",
191
+ "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz",
192
+ "integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==",
198
193
  "engines": {
199
194
  "node": ">= 0.6"
200
195
  }
@@ -204,18 +199,6 @@
204
199
  "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz",
205
200
  "integrity": "sha512-QADzlaHc8icV8I7vbaJXJwod9HWYp8uCqf1xa4OfNu1T7JVxQIrUgOWtHdNDtPiywmFbiS12VjotIXLrKM3orQ=="
206
201
  },
207
- "node_modules/cors": {
208
- "version": "2.8.5",
209
- "resolved": "https://registry.npmjs.org/cors/-/cors-2.8.5.tgz",
210
- "integrity": "sha512-KIHbLJqu73RGr/hnbrO9uBeixNGuvSQjul/jdFvS/KFSIH1hWVd1ng7zOHx+YrEfInLG7q4n6GHQ9cDtxv/P6g==",
211
- "dependencies": {
212
- "object-assign": "^4",
213
- "vary": "^1"
214
- },
215
- "engines": {
216
- "node": ">= 0.10"
217
- }
218
- },
219
202
  "node_modules/debug": {
220
203
  "version": "2.6.9",
221
204
  "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz",
@@ -224,6 +207,22 @@
224
207
  "ms": "2.0.0"
225
208
  }
226
209
  },
210
+ "node_modules/define-data-property": {
211
+ "version": "1.1.4",
212
+ "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz",
213
+ "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==",
214
+ "dependencies": {
215
+ "es-define-property": "^1.0.0",
216
+ "es-errors": "^1.3.0",
217
+ "gopd": "^1.0.1"
218
+ },
219
+ "engines": {
220
+ "node": ">= 0.4"
221
+ },
222
+ "funding": {
223
+ "url": "https://github.com/sponsors/ljharb"
224
+ }
225
+ },
227
226
  "node_modules/depd": {
228
227
  "version": "2.0.0",
229
228
  "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
@@ -254,6 +253,25 @@
254
253
  "node": ">= 0.8"
255
254
  }
256
255
  },
256
+ "node_modules/es-define-property": {
257
+ "version": "1.0.0",
258
+ "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.0.tgz",
259
+ "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==",
260
+ "dependencies": {
261
+ "get-intrinsic": "^1.2.4"
262
+ },
263
+ "engines": {
264
+ "node": ">= 0.4"
265
+ }
266
+ },
267
+ "node_modules/es-errors": {
268
+ "version": "1.3.0",
269
+ "resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
270
+ "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
271
+ "engines": {
272
+ "node": ">= 0.4"
273
+ }
274
+ },
257
275
  "node_modules/escape-html": {
258
276
  "version": "1.0.3",
259
277
  "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz",
@@ -268,16 +286,16 @@
268
286
  }
269
287
  },
270
288
  "node_modules/express": {
271
- "version": "4.18.2",
272
- "resolved": "https://registry.npmjs.org/express/-/express-4.18.2.tgz",
273
- "integrity": "sha512-5/PsL6iGPdfQ/lKM1UuielYgv3BUoJfz1aUwU9vHZ+J7gyvwdQXFEBIEIaxeGf0GIcreATNyBExtalisDbuMqQ==",
289
+ "version": "4.19.2",
290
+ "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz",
291
+ "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==",
274
292
  "dependencies": {
275
293
  "accepts": "~1.3.8",
276
294
  "array-flatten": "1.1.1",
277
- "body-parser": "1.20.1",
295
+ "body-parser": "1.20.2",
278
296
  "content-disposition": "0.5.4",
279
297
  "content-type": "~1.0.4",
280
- "cookie": "0.5.0",
298
+ "cookie": "0.6.0",
281
299
  "cookie-signature": "1.0.6",
282
300
  "debug": "2.6.9",
283
301
  "depd": "2.0.0",
@@ -342,32 +360,62 @@
342
360
  }
343
361
  },
344
362
  "node_modules/function-bind": {
345
- "version": "1.1.1",
346
- "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz",
347
- "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A=="
363
+ "version": "1.1.2",
364
+ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
365
+ "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
366
+ "funding": {
367
+ "url": "https://github.com/sponsors/ljharb"
368
+ }
348
369
  },
349
370
  "node_modules/get-intrinsic": {
350
- "version": "1.2.0",
351
- "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz",
352
- "integrity": "sha512-L049y6nFOuom5wGyRc3/gdTLO94dySVKRACj1RmJZBQXlbTMhtNIgkWkUHq+jYmZvKf14EW1EoJnnjbmoHij0Q==",
371
+ "version": "1.2.4",
372
+ "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.4.tgz",
373
+ "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==",
374
+ "dependencies": {
375
+ "es-errors": "^1.3.0",
376
+ "function-bind": "^1.1.2",
377
+ "has-proto": "^1.0.1",
378
+ "has-symbols": "^1.0.3",
379
+ "hasown": "^2.0.0"
380
+ },
381
+ "engines": {
382
+ "node": ">= 0.4"
383
+ },
384
+ "funding": {
385
+ "url": "https://github.com/sponsors/ljharb"
386
+ }
387
+ },
388
+ "node_modules/gopd": {
389
+ "version": "1.0.1",
390
+ "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.0.1.tgz",
391
+ "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==",
353
392
  "dependencies": {
354
- "function-bind": "^1.1.1",
355
- "has": "^1.0.3",
356
- "has-symbols": "^1.0.3"
393
+ "get-intrinsic": "^1.1.3"
357
394
  },
358
395
  "funding": {
359
396
  "url": "https://github.com/sponsors/ljharb"
360
397
  }
361
398
  },
362
- "node_modules/has": {
363
- "version": "1.0.3",
364
- "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz",
365
- "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==",
399
+ "node_modules/has-property-descriptors": {
400
+ "version": "1.0.2",
401
+ "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz",
402
+ "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==",
366
403
  "dependencies": {
367
- "function-bind": "^1.1.1"
404
+ "es-define-property": "^1.0.0"
368
405
  },
406
+ "funding": {
407
+ "url": "https://github.com/sponsors/ljharb"
408
+ }
409
+ },
410
+ "node_modules/has-proto": {
411
+ "version": "1.0.3",
412
+ "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.0.3.tgz",
413
+ "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==",
369
414
  "engines": {
370
- "node": ">= 0.4.0"
415
+ "node": ">= 0.4"
416
+ },
417
+ "funding": {
418
+ "url": "https://github.com/sponsors/ljharb"
371
419
  }
372
420
  },
373
421
  "node_modules/has-symbols": {
@@ -381,6 +429,17 @@
381
429
  "url": "https://github.com/sponsors/ljharb"
382
430
  }
383
431
  },
432
+ "node_modules/hasown": {
433
+ "version": "2.0.2",
434
+ "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
435
+ "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
436
+ "dependencies": {
437
+ "function-bind": "^1.1.2"
438
+ },
439
+ "engines": {
440
+ "node": ">= 0.4"
441
+ }
442
+ },
384
443
  "node_modules/http-errors": {
385
444
  "version": "2.0.0",
386
445
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -484,18 +543,10 @@
484
543
  "node": ">= 0.6"
485
544
  }
486
545
  },
487
- "node_modules/object-assign": {
488
- "version": "4.1.1",
489
- "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
490
- "integrity": "sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==",
491
- "engines": {
492
- "node": ">=0.10.0"
493
- }
494
- },
495
546
  "node_modules/object-inspect": {
496
- "version": "1.12.3",
497
- "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.3.tgz",
498
- "integrity": "sha512-geUvdk7c+eizMNUDkRpW1wJwgfOiOeHbxBR/hLXK1aT6zmVSO0jsQcs7fj6MGw89jC/cjGfLcNOrtMYtGqm81g==",
547
+ "version": "1.13.1",
548
+ "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.1.tgz",
549
+ "integrity": "sha512-5qoj1RUiKOMsCCNLV1CBiPYE10sziTsnmNxkAI/rZhiD63CF7IqdFGC/XzjWjpSgLf0LxXX3bDFIh0E18f6UhQ==",
499
550
  "funding": {
500
551
  "url": "https://github.com/sponsors/ljharb"
501
552
  }
@@ -682,9 +733,9 @@
682
733
  }
683
734
  },
684
735
  "node_modules/raw-body": {
685
- "version": "2.5.1",
686
- "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.1.tgz",
687
- "integrity": "sha512-qqJBtEyVgS0ZmPGdCFPWJ3FreoqvG4MVQln/kCgF7Olq95IbOp0/BWyMwbdtn4VTvkM8Y7khCQ2Xgk/tcrCXig==",
736
+ "version": "2.5.2",
737
+ "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.5.2.tgz",
738
+ "integrity": "sha512-8zGqypfENjCIqGhgXToC8aB2r7YrBX+AQAfIPs/Mlk+BtPTztOvTS01NRW/3Eh60J+a48lt8qsCzirQ6loCVfA==",
688
739
  "dependencies": {
689
740
  "bytes": "3.1.2",
690
741
  "http-errors": "2.0.0",
@@ -761,19 +812,39 @@
761
812
  "node": ">= 0.8.0"
762
813
  }
763
814
  },
815
+ "node_modules/set-function-length": {
816
+ "version": "1.2.2",
817
+ "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz",
818
+ "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==",
819
+ "dependencies": {
820
+ "define-data-property": "^1.1.4",
821
+ "es-errors": "^1.3.0",
822
+ "function-bind": "^1.1.2",
823
+ "get-intrinsic": "^1.2.4",
824
+ "gopd": "^1.0.1",
825
+ "has-property-descriptors": "^1.0.2"
826
+ },
827
+ "engines": {
828
+ "node": ">= 0.4"
829
+ }
830
+ },
764
831
  "node_modules/setprototypeof": {
765
832
  "version": "1.2.0",
766
833
  "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz",
767
834
  "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw=="
768
835
  },
769
836
  "node_modules/side-channel": {
770
- "version": "1.0.4",
771
- "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz",
772
- "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==",
837
+ "version": "1.0.6",
838
+ "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.6.tgz",
839
+ "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==",
773
840
  "dependencies": {
774
- "call-bind": "^1.0.0",
775
- "get-intrinsic": "^1.0.2",
776
- "object-inspect": "^1.9.0"
841
+ "call-bind": "^1.0.7",
842
+ "es-errors": "^1.3.0",
843
+ "get-intrinsic": "^1.2.4",
844
+ "object-inspect": "^1.13.1"
845
+ },
846
+ "engines": {
847
+ "node": ">= 0.4"
777
848
  },
778
849
  "funding": {
779
850
  "url": "https://github.com/sponsors/ljharb"
@@ -15,12 +15,10 @@
15
15
  "author": "Michael L Perry",
16
16
  "license": "MIT",
17
17
  "dependencies": {
18
- "cors": "^2.8.5",
19
- "express": "^4.18.1",
18
+ "express": "^4.19.2",
20
19
  "pg": "8.11.3"
21
20
  },
22
21
  "devDependencies": {
23
- "@types/cors": "^2.8.12",
24
22
  "@types/express": "^4.17.13",
25
23
  "typescript": "^4.7.4"
26
24
  }
@@ -0,0 +1,69 @@
1
+ const PauseAt = 10;
2
+ const ResumeAt = 5;
3
+
4
+ export function createLineReader(stream: NodeJS.ReadableStream): () => Promise<string | null> {
5
+ // Store the bytes read so far that have not yet been processed.
6
+ let buffer = Buffer.alloc(0);
7
+ // Store a queue of promises that resolve to the next line read.
8
+ let promiseQueue: Promise<string | null>[] = [];
9
+ // Initialize the queue.
10
+ let resolve: (value: string | null) => void;
11
+ let reject: (reason: any) => void;
12
+ promiseQueue.push(new Promise<string | null>((res, rej) => { resolve = res; reject = rej; }));
13
+
14
+ stream.on('data', (data: Buffer) => {
15
+ let newline = -1;
16
+ // Look for the first newline in the data.
17
+ while ((newline = data.indexOf(10)) >= 0) {
18
+ // Extract the line from the data.
19
+ let line = Buffer.concat([buffer, data.slice(0, newline)]).toString();
20
+ data = data.slice(newline + 1);
21
+ buffer = Buffer.alloc(0);
22
+ if (line.charCodeAt(0) === 0xFEFF) {
23
+ // Remove BOM
24
+ line = line.slice(1);
25
+ }
26
+ // Resolve the promise with the line.
27
+ resolve(line);
28
+ // Create a new promise for the next line.
29
+ promiseQueue.push(new Promise<string | null>((res, rej) => { resolve = res; reject = rej; }));
30
+
31
+ // Apply backpressure if the promise queue gets too deep
32
+ if (promiseQueue.length > PauseAt) {
33
+ stream.pause();
34
+ }
35
+ }
36
+ // Append the remaining data to the buffer.
37
+ buffer = Buffer.concat([buffer, data]);
38
+ });
39
+
40
+ stream.on('end', () => {
41
+ // Extract the last line from the buffer.
42
+ let line = buffer.toString();
43
+ if (line.charCodeAt(0) === 0xFEFF) {
44
+ // Remove BOM
45
+ line = line.slice(1);
46
+ }
47
+ // If the stream ends with a newline, then don't add an empty line.
48
+ if (line.length > 0) {
49
+ resolve(line);
50
+ promiseQueue.push(new Promise<string | null>((res, rej) => { resolve = res; reject = rej; }));
51
+ }
52
+ resolve(null);
53
+ });
54
+
55
+ stream.on('error', (e: Error) => {
56
+ reject(e);
57
+ });
58
+
59
+ return () => {
60
+ if (promiseQueue.length === 0) {
61
+ throw new Error("Line reader has been closed.");
62
+ }
63
+ const promise = promiseQueue.shift()!;
64
+ if (stream.isPaused() && promiseQueue.length <= ResumeAt) {
65
+ stream.resume();
66
+ }
67
+ return promise;
68
+ };
69
+ }