modarb-be / src /lib /responses /json-responses.d.ts
moahmedwafy's picture
feat: init docs
721abf7
raw
history blame
526 Bytes
interface IJSONResponse {
status: number;
message: string;
}
export type IJSONSuccessResponse<T extends Record<string, any> | Record<string, any>[]> = IJSONResponse & {
data: T;
}
&
(T extends any[] ? {
meta: {
total: number;
page: number;
perPage: number;
};
} : {});
export interface IJSONErrorResponse extends IJSONResponse {
error: string;
}
export interface IJSONValidationErrorResponse extends IJSONResponse {
status: 422;
message: "Validation Error";
errors: Record<string, any>[];
}