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

Response pagination for Fastify. Inspired by Django Rest Framework.

License

Notifications You must be signed in to change notification settings

francisbrito/fastify-pagination

Repository files navigation

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.

About

Response pagination for Fastify. Inspired by Django Rest Framework.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published