Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hqoss/http-client

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hqoss/http-client - npm Package Compare versions

Comparing version 0.1.19-0 to 0.1.20-0

3

dist/lib/httpClient/httpClient.d.ts

@@ -5,6 +5,7 @@ /// <reference types="node" />

import { Readable } from "stream";
import { Method, ConsumedResponse } from "./types";
import { ConsumedResponse, Method, RequestInterceptor } from "./types";
declare class HttpClient {
private baseUrl;
private baseReqOpts?;
willSendRequest?: RequestInterceptor<RequestOptions>;
constructor(baseUrl: string, baseReqOpts?: RequestOptions);

@@ -11,0 +12,0 @@ get: (pathOrUrl: string | URL, reqOpts?: RequestOptions | undefined, telemetry?: EventEmitter | undefined) => Promise<ConsumedResponse<Buffer>>;

@@ -37,2 +37,5 @@ "use strict";

const req = http_1.request(url, opts);
if (this.willSendRequest) {
this.willSendRequest(url, opts);
}
telemetry === null || telemetry === void 0 ? void 0 : telemetry.emit(telemetry_1.EventType.RequestStreamInitialised, new telemetry_1.TelemetryEvent(telemetry_1.EventType.RequestStreamInitialised, { url, opts }));

@@ -39,0 +42,0 @@ req.once("socket", (socket) => {

@@ -6,5 +6,5 @@ /// <reference types="node" />

export declare const toBufferResponse: (response: IncomingMessage) => Promise<ConsumedResponse<Buffer>>;
export declare const toJSONResponse: <T = any>(response: IncomingMessage) => Promise<ConsumedResponse<T>>;
export declare const toJSONResponse: <T = any>(response: ConsumedResponse<Buffer> | IncomingMessage) => Promise<ConsumedResponse<T>>;
export declare const readableToBuffer: (source: Readable) => Promise<Buffer>;
export declare const getStatusClass: (statusCode?: number | undefined) => StatusClass;
//# sourceMappingURL=transform.d.ts.map

@@ -21,3 +21,10 @@ "use strict";

exports.toJSONResponse = async (response) => {
const { data, ...rest } = await exports.toBufferResponse(response);
let consumedResponse;
if (response instanceof http_1.IncomingMessage) {
consumedResponse = await exports.toBufferResponse(response);
}
else {
consumedResponse = response;
}
const { data, ...rest } = consumedResponse;
if (Buffer.byteLength(data) === 0) {

@@ -24,0 +31,0 @@ throw new TypeError("cannot convert empty buffer to JSON");

/// <reference types="node" />
import type { ClientRequest, IncomingHttpHeaders } from "http";
import type { IncomingHttpHeaders } from "http";
import type { Readable } from "stream";

@@ -25,3 +25,3 @@ export declare type Consumable = Readable | Buffer | string;

};
export declare type RequestInterceptor = (url: URL, request: ClientRequest) => void;
export declare type RequestInterceptor<T> = (url: URL, opts: T) => void;
//# sourceMappingURL=types.d.ts.map

@@ -5,6 +5,7 @@ /// <reference types="node" />

import { Readable } from "stream";
import { Method, ConsumedResponse } from "../httpClient/types";
import { ConsumedResponse, Method, RequestInterceptor } from "../httpClient/types";
declare class HttpsClient {
private baseUrl;
private baseReqOpts?;
willSendRequest?: RequestInterceptor<RequestOptions>;
constructor(baseUrl: string, baseReqOpts?: RequestOptions);

@@ -11,0 +12,0 @@ get: (pathOrUrl: string | URL, reqOpts?: RequestOptions | undefined, telemetry?: EventEmitter | undefined) => Promise<ConsumedResponse<Buffer>>;

@@ -37,2 +37,5 @@ "use strict";

const req = https_1.request(url, opts);
if (this.willSendRequest) {
this.willSendRequest(url, opts);
}
telemetry === null || telemetry === void 0 ? void 0 : telemetry.emit(telemetry_1.EventType.RequestStreamInitialised, new telemetry_1.TelemetryEvent(telemetry_1.EventType.RequestStreamInitialised, { url, opts }));

@@ -39,0 +42,0 @@ req.once("socket", (socket) => {

@@ -6,3 +6,8 @@ import { EventEmitter } from "events";

import { EventType, TelemetryEvent } from "./telemetry";
import { Method, ConsumedResponse, Consumable } from "./types";
import {
ConsumedResponse,
Consumable,
Method,
RequestInterceptor,
} from "./types";
import { toBufferResponse } from "./transform";

@@ -13,2 +18,3 @@

private baseReqOpts?: RequestOptions;
willSendRequest?: RequestInterceptor<RequestOptions>;

@@ -93,2 +99,6 @@ constructor(baseUrl: string, baseReqOpts?: RequestOptions) {

if (this.willSendRequest) {
this.willSendRequest(url, opts);
}
telemetry?.emit(

@@ -95,0 +105,0 @@ EventType.RequestStreamInitialised,

@@ -26,6 +26,14 @@ import { IncomingMessage } from "http";

export const toJSONResponse = async <T = any>(
response: IncomingMessage,
response: ConsumedResponse<Buffer> | IncomingMessage,
): Promise<ConsumedResponse<T>> => {
const { data, ...rest } = await toBufferResponse(response);
let consumedResponse: ConsumedResponse<Buffer>;
if (response instanceof IncomingMessage) {
consumedResponse = await toBufferResponse(response);
} else {
consumedResponse = response;
}
const { data, ...rest } = consumedResponse;
if (Buffer.byteLength(data) === 0) {

@@ -32,0 +40,0 @@ throw new TypeError("cannot convert empty buffer to JSON");

@@ -1,2 +0,2 @@

import type { ClientRequest, IncomingHttpHeaders } from "http";
import type { IncomingHttpHeaders } from "http";
import type { Readable } from "stream";

@@ -30,2 +30,2 @@

export type RequestInterceptor = (url: URL, request: ClientRequest) => void;
export type RequestInterceptor<T> = (url: URL, opts: T) => void;

@@ -6,3 +6,8 @@ import { EventEmitter } from "events";

import { EventType, TelemetryEvent } from "../httpClient/telemetry";
import { Method, ConsumedResponse, Consumable } from "../httpClient/types";
import {
ConsumedResponse,
Consumable,
Method,
RequestInterceptor,
} from "../httpClient/types";
import { toBufferResponse } from "../httpClient/transform";

@@ -13,2 +18,3 @@

private baseReqOpts?: RequestOptions;
willSendRequest?: RequestInterceptor<RequestOptions>;

@@ -93,2 +99,6 @@ constructor(baseUrl: string, baseReqOpts?: RequestOptions) {

if (this.willSendRequest) {
this.willSendRequest(url, opts);
}
telemetry?.emit(

@@ -95,0 +105,0 @@ EventType.RequestStreamInitialised,

{
"name": "@hqoss/http-client",
"version": "0.1.19-0",
"version": "0.1.20-0",
"description": "A light-weight, performant, composable blueprint for writing consistent and re-usable Node.js HTTP clients",

@@ -5,0 +5,0 @@ "main": "./dist/lib/index.js",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc