0.4.1 • Published 8 years ago

hapi-paginate v0.4.1

Weekly downloads
1
License
CC0-1.0
Repository
github
Last release
8 years ago

hapi-paginate

npm version Build Status

A basic pagination plugin for Hapi.

The plugin listens to page and limit query parameters and add them to request object.

The Hapi app should decide how to handle request.page and request.limit values.

The plugin then adds a meta key to the output json response and move the response under results key.

To limit the plugin to specific routes, adds routes to options.

Example

curl -X GET http://www.example.com?page=3&limit=100

{
    "meta": {
        "page": 3,
        "limit": 100
    },
    "results": {
        "key": "value"
    }
}

Installation

$: npm install hapi-paginate

Registration

var Hapi = require('hapi');

var hapi = new Hapi.Server();
hapi.connection();

hapi.register({
  register: require('hapi-paginate'),
  options: {
    limit: 1000,
    name: 'My Meta',
    results: 'output',
    routes: ['/', '/api']
  }
};

Test

$ npm test
0.4.1

8 years ago

0.4.0

8 years ago

0.3.0

9 years ago

0.2.0

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago