From 81694cf58c1d3d6bcc5f4632eb8825727d987786 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 3 Nov 2023 00:47:42 +0100 Subject: [PATCH] fix(core): update --- ts/00_commitinfo_data.ts | 2 +- ts/index.ts | 1 + ts/smartrequest.stream.ts | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 ts/smartrequest.stream.ts diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index aa55742..0284777 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartrequest', - version: '2.0.18', + version: '2.0.19', description: 'dropin replacement for request' } diff --git a/ts/index.ts b/ts/index.ts index e0bc35a..015e3cb 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -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'; diff --git a/ts/smartrequest.stream.ts b/ts/smartrequest.stream.ts new file mode 100644 index 0000000..951f298 --- /dev/null +++ b/ts/smartrequest.stream.ts @@ -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 => { + 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. + } +}; \ No newline at end of file