25 lines
548 B
TypeScript
25 lines
548 B
TypeScript
import { ApiProperty } from '@nestjs/swagger';
|
|
|
|
export class ApiResponseMeta {
|
|
@ApiProperty({ nullable: true })
|
|
cachedAt: string | null;
|
|
|
|
@ApiProperty()
|
|
fromCache: boolean;
|
|
|
|
constructor(fromCache: boolean, cachedAt: string | null = null) {
|
|
this.fromCache = fromCache;
|
|
this.cachedAt = cachedAt;
|
|
}
|
|
}
|
|
|
|
export class ApiResponse<T> {
|
|
data: T;
|
|
meta: ApiResponseMeta;
|
|
|
|
constructor(data: T, fromCache = false, cachedAt: string | null = null) {
|
|
this.data = data;
|
|
this.meta = new ApiResponseMeta(fromCache, cachedAt);
|
|
}
|
|
}
|