0.1.2 • Published 5 years ago

fastify-pagination v0.1.2

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

fastify-pagination

Build Status Coverage Status

Response pagination for Fastify. Inspired by Django Rest Framework

Install

npm install fastify-pagination

Or, if using yarn:

yarn add fastify-pagination

Usage

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.