0.1.2 • Published 6 years ago
fastify-pagination v0.1.2
fastify-pagination
Response pagination for Fastify. Inspired by Django Rest Framework
Install
npm install fastify-paginationOr, if using yarn:
yarn add fastify-paginationUsage
const fastify = require('fastify')();
fastify
.register(require('fastify-pagination'))
.get("/", {}, async (request, reply) => {
const { limit, offset } = request.parsePagination();
const { items, count } = await getItemsAndTotalCountWithPagination(limit, offset);
reply.sendWithPagination({ count, page: items }); // adds `next` and `previous` properties.
});API
Todo.