arcx
Version:
A lightweight, dependency-free fetch utility for APIs and React.
29 lines (28 loc) • 905 B
JavaScript
;
/**
* @module config
* Contains global configuration types, defaults, and
* a function to merge user-defined config.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.globalConfig = void 0;
exports.configureArcX = configureArcX;
/**
* Global configuration object, which can be updated via `configureArcX`.
* Includes default values for convenience.
*/
exports.globalConfig = {
baseUrl: "",
headers: {},
interceptors: {},
};
/**
* Merges user-defined config into the global config. The generic type <T> ensures
* that if you have a consistent response shape for global interceptors, you can
* annotate it here. For most cases, using the default <unknown> is sufficient.
*
* @param config - Partial configuration to be merged with the global configuration.
*/
function configureArcX(config) {
Object.assign(exports.globalConfig, config);
}