fix(core): update

This commit is contained in:
Philipp Kunz 2023-11-03 00:47:42 +01:00
parent fdd1c7cdb3
commit 81694cf58c
3 changed files with 19 additions and 1 deletions

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@push.rocks/smartrequest',
version: '2.0.18',
version: '2.0.19',
description: 'dropin replacement for request'
}

View File

@ -5,3 +5,4 @@ export type { ISmartRequestOptions } from './smartrequest.interfaces.js';
export * from './smartrequest.jsonrest.js';
export * from './smartrequest.binaryrest.js';
export * from './smartrequest.formdata.js';
export * from './smartrequest.stream.js';

17
ts/smartrequest.stream.ts Normal file
View File

@ -0,0 +1,17 @@
import * as plugins from './smartrequest.plugins.js';
import * as interfaces from './smartrequest.interfaces.js';
import { request } from './smartrequest.request.js';
export const getStream = async (
urlArg: string,
optionsArg: interfaces.ISmartRequestOptions = {}
): Promise<plugins.http.IncomingMessage> => {
try {
// Call the existing request function with responseStreamArg set to true.
const responseStream = await request(urlArg, optionsArg, true);
return responseStream;
} catch (err) {
console.error('An error occurred while getting the stream:', err);
throw err; // Rethrow the error to be handled by the caller.
}
};