recommended
config.
Pagination helps in optimizing the performance of API requests, especially when dealing with large datasets. Instead of retrieving the entire dataset in a single request, pagination allows fetching a smaller subset of data, reducing the response time and resource usage.
Fetching only the necessary data reduces the amount of data transmitted over the network. This is particularly important for users on limited bandwidth or mobile devices. Pagination ensures that only the relevant data is transferred, conserving bandwidth and improving overall network efficiency.
This rule is built for the NestJS framework but can work with a controller @Controller()
and a
decorated method @Get()
.
@Controller()
class Test {
@Get()
public find(): Promise<string[]> {
} // Non-compliant
}
interface Pagination {
items: string[];
currentPage: number;
totalPages: number;
}
@Controller()
class Test {
@Get()
public find(): Promise<Pagination> {
} // Compliant
}
- CNUMR best practices - Avoid transferring large amounts of data for processing tasks
- nestjs-paginate - Pagination and filtering helper method using Nest.js framework