Skip to content

Commit

Permalink
style(http): return types
Browse files Browse the repository at this point in the history
  • Loading branch information
seth2810 committed Aug 19, 2024
1 parent dcfd5c4 commit be57d11
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/lib/http/HttpManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import axios, {
AxiosError,
AxiosInstance,
AxiosPromise,
AxiosRequestConfig,
AxiosResponse,
InternalAxiosRequestConfig
} from 'axios';
import { URL, URLSearchParams } from 'url';
Expand Down Expand Up @@ -109,7 +109,7 @@ export class HttpClient {
return client;
}

private async handleError(client: AxiosInstance, err: unknown): Promise<AxiosResponse> {
private async handleError(client: AxiosInstance, err: unknown): AxiosPromise {
if (axios.isCancel(err) || axios.isAxiosError(err) === false || !this.shouldRetryRequest(err)) {
return await Promise.reject(this.extractResponseError(err));
}
Expand Down Expand Up @@ -262,54 +262,54 @@ export class HttpClient {
/**
* @param {string} slug The slug to get.
* @param {{query?: Record<string, string> & AxiosRequestConfig}} config Config.
* @returns {Promise<AxiosResponse>} Returns a promise with the response.
* @returns {AxiosPromise} Returns a promise with the response.
*/
async get(
slug: string,
config?: { query?: Record<string, string> } & AxiosRequestConfig
): Promise<AxiosResponse> {
): AxiosPromise {
return await this.client.get(this.getURL(slug, config?.query), config);
}

/**
* @param {string} slug The slug to post.
* @param {any} data Body data.
* @param {{Record<string, string> & RequestInit}} config Config.
* @returns {Promise<Response>} Returns a promise with the response.
* @returns {AxiosPromise} Returns a promise with the response.
*/
async post(
slug: string,
data: unknown,
config?: { query?: Record<string, string> } & AxiosRequestConfig
): Promise<AxiosResponse> {
): AxiosPromise {
return await this.client.post(this.getURL(slug, config?.query), data, config);
}

/**
* @param {string} slug The slug to put.
* @param {any} data Body data.
* @param {{Record<string, string> & RequestInit}} config Config.
* @returns {Promise<Response>} Returns a promise with the response.
* @returns {AxiosPromise} Returns a promise with the response.
*/
async put(
slug: string,
data: unknown,
config?: { query?: Record<string, string> } & AxiosRequestConfig
): Promise<AxiosResponse> {
): AxiosPromise {
return await this.client.put(this.getURL(slug, config?.query), data, config);
}

/**
* @param {string} slug The slug to delete.
* @param {unknown} data Body data.
* @param {{Record<string, string> & RequestInit}} config Config.
* @returns {Promise<Response>} Returns a promise with the response.
* @returns {AxiosPromise} Returns a promise with the response.
*/
async delete(
slug: string,
data: unknown,
config?: { query?: Record<string, string> } & AxiosRequestConfig
): Promise<AxiosResponse> {
): AxiosPromise {
return await this.client.delete(this.getURL(slug, config?.query), {
...config,
data
Expand Down

0 comments on commit be57d11

Please sign in to comment.