Currently, the project does not have a consistent base response structure for API success and error outputs. This leads to inconsistency across endpoints and makes it harder for frontend integration, debugging, and documentation.
We should introduce a unified base response schema that all APIs must follow for both success and error cases.
type ApiResponse = SuccessResponse | ErrorResponse;
type SuccessResponse = {
success: true;
data: T; // object, array, or null
message?: string; // human-readable, present on every endpoint
meta?: { pagination?: { page; limit; total }; unreadCount?; metrics? };
};
type ErrorResponse = {
success: false;
error: { code: string; message: string; details?: unknown };
};
Currently, the project does not have a consistent base response structure for API success and error outputs. This leads to inconsistency across endpoints and makes it harder for frontend integration, debugging, and documentation.
We should introduce a unified base response schema that all APIs must follow for both success and error cases.
type ApiResponse = SuccessResponse | ErrorResponse;
type SuccessResponse = {
success: true;
data: T; // object, array, or null
message?: string; // human-readable, present on every endpoint
meta?: { pagination?: { page; limit; total }; unreadCount?; metrics? };
};
type ErrorResponse = {
success: false;
error: { code: string; message: string; details?: unknown };
};