https://github.com/polo2ro/node-paginate-anything
nodejs server side module for angular-pagninate-anything
https://github.com/polo2ro/node-paginate-anything
angular nodejs paginate
Last synced: 6 months ago
JSON representation
nodejs server side module for angular-pagninate-anything
- Host: GitHub
- URL: https://github.com/polo2ro/node-paginate-anything
- Owner: polo2ro
- Created: 2014-06-24T07:18:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-01-01T14:51:55.000Z (almost 9 years ago)
- Last Synced: 2025-04-24T02:09:13.270Z (6 months ago)
- Topics: angular, nodejs, paginate
- Language: JavaScript
- Size: 22.5 KB
- Stars: 17
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
node-paginate-anything
======================[](https://travis-ci.org/polo2ro/node-paginate-anything)
[](https://david-dm.org/polo2ro/node-paginate-anything)
[](https://david-dm.org/polo2ro/node-paginate-anything#info=devDependencies)nodejs server side module for [angular-paginate-anything](https://github.com/begriffs/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](https://github.com/begriffs/clean_pagination)
### Install
```Bash
npm install node-paginate-anything
```### Usage
```JavaScript
var paginate = require('node-paginate-anything');
var queryParameters = paginate(ClientRequest, ServerResponse, totalItems, maxRangeSize);
mongooseQuery.limit(queryParameters.limit);
mongooseQuery.skip(queryParameters.skip);
```parameter | Description
---------------|---------------
ClientRequest | [clientRequest](http://nodejs.org/api/http.html#http_class_http_clientrequest) object from the native http module or from an express app.
ServerResponse | [ServerResponse](http://nodejs.org/api/http.html#http_class_http_serverresponse) object to modify before sending the http response.
totalItems | total number of items in the result set.
maxRangeSize | angular-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.