Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@nomalism-com/api

Package Overview
Dependencies
Maintainers
2
Versions
2562
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nomalism-com/api - npm Package Compare versions

Comparing version
0.45.63
to
0.45.64
+52
dist/lib/apiError.d.ts
/**
* Where the failure happened in the axios lifecycle.
*
* - `response` — the server replied with a non-2xx status (HTTP / application layer).
* - `request` — the request was sent but no response came back (network, timeout, CORS, offline).
* - `setup` — the request was never sent (bad config, invalid URL, serialization error).
* - `unknown` — the thrown value was not an axios error at all.
*/
export type ApiErrorKind = 'response' | 'request' | 'setup' | 'unknown';
export interface IApiErrorFields {
kind: ApiErrorKind;
message: string;
status?: number;
code?: string;
method?: string;
url?: string;
data?: unknown;
}
/**
* A compact, log-friendly error that replaces axios's huge error object.
*
* Only small primitives are kept as enumerable fields, so `console.log(err)`,
* `JSON.stringify(err)` and `err.stack` stay short. The original axios error is
* preserved on a NON-enumerable `cause` property — available for deep debugging,
* but never dumped when the error is logged.
*/
export declare class ApiError extends Error {
readonly kind: ApiErrorKind;
/** HTTP status code, when the server responded. */
readonly status?: number;
/** Axios error code, e.g. 'ECONNABORTED', 'ERR_NETWORK', 'ERR_BAD_REQUEST'. */
readonly code?: string;
/** HTTP method of the failed request, uppercased. */
readonly method?: string;
/** Request URL (baseURL + path) of the failed request. */
readonly url?: string;
/** The server-provided error payload (response body), when present. */
readonly data?: unknown;
constructor(fields: IApiErrorFields, cause?: unknown);
/** Controls what `JSON.stringify(err)` and most loggers emit — kept compact. */
toJSON(): IApiErrorFields;
}
/** Type guard for the simplified error. */
export declare function isApiError(error: unknown): error is ApiError;
/**
* Convert ANY thrown value into a compact {@link ApiError}.
*
* This is the single, DRY place that understands axios's four failure modes,
* so individual modules never have to inspect `error.response` / `error.request`
* themselves.
*/
export declare function parseApiError(error: unknown): ApiError;
+2
-0
import * as Nomalism from './main';
export { ApiError, isApiError, parseApiError } from './lib/apiError';
export type { ApiErrorKind, IApiErrorFields } from './lib/apiError';
export default Nomalism;
+1
-1
{
"name": "@nomalism-com/api",
"description": "A nomalism API package for performing HTTP requests on API endpoints",
"version": "0.45.63",
"version": "0.45.64",
"author": "Nomalism <it.nomalism@gmail.com> (https://https://nomalism.com/)",

@@ -6,0 +6,0 @@ "license": "UNLICENSED",

Sorry, the diff of this file is too big to display