1.0.0 • Published 7 years ago

node-paginate-anything v1.0.0

Weekly downloads
851
License
-
Repository
github
Last release
7 years ago

node-paginate-anything

Build Status Dependency Status devDependency Status

nodejs server side module for angular-paginate-anything

This nodejs module add the required headers in the http response to paginate the items. This is a rewrite of clean_pagination

Install

  npm install node-paginate-anything

Usage

  var paginate = require('node-paginate-anything');
  
  var queryParameters = paginate(ClientRequest, ServerResponse, totalItems, maxRangeSize);
  
  mongooseQuery.limit(queryParameters.limit);
  mongooseQuery.skip(queryParameters.skip);
parameterDescription
ClientRequestclientRequest object from the native http module or from an express app.
ServerResponseServerResponse object to modify before sending the http response.
totalItemstotal number of items in the result set.
maxRangeSizeangular-paginate-anything send is own requested range in the request, this parameter specify the maximum value.

Benefits

  • HTTP Content-Type agnoticism. Information about total items, selected ranges, and next- previous-links are sent through headers. It works without modifying your API payload in any way.
  • Graceful degredation. Both client and server specify the maximum page size they accept and communication gracefully degrades to accomodate the lesser.
  • Expressive retrieval. This approach, unlike the use of per_page and page parameters, allows the client to request any (possibly unbounded) interval of items.
  • Semantic HTTP. Built in strict conformance to RFCs 2616 and 5988.
1.0.0

7 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago