Skip to content

Commit 5311233

Browse files
committed
refactor: createAddStream
1 parent 312f8df commit 5311233

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

lib/solr.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as querystring from 'querystring';
22
import * as JSONStream from 'JSONStream';
3-
import * as duplexer from 'duplexer';
43
import { Query } from './query';
54
import { Collection } from './collection';
65
import * as versionUtils from './utils/version';
@@ -15,8 +14,9 @@ import {
1514
} from './types';
1615
import { Duplex } from 'stream';
1716
import { request } from 'undici';
17+
import undici from 'undici';
18+
import stream from 'stream';
1819

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

@@ -300,10 +300,13 @@ export class Client {
300300
method: 'POST',
301301
headers: headers,
302302
};
303-
const jsonStreamStringify = JSONStream.stringify();
304-
const postRequest = oldRequest(optionsRequest);
305-
jsonStreamStringify.pipe(postRequest);
306-
return duplexer(jsonStreamStringify, postRequest);
303+
return stream.compose(
304+
JSONStream.stringify(),
305+
undici.pipeline(optionsRequest.url, optionsRequest, ({ statusCode, headers, body }) => {
306+
// TODO:
307+
return body
308+
})
309+
)
307310
}
308311

309312
/**

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,9 @@
2424
"node": ">= 12"
2525
},
2626
"dependencies": {
27-
"duplexer": "^0.1.2",
2827
"hnp": "^1.0.1",
2928
"json-bigint": "^1.0.0",
3029
"JSONStream": "^1.3.5",
31-
"request": "^2.88.2",
3230
"tslib": "^2.3.1",
3331
"undici": "^4.7.1"
3432
},

0 commit comments

Comments
 (0)