2022-08-25 13:22:14 +00:00
|
|
|
import { IsNumber, Max, Min } from 'class-validator';
|
|
|
|
|
2022-08-25 11:39:58 +00:00
|
|
|
export class BaseResponse {
|
2022-08-25 12:16:29 +00:00
|
|
|
constructor(statusCode: number) {
|
|
|
|
this.statusCode = statusCode;
|
|
|
|
}
|
|
|
|
|
2022-08-25 13:22:14 +00:00
|
|
|
@IsNumber()
|
|
|
|
@Min(100)
|
|
|
|
@Max(599)
|
2022-08-25 11:39:58 +00:00
|
|
|
statusCode: number;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class SuccessResponse extends BaseResponse {
|
2022-08-25 12:16:29 +00:00
|
|
|
constructor() {
|
|
|
|
super(200);
|
|
|
|
}
|
|
|
|
|
|
|
|
declare statusCode: 200;
|
2022-08-25 11:39:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export class ErrorResponse extends BaseResponse {
|
2022-08-25 12:16:29 +00:00
|
|
|
declare statusCode: 400 | 401 | 403;
|
2022-08-25 11:39:58 +00:00
|
|
|
message?: string;
|
|
|
|
}
|