New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@lokalise/backend-http-client

Package Overview
Dependencies
Maintainers
0
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@lokalise/backend-http-client - npm Package Compare versions

Comparing version 1.4.0 to 2.0.0

dist/src/client/constants.d.ts

6

dist/index.d.ts

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

export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendPostBinary, httpClient, buildClient, type RequestOptions, type Response, type HttpRequestContext, type ResponseSchema, TEST_OPTIONS, JSON_HEADERS, NO_CONTENT_RESPONSE_SCHEMA, UNKNOWN_RESPONSE_SCHEMA, } from './src/client/httpClient';
export { isResponseStatusError, ResponseStatusError } from './src/errors/ResponseStatusError';
export type { RequestOptions, HttpRequestContext, RequestResultDefinitiveEither, } from './src/client/types';
export { JSON_HEADERS, TEST_OPTIONS, NO_CONTENT_RESPONSE_SCHEMA, } from './src/client/constants';
export { sendPut, sendPutBinary, sendDelete, sendPatch, sendGet, sendPost, sendPostBinary, httpClient, buildClient, } from './src/client/httpClient';
export { isResponseStatusError, ResponseStatusError, } from './src/errors/ResponseStatusError';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseStatusError = exports.isResponseStatusError = exports.UNKNOWN_RESPONSE_SCHEMA = exports.NO_CONTENT_RESPONSE_SCHEMA = exports.JSON_HEADERS = exports.TEST_OPTIONS = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = void 0;
exports.ResponseStatusError = exports.isResponseStatusError = exports.buildClient = exports.httpClient = exports.sendPostBinary = exports.sendPost = exports.sendGet = exports.sendPatch = exports.sendDelete = exports.sendPutBinary = exports.sendPut = exports.NO_CONTENT_RESPONSE_SCHEMA = exports.TEST_OPTIONS = exports.JSON_HEADERS = void 0;
var constants_1 = require("./src/client/constants");
Object.defineProperty(exports, "JSON_HEADERS", { enumerable: true, get: function () { return constants_1.JSON_HEADERS; } });
Object.defineProperty(exports, "TEST_OPTIONS", { enumerable: true, get: function () { return constants_1.TEST_OPTIONS; } });
Object.defineProperty(exports, "NO_CONTENT_RESPONSE_SCHEMA", { enumerable: true, get: function () { return constants_1.NO_CONTENT_RESPONSE_SCHEMA; } });
var httpClient_1 = require("./src/client/httpClient");

@@ -14,6 +18,2 @@ Object.defineProperty(exports, "sendPut", { enumerable: true, get: function () { return httpClient_1.sendPut; } });

Object.defineProperty(exports, "buildClient", { enumerable: true, get: function () { return httpClient_1.buildClient; } });
Object.defineProperty(exports, "TEST_OPTIONS", { enumerable: true, get: function () { return httpClient_1.TEST_OPTIONS; } });
Object.defineProperty(exports, "JSON_HEADERS", { enumerable: true, get: function () { return httpClient_1.JSON_HEADERS; } });
Object.defineProperty(exports, "NO_CONTENT_RESPONSE_SCHEMA", { enumerable: true, get: function () { return httpClient_1.NO_CONTENT_RESPONSE_SCHEMA; } });
Object.defineProperty(exports, "UNKNOWN_RESPONSE_SCHEMA", { enumerable: true, get: function () { return httpClient_1.UNKNOWN_RESPONSE_SCHEMA; } });
var ResponseStatusError_1 = require("./src/errors/ResponseStatusError");

@@ -20,0 +20,0 @@ Object.defineProperty(exports, "isResponseStatusError", { enumerable: true, get: function () { return ResponseStatusError_1.isResponseStatusError; } });

@@ -1,53 +0,13 @@

/// <reference types="node" />
/// <reference types="node" />
import type { Readable } from 'stream';
import type { DefiniteEither } from '@lokalise/node-core';
import type { Readable } from 'node:stream';
import { Client } from 'undici';
import type { FormData } from 'undici';
import type { RequestResult, RetryConfig } from 'undici-retry';
import { z } from 'zod';
type RecordObject = Record<string, any>;
/**
* Technically 204 will send an empty body, but undici-retry defaults to parsing unknown mimetype as text for compatibility reasons, so we should expect to get an empty string here
*/
export declare const NO_CONTENT_RESPONSE_SCHEMA: z.ZodString;
/**
* This schema is to be used when we don't really care about the response type and are prepared to accept any value
*/
export declare const UNKNOWN_RESPONSE_SCHEMA: z.ZodUnknown;
export declare const TEST_OPTIONS: RequestOptions<unknown>;
export type HttpRequestContext = {
reqId: string;
};
export type ResponseSchema<Output = any> = {
parse(data: unknown): Output;
};
export type RequestOptions<T> = {
headers?: RecordObject;
query?: RecordObject;
timeout?: number | null;
throwOnError?: boolean;
reqContext?: HttpRequestContext;
safeParseJson?: boolean;
blobResponseBody?: boolean;
requestLabel: string;
disableKeepAlive?: boolean;
retryConfig?: RetryConfig;
clientOptions?: Client.Options;
responseSchema: ResponseSchema<T>;
validateResponse?: boolean;
};
export type Response<T> = {
body: T;
headers: RecordObject;
statusCode: number;
};
export declare function sendGet<T>(client: Client, path: string, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendDelete<T>(client: Client, path: string, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendPost<T>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendPostBinary<T>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendPut<T>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendPutBinary<T>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
export declare function sendPatch<T>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T>): Promise<DefiniteEither<RequestResult<unknown>, RequestResult<T>>>;
import type { RecordObject, RequestOptions, RequestResultDefinitiveEither } from './types';
export declare function buildClient(baseUrl: string, clientOptions?: Client.Options): Client;
export declare function sendGet<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendDelete<T, IsEmptyResponseExpected extends boolean = true>(client: Client, path: string, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendPost<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendPostBinary<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendPut<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendPutBinary<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: Buffer | Uint8Array | Readable | FormData | null, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare function sendPatch<T, IsEmptyResponseExpected extends boolean = false>(client: Client, path: string, body: RecordObject | undefined, options: RequestOptions<T, IsEmptyResponseExpected>): Promise<RequestResultDefinitiveEither<T, IsEmptyResponseExpected>>;
export declare const httpClient: {

@@ -60,5 +20,1 @@ get: typeof sendGet;

};
export declare const JSON_HEADERS: {
'Content-Type': string;
};
export {};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JSON_HEADERS = exports.httpClient = exports.buildClient = exports.sendPatch = exports.sendPutBinary = exports.sendPut = exports.sendPostBinary = exports.sendPost = exports.sendDelete = exports.sendGet = exports.TEST_OPTIONS = exports.UNKNOWN_RESPONSE_SCHEMA = exports.NO_CONTENT_RESPONSE_SCHEMA = void 0;
exports.httpClient = void 0;
exports.buildClient = buildClient;
exports.sendGet = sendGet;
exports.sendDelete = sendDelete;
exports.sendPost = sendPost;
exports.sendPostBinary = sendPostBinary;
exports.sendPut = sendPut;
exports.sendPutBinary = sendPutBinary;
exports.sendPatch = sendPatch;
const node_core_1 = require("@lokalise/node-core");
const undici_1 = require("undici");
const undici_retry_1 = require("undici-retry");
const zod_1 = require("zod");
const ResponseStatusError_1 = require("../errors/ResponseStatusError");
/**
* Technically 204 will send an empty body, but undici-retry defaults to parsing unknown mimetype as text for compatibility reasons, so we should expect to get an empty string here
*/
exports.NO_CONTENT_RESPONSE_SCHEMA = zod_1.z.string().length(0);
/**
* This schema is to be used when we don't really care about the response type and are prepared to accept any value
*/
exports.UNKNOWN_RESPONSE_SCHEMA = zod_1.z.unknown();
exports.TEST_OPTIONS = {
requestLabel: 'test',
responseSchema: exports.UNKNOWN_RESPONSE_SCHEMA,
};
const DEFAULT_OPTIONS = {
validateResponse: true,
throwOnError: true,
timeout: 30000,
};
const defaultClientOptions = {
keepAliveMaxTimeout: 300_000,
keepAliveTimeout: 4000,
};
const constants_1 = require("./constants");
function buildClient(baseUrl, clientOptions) {
return new undici_1.Client(baseUrl, {
...constants_1.defaultClientOptions,
...clientOptions,
});
}
async function sendGet(client, path, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -41,12 +34,11 @@ method: 'GET',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendGet = sendGet;
async function sendDelete(client, path, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path,

@@ -60,12 +52,11 @@ method: 'DELETE',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? true);
}
exports.sendDelete = sendDelete;
async function sendPost(client, path, body, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -80,12 +71,11 @@ method: 'POST',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendPost = sendPost;
async function sendPostBinary(client, path, body, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -100,12 +90,11 @@ method: 'POST',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendPostBinary = sendPostBinary;
async function sendPut(client, path, body, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -120,12 +109,11 @@ method: 'PUT',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendPut = sendPut;
async function sendPutBinary(client, path, body, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -140,12 +128,11 @@ method: 'PUT',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendPutBinary = sendPutBinary;
async function sendPatch(client, path, body, options) {
const result = await (0, undici_retry_1.sendWithRetry)(client, {
...DEFAULT_OPTIONS,
...constants_1.DEFAULT_OPTIONS,
path: path,

@@ -160,9 +147,8 @@ method: 'PATCH',

reset: options.disableKeepAlive ?? false,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : DEFAULT_OPTIONS.timeout,
bodyTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
headersTimeout: Object.hasOwn(options, 'timeout') ? options.timeout : constants_1.DEFAULT_OPTIONS.timeout,
throwOnError: false,
}, resolveRetryConfig(options), resolveRequestConfig(options));
return resolveResult(result, options.throwOnError ?? DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel);
return resolveResult(result, options.throwOnError ?? constants_1.DEFAULT_OPTIONS.throwOnError, options.validateResponse ?? constants_1.DEFAULT_OPTIONS.validateResponse, options.responseSchema, options.requestLabel, options.isEmptyResponseExpected ?? false);
}
exports.sendPatch = sendPatch;
function resolveRequestConfig(options) {

@@ -179,28 +165,30 @@ return {

}
function buildClient(baseUrl, clientOptions) {
const newClient = new undici_1.Client(baseUrl, {
...defaultClientOptions,
...clientOptions,
});
return newClient;
}
exports.buildClient = buildClient;
function resolveResult(requestResult, throwOnError, validateResponse, validationSchema, requestLabel) {
function resolveResult(requestResult, throwOnError, validateResponse, validationSchema, requestLabel, isEmptyResponseExpected) {
// Throw response error
if (requestResult.error && throwOnError) {
if ((0, undici_retry_1.isRequestResult)(requestResult.error)) {
throw new ResponseStatusError_1.ResponseStatusError(requestResult.error, requestLabel);
}
throw requestResult.error;
throw (0, undici_retry_1.isRequestResult)(requestResult.error)
? new ResponseStatusError_1.ResponseStatusError(requestResult.error, requestLabel)
: requestResult.error;
}
if (requestResult.result && validateResponse) {
if (requestResult.result) {
requestResult.result = handleRequestResultSuccess(requestResult.result, validateResponse, validationSchema, requestLabel, isEmptyResponseExpected);
}
return requestResult;
}
function handleRequestResultSuccess(result, validateResponse, validationSchema, requestLabel, isEmptyResponseExpected) {
if (result.statusCode === 204 && isEmptyResponseExpected) {
// @ts-ignore
result.body = null;
return result;
}
if (validateResponse) {
try {
requestResult.result.body = validationSchema.parse(requestResult.result.body);
// @ts-ignore
result.body = validationSchema.parse(result.body);
}
catch (err) {
// @ts-ignore
for (const issue of err.issues) {
// @ts-ignore
issue.requestLabel = requestLabel;
}
// @ts-ignore
err.requestLabel = requestLabel;

@@ -210,3 +198,3 @@ throw err;

}
return requestResult;
return result;
}

@@ -220,5 +208,2 @@ exports.httpClient = {

};
exports.JSON_HEADERS = {
'Content-Type': 'application/json',
};
//# sourceMappingURL=httpClient.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ResponseStatusError = exports.isResponseStatusError = void 0;
exports.ResponseStatusError = void 0;
exports.isResponseStatusError = isResponseStatusError;
const node_core_1 = require("@lokalise/node-core");

@@ -8,8 +9,7 @@ function isResponseStatusError(entity) {

}
exports.isResponseStatusError = isResponseStatusError;
class ResponseStatusError extends node_core_1.InternalError {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
response;
isResponseStatusError = true;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
constructor(requestResult, requestLabel = 'N/A') {

@@ -16,0 +16,0 @@ super({

{
"name": "@lokalise/backend-http-client",
"version": "1.4.0",
"author": {
"name": "Lokalise",
"url": "https://lokalise.com/"
},
"homepage": "https://github.com/lokalise/backend-http-client",
"repository": {
"type": "git",
"url": "git://github.com/lokalise/backend-http-client.git"
},
"license": "Apache-2.0",
"files": [
"dist/**",
"LICENSE.md",
"README.md"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "commonjs",
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc",
"test": "vitest",
"test:coverage": "vitest --coverage",
"test:ci": "npm run lint && npm run test:coverage",
"test:update-snapshots": "vitest -u",
"lint": "eslint . --ext .ts && prettier --check --log-level warn \"**/*.{json,md,ts}\" !CHANGELOG.md",
"lint:fix": "eslint . --fix && prettier --write --log-level warn \"**/*.{json,md,ts}\" !CHANGELOG.md",
"version": "auto-changelog -p && git add CHANGELOG.md",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@lokalise/node-core": "^10.0.0",
"undici": "^6.18.2",
"undici-retry": "^5.0.3",
"zod": "^3.23.8"
},
"devDependencies": {
"@lokalise/prettier-config": "latest",
"@types/node": "^20.14.2",
"@typescript-eslint/eslint-plugin": "^7.12.0",
"@typescript-eslint/parser": "^7.12.0",
"@vitest/coverage-v8": "1.6.0",
"auto-changelog": "^2.4.0",
"eslint": "^8.57.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-vitest": "0.4.1",
"prettier": "^3.3.2",
"typescript": "^5.4.5",
"vitest": "1.6.0"
},
"prettier": "@lokalise/prettier-config"
"name": "@lokalise/backend-http-client",
"version": "2.0.0",
"author": {
"name": "Lokalise",
"url": "https://lokalise.com/"
},
"homepage": "https://github.com/lokalise/backend-http-client",
"repository": {
"type": "git",
"url": "git://github.com/lokalise/backend-http-client.git"
},
"license": "Apache-2.0",
"files": [
"dist/**",
"LICENSE.md",
"README.md"
],
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "commonjs",
"private": false,
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsc",
"test": "vitest",
"test:coverage": "vitest --coverage",
"test:ci": "npm run lint && npm run test:coverage",
"test:update-snapshots": "vitest -u",
"lint": "biome check . && tsc --project tsconfig.lint.json --noEmit",
"lint:fix": "biome check --write",
"package-version": "auto-changelog -p && git add CHANGELOG.md",
"prepublishOnly": "npm run build"
},
"dependencies": {
"@lokalise/node-core": "^10.0.1",
"undici": "^6.19.2",
"undici-retry": "^5.0.3",
"zod": "^3.23.8"
},
"devDependencies": {
"@biomejs/biome": "^1.8.3",
"@lokalise/biome-config": "^1.0.0",
"@types/node": "^20.14.10",
"@vitest/coverage-v8": "^2.0.1",
"auto-changelog": "^2.4.0",
"typescript": "^5.5.3",
"vitest": "^2.0.1"
}
}

@@ -46,2 +46,3 @@ # backend-http-client 🧬

- `validateResponse`;
- `isEmptyResponseExpected`, used to specify if a 204 response should be treated as an error or not. when `true` the response body type is adjusted to include potential `null`

@@ -61,2 +62,3 @@ The following options are applied by default:

```
For `sendDelete()` `isEmptyResponseExpected` by default is set to `true`, for all other methods it is `false`.

@@ -63,0 +65,0 @@ Additionally, `sendPost()`, `sendPut()`, `sendPutBinary()`, and `sendPatch()` also accept a `body` parameter.

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