From 531123346fc2b9f0a6e767fec433afce6f514cff Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Wed, 10 Nov 2021 10:05:28 +0200 Subject: [PATCH] refactor: createAddStream --- lib/solr.ts | 15 +++++++++------ package.json | 2 -- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/lib/solr.ts b/lib/solr.ts index 812bf0a..31e57ef 100644 --- a/lib/solr.ts +++ b/lib/solr.ts @@ -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'; @@ -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'); @@ -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 + }) + ) } /** diff --git a/package.json b/package.json index b5c260f..ededa46 100644 --- a/package.json +++ b/package.json @@ -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" },