# connect-pagination

> Exposes a connect middleware to easily parse and create pagination query strings.

Latest version **1.1.0** (published 2014-10-03) · 0 weekly downloads

## Install

```sh
npm install connect-pagination
pnpm add connect-pagination
yarn add connect-pagination
bun add connect-pagination
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2014-10-03 |
| First published | 2013-06-30 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Philipp Nolte |
| Maintainers | ptnplanet |
| Keywords | pagination, query, connect, middleware, pagination-url, url |

## Links

- npm: https://www.npmjs.com/package/connect-pagination
- Repository: https://github.com/ptnplanet/connect-pagination
- Issues: https://github.com/ptnplanet/connect-pagination/issues
- npm.io page: https://npm.io/package/connect-pagination

## Alternatives

- [gamedig](https://npm.io/package/gamedig.md) — 29.3K weekly downloads
- [join-monster](https://npm.io/package/join-monster.md) — 12.8K weekly downloads
- [masked](https://npm.io/package/masked.md) — 5.5K weekly downloads
- [@comunica/actor-query-process-explain-logical](https://npm.io/package/@comunica/actor-query-process-explain-logical.md) — 4.7K weekly downloads
- [@veracity/vui](https://npm.io/package/@veracity/vui.md) — 4.6K weekly downloads

## Recent versions

- 1.1.0 (latest) — 2014-10-03
- 1.0.5 — 2014-05-06
- 1.0.4 — 2014-05-06
- 1.0.3 — 2014-05-06
- 1.0.2 — 2013-07-01
- 1.0.1 — 2013-06-30
- 1.0.0 — 2013-06-30

## README

## connect-pagination

Very simple and easy to use connect (express) middleware for parsing pagination query strings.

### Installation

    $ npm install connect-pagination

### Quick Start with Connect.js or Express.js

```js

var connect    = require('connect'),
    pagination = require('connect-pagination')

var paginationOptions = {
    pageParam: 'p'
};

connect()
    .use(pagination(options))
    .use(function (req, res) {
        res.send(req.pagination);
    });
```

### Available Options

* `pageParam` specifies the query param for the page number (defaults to `page`)
* `ippParam` specifies the query param for the number of items per page (defaults to `ipp`)
* `page` the default page number (defaults to `1`)
* `ipp` the default number of items per page (defaults to `24`)

### The `req.pagination` object

Through `req.pagination` the following object becomes available:

* `page` the current requested page number
* `pip` the current requested number of items per page
* `optionsPresent` `true` if there are pagination request parameters
* Function `buildQuery(page, ipp)` returns a query string like `?page=4&ipp=20`
* Function `addQuery(url, page, ipp)` adds the pagination query to the url given

### Changelog

#### 1.1.0

*May not be backwards-compatible.*

* Now builds the query string with the parameter names given.

#### 1.0.5

* Fixed bug that resulted in wrong query strings.

#### 1.0.4

* Add `optionsPresent` attribute to `req.pagination` object.

#### 1.0.3

* Parse query parameters to numbers.

#### 1.0.2

* The ```pagination``` object is now attached to ```res.locals``` so that it can be used in express remplates

---
_Source: https://npm.io/package/connect-pagination · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
