feat: added nyc for test coverage reporting. fix: add jsdoc comments
This commit is contained in:
@@ -1,13 +1,38 @@
|
||||
/**
|
||||
* @class ApiResponse - A generic response object for API requests.
|
||||
*/
|
||||
export class ApiResponse<T> {
|
||||
/**
|
||||
* @property {number} statusCode - The status code of the response.
|
||||
*/
|
||||
readonly statusCode: number;
|
||||
|
||||
/**
|
||||
* @property {boolean} isSuccessful - True if the status code is less than 400; otherwise, false.
|
||||
*/
|
||||
readonly isSuccessful: boolean;
|
||||
|
||||
/**
|
||||
* @property {string} message - The message of the response.
|
||||
*/
|
||||
readonly message: string;
|
||||
|
||||
/**
|
||||
* @property {T} data - The data of the response.
|
||||
*/
|
||||
readonly data: T;
|
||||
|
||||
constructor(statusCode: number, isSuccessful: boolean, message: string, data: T) {
|
||||
/**
|
||||
* @constructor - Creates a new instance of the ApiResponse class.
|
||||
* @param {number} statusCode - The status code of the response.
|
||||
* @param {string} message - The message of the response.
|
||||
* @param {T} data - The data of the response.
|
||||
* @returns {ApiResponse<T>} - A new instance of the ApiResponse class.
|
||||
*/
|
||||
constructor(statusCode: number, message: string, data: T) {
|
||||
this.statusCode = statusCode;
|
||||
this.isSuccessful = statusCode < 400;
|
||||
this.message = message;
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user