Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions lib/solr.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as querystring from 'querystring';
import * as JSONStream from 'JSONStream';
import * as duplexer from 'duplexer';
import { Query } from './query';
import { Collection } from './collection';
import * as versionUtils from './utils/version';
Expand All @@ -15,8 +14,9 @@ import {
} from './types';
import { Duplex } from 'stream';
import { request } from 'undici';
import undici from 'undici';
import stream from 'stream';

const oldRequest = require('request');
const format = require('./utils/format');
const JSONbig = require('json-bigint');

Expand Down Expand Up @@ -300,10 +300,13 @@ export class Client {
method: 'POST',
headers: headers,
};
const jsonStreamStringify = JSONStream.stringify();
const postRequest = oldRequest(optionsRequest);
jsonStreamStringify.pipe(postRequest);
return duplexer(jsonStreamStringify, postRequest);
return stream.compose(
JSONStream.stringify(),
undici.pipeline(optionsRequest.url, optionsRequest, ({ statusCode, headers, body }) => {
// TODO:
return body
})
)
Comment on lines +303 to +309
Copy link
Copy Markdown
Author

@ronag ronag Nov 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Node 14+

const jsonStreamStringify = JSONStream.stringify();
const req = undici.pipeline(optionsRequest.url, optionsRequest, ({ statusCode, headers, body }) => {
  // TODO: statusCode & headers
  return body;
});
return duplexer(jsonStreamStringify, pipeline(jsonStreamStringify, req, () => {}));

}

/**
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,9 @@
"node": ">= 12"
},
"dependencies": {
"duplexer": "^0.1.2",
"hnp": "^1.0.1",
"json-bigint": "^1.0.0",
"JSONStream": "^1.3.5",
"request": "^2.88.2",
"tslib": "^2.3.1",
"undici": "^4.7.1"
},
Expand Down