1.0.0 • Published 7 years ago

express-paginate-bacon v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

express-paginate-bacon

NPM Version NPM Downloads Test Coverage MIT License Slack

Node.js pagination middleware and view helpers. Based on https://github.com/expressjs/express-paginate, but everything is better with a bacon.

Install

npm install -S express-paginate-bacon

Usage

Just provide page=1 query parameter in the url.

API

var paginate = require('express-paginate-bacon');

paginate.middleware(perPage)

That's it. No other arguments required.

// # app.js
var express = require('express');
var paginate = require('express-paginate-bacon');
var app = express();

// Keep this before all routes that will use pagination.
app.use(paginate.middleware(100));

paginate.getPages(req)(resultsCount)

Get all the page urls.

paginate.slice(req)(data)

Slices data for the current page.

Frontend

paginate object is available in your template automagically.

  • paginate.perPage
  • paginate.offset
  • paginate.skip
  • paginate.start
  • paginate.currentPage
  • paginate.href

License

MIT