Skip to content
This repository has been archived by the owner on Aug 7, 2024. It is now read-only.

Latest commit

 

History

History
30 lines (24 loc) · 1.02 KB

README.md

File metadata and controls

30 lines (24 loc) · 1.02 KB

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.