infinity-forge
Version:
37 lines (36 loc) • 967 B
TypeScript
import { ResponseType } from "axios";
import { ValidationErrorModel } from "./errors/index.js";
export type HttpMethod = 'post' | 'get' | 'put' | 'delete';
export type HttpRequest = {
url: string;
method: HttpMethod;
body?: any;
headers?: any;
responseType?: ResponseType;
fullPath?: string;
debugMode?: boolean;
};
export declare enum HttpStatusCode {
ok = 200,
okCreated = 201,
okPost = 202,
okNoContent = 204,
notFound = 404,
noContent = 204,
forbidden = 403,
badRequest = 400,
serverError = 500,
conflict = 409,
unauthorized = 401,
unprocessableEntity = 422
}
export type HttpResponse<T = any> = {
data: T;
status: HttpStatusCode;
message?: string | null;
validationErros?: ValidationErrorModel;
} & T;
export type HttpResponseResult<R = any> = Promise<HttpResponse<R>>;
export interface HttpClient<R = any> {
request: (data: HttpRequest) => HttpResponseResult<R>;
}