@orion-js/http 3.8.0 → 3.10.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.
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,43 @@
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
+ const start_1 = require("./../start");
7
+ const route_1 = __importDefault(require("./route"));
8
+ const registerRoute_1 = __importDefault(require("./registerRoute"));
9
+ const supertest_1 = __importDefault(require("supertest"));
10
+ const lodash_1 = require("lodash");
11
+ const helpers_1 = require("@orion-js/helpers");
12
+ const app = (0, start_1.getApp)();
13
+ describe('Test streaming responses', () => {
14
+ it('Should be able to send a streaming response', async () => {
15
+ const testRoute = (0, route_1.default)({
16
+ path: '/test-streaming',
17
+ method: 'get',
18
+ async resolve(_req, res) {
19
+ for (const i of (0, lodash_1.range)(5)) {
20
+ res.write(`data: ${JSON.stringify({ count: i })}\n\n`); // "data:" is important here
21
+ await (0, helpers_1.sleep)(100);
22
+ }
23
+ res.end();
24
+ },
25
+ });
26
+ (0, registerRoute_1.default)(testRoute);
27
+ const response = await (0, supertest_1.default)(app)
28
+ .get('/test-streaming')
29
+ .parse((res, callback) => {
30
+ let data = '';
31
+ res.setEncoding('binary');
32
+ res.on('data', chunk => {
33
+ console.log('got chunk', chunk);
34
+ data += chunk;
35
+ });
36
+ res.on('end', () => {
37
+ callback(null, '');
38
+ });
39
+ });
40
+ const body = response.body;
41
+ console.log(body);
42
+ });
43
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/http",
3
- "version": "3.8.0",
3
+ "version": "3.10.0",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "files": [
@@ -17,11 +17,11 @@
17
17
  "upgrade-interactive": "yarn upgrade-interactive"
18
18
  },
19
19
  "dependencies": {
20
- "@orion-js/env": "^3.8.0",
21
- "@orion-js/helpers": "^3.7.4",
22
- "@orion-js/resolvers": "^3.7.4",
23
- "@orion-js/schema": "^3.7.4",
24
- "@orion-js/services": "^3.7.4",
20
+ "@orion-js/env": "^3.10.0",
21
+ "@orion-js/helpers": "^3.10.0",
22
+ "@orion-js/resolvers": "^3.10.0",
23
+ "@orion-js/schema": "^3.10.0",
24
+ "@orion-js/services": "^3.10.0",
25
25
  "body-parser": "1.19.0",
26
26
  "express": "4.17.1",
27
27
  "reflect-metadata": "^0.1.13"
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "05bb0f7c0679b17993a2375332804d745dd49ba2"
45
+ "gitHead": "68036a0293066cc23feb3000ab44e58600540615"
46
46
  }