add grist
This commit is contained in:
@@ -1,48 +1,48 @@
|
||||
import type { AxiosInstance } from "axios";
|
||||
|
||||
export type ServiceResult<T = unknown> = {
|
||||
result: T;
|
||||
successful: boolean;
|
||||
result: T;
|
||||
successful: boolean;
|
||||
};
|
||||
|
||||
export class API_Error {
|
||||
constructor(public error: string) {}
|
||||
constructor(public error: string) {}
|
||||
}
|
||||
|
||||
export abstract class BaseClient {
|
||||
private axiosInstance: AxiosInstance;
|
||||
private axiosInstance: AxiosInstance;
|
||||
|
||||
constructor(axiosInstance: AxiosInstance) {
|
||||
this.axiosInstance = axiosInstance;
|
||||
}
|
||||
constructor(axiosInstance: AxiosInstance) {
|
||||
this.axiosInstance = axiosInstance;
|
||||
}
|
||||
|
||||
getAxios(): AxiosInstance {
|
||||
return this.axiosInstance;
|
||||
}
|
||||
getAxios(): AxiosInstance {
|
||||
return this.axiosInstance;
|
||||
}
|
||||
}
|
||||
|
||||
export abstract class BaseService<T> {
|
||||
private client: T;
|
||||
private client: T;
|
||||
|
||||
constructor(client: T) {
|
||||
this.client = client;
|
||||
}
|
||||
constructor(client: T) {
|
||||
this.client = client;
|
||||
}
|
||||
|
||||
getClient(): T {
|
||||
return this.client;
|
||||
}
|
||||
getClient(): T {
|
||||
return this.client;
|
||||
}
|
||||
|
||||
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R> {
|
||||
return {
|
||||
result,
|
||||
successful: true,
|
||||
};
|
||||
}
|
||||
getSuccessfulResult<R = unknown>(result: R): ServiceResult<R> {
|
||||
return {
|
||||
result,
|
||||
successful: true,
|
||||
};
|
||||
}
|
||||
|
||||
getErrorResult(error: string): ServiceResult<string> {
|
||||
return {
|
||||
result: error,
|
||||
successful: false,
|
||||
};
|
||||
}
|
||||
getErrorResult(error: string): ServiceResult<string> {
|
||||
return {
|
||||
result: error,
|
||||
successful: false,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user