mirror of
https://github.com/aleksilassila/reiverr.git
synced 2026-04-19 15:53:25 +02:00
47 lines
889 B
TypeScript
47 lines
889 B
TypeScript
import { Type } from '@nestjs/common';
|
|
import {
|
|
ApiProperty,
|
|
IntersectionType,
|
|
OmitType,
|
|
PartialType,
|
|
PickType,
|
|
} from '@nestjs/swagger';
|
|
import { PaginatedResponse, PaginationParams } from 'plugins/plugin-types';
|
|
|
|
export const PickAndPartial = <T, K extends keyof T>(
|
|
clazz: Type<T>,
|
|
pick: K[] = [],
|
|
partial: K[] = [],
|
|
) =>
|
|
IntersectionType(
|
|
OmitType(PickType(clazz, pick), partial),
|
|
PickType(PartialType(clazz), partial),
|
|
);
|
|
|
|
export class PaginatedResponseDto<T> implements PaginatedResponse<T> {
|
|
@ApiProperty()
|
|
total: number;
|
|
|
|
@ApiProperty()
|
|
page: number;
|
|
|
|
@ApiProperty()
|
|
itemsPerPage: number;
|
|
|
|
// @ApiProperty()
|
|
items: T[];
|
|
}
|
|
|
|
export class PaginationParamsDto implements PaginationParams {
|
|
@ApiProperty()
|
|
page: number;
|
|
|
|
@ApiProperty()
|
|
itemsPerPage: number;
|
|
}
|
|
|
|
export class SuccessResponseDto {
|
|
@ApiProperty()
|
|
success: boolean;
|
|
}
|