@exceptionless/fetchclient
Advanced tools
Comparing version 0.12.0 to 0.13.0
@@ -14,13 +14,36 @@ import { defaultInstance, } from "./src/FetchClientProvider.js"; | ||
export const defaultProvider = defaultInstance; | ||
/** | ||
* Sets the default base URL for the FetchClient. | ||
* @param baseUrl - The base URL to use for requests. | ||
*/ | ||
export function setDefaultBaseUrl(baseUrl) { | ||
defaultProvider.setDefaultBaseUrl(baseUrl); | ||
} | ||
export function setAccessTokenFunc(accessTokenFunc) { | ||
/** | ||
* Sets the default access token function for the FetchClient. | ||
* @param accessTokenFunc - The function that retrieves the access token. | ||
*/ | ||
export function setDefaultAccessTokenFunc(accessTokenFunc) { | ||
defaultProvider.setAccessTokenFunc(accessTokenFunc); | ||
} | ||
/** | ||
* Sets the default model validator function for the FetchClient. | ||
* @param validate - The function that validates the model. | ||
*/ | ||
export function setDefaultModelValidator(validate) { | ||
defaultProvider.setDefaultModelValidator(validate); | ||
} | ||
export function useGlobalMiddleware(middleware) { | ||
/** | ||
* Adds a middleware to the FetchClient. | ||
* @param middleware - The middleware function to be added. | ||
*/ | ||
export function useDefaultMiddleware(middleware) { | ||
defaultProvider.useMiddleware(middleware); | ||
} | ||
/** | ||
* Sets the default request options for the FetchClient. | ||
* @param options - The options to set as the default request options. | ||
*/ | ||
export function setDefaultRequestOptions(options) { | ||
defaultProvider.applyOptions(options); | ||
} |
{ | ||
"name": "@exceptionless/fetchclient", | ||
"version": "0.12.0", | ||
"version": "0.13.0", | ||
"description": "A simple fetch client with middleware support for Deno and the browser.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -17,3 +17,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.useGlobalMiddleware = exports.setDefaultModelValidator = exports.setAccessTokenFunc = exports.setDefaultBaseUrl = exports.defaultProvider = exports.instance = exports.FetchClientProvider = exports.FetchClientCache = exports.ProblemDetails = void 0; | ||
exports.setDefaultRequestOptions = exports.useDefaultMiddleware = exports.setDefaultModelValidator = exports.setDefaultAccessTokenFunc = exports.setDefaultBaseUrl = exports.defaultProvider = exports.instance = exports.FetchClientProvider = exports.FetchClientCache = exports.ProblemDetails = void 0; | ||
const FetchClientProvider_js_1 = require("./src/FetchClientProvider.js"); | ||
@@ -35,2 +35,6 @@ __exportStar(require("./src/FetchClient.js"), exports); | ||
exports.defaultProvider = FetchClientProvider_js_1.defaultInstance; | ||
/** | ||
* Sets the default base URL for the FetchClient. | ||
* @param baseUrl - The base URL to use for requests. | ||
*/ | ||
function setDefaultBaseUrl(baseUrl) { | ||
@@ -40,6 +44,14 @@ exports.defaultProvider.setDefaultBaseUrl(baseUrl); | ||
exports.setDefaultBaseUrl = setDefaultBaseUrl; | ||
function setAccessTokenFunc(accessTokenFunc) { | ||
/** | ||
* Sets the default access token function for the FetchClient. | ||
* @param accessTokenFunc - The function that retrieves the access token. | ||
*/ | ||
function setDefaultAccessTokenFunc(accessTokenFunc) { | ||
exports.defaultProvider.setAccessTokenFunc(accessTokenFunc); | ||
} | ||
exports.setAccessTokenFunc = setAccessTokenFunc; | ||
exports.setDefaultAccessTokenFunc = setDefaultAccessTokenFunc; | ||
/** | ||
* Sets the default model validator function for the FetchClient. | ||
* @param validate - The function that validates the model. | ||
*/ | ||
function setDefaultModelValidator(validate) { | ||
@@ -49,5 +61,17 @@ exports.defaultProvider.setDefaultModelValidator(validate); | ||
exports.setDefaultModelValidator = setDefaultModelValidator; | ||
function useGlobalMiddleware(middleware) { | ||
/** | ||
* Adds a middleware to the FetchClient. | ||
* @param middleware - The middleware function to be added. | ||
*/ | ||
function useDefaultMiddleware(middleware) { | ||
exports.defaultProvider.useMiddleware(middleware); | ||
} | ||
exports.useGlobalMiddleware = useGlobalMiddleware; | ||
exports.useDefaultMiddleware = useDefaultMiddleware; | ||
/** | ||
* Sets the default request options for the FetchClient. | ||
* @param options - The options to set as the default request options. | ||
*/ | ||
function setDefaultRequestOptions(options) { | ||
exports.defaultProvider.applyOptions(options); | ||
} | ||
exports.setDefaultRequestOptions = setDefaultRequestOptions; |
import { type FetchClientProvider } from "./src/FetchClientProvider.js"; | ||
import type { FetchClient } from "./src/FetchClient.js"; | ||
import type { FetchClient, FetchClientOptions } from "./src/FetchClient.js"; | ||
import type { FetchClientMiddleware } from "./src/FetchClientMiddleware.js"; | ||
@@ -21,6 +21,27 @@ import type { ProblemDetails } from "./src/ProblemDetails.js"; | ||
export declare const defaultProvider: FetchClientProvider; | ||
/** | ||
* Sets the default base URL for the FetchClient. | ||
* @param baseUrl - The base URL to use for requests. | ||
*/ | ||
export declare function setDefaultBaseUrl(baseUrl: string): void; | ||
export declare function setAccessTokenFunc(accessTokenFunc: () => string | null): void; | ||
/** | ||
* Sets the default access token function for the FetchClient. | ||
* @param accessTokenFunc - The function that retrieves the access token. | ||
*/ | ||
export declare function setDefaultAccessTokenFunc(accessTokenFunc: () => string | null): void; | ||
/** | ||
* Sets the default model validator function for the FetchClient. | ||
* @param validate - The function that validates the model. | ||
*/ | ||
export declare function setDefaultModelValidator(validate: (model: object | null) => Promise<ProblemDetails | null>): void; | ||
export declare function useGlobalMiddleware(middleware: FetchClientMiddleware): void; | ||
/** | ||
* Adds a middleware to the FetchClient. | ||
* @param middleware - The middleware function to be added. | ||
*/ | ||
export declare function useDefaultMiddleware(middleware: FetchClientMiddleware): void; | ||
/** | ||
* Sets the default request options for the FetchClient. | ||
* @param options - The options to set as the default request options. | ||
*/ | ||
export declare function setDefaultRequestOptions(options: FetchClientOptions): void; | ||
//# sourceMappingURL=mod.d.ts.map |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
103880
2205