Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

koa-pagination

Package Overview
Dependencies
Maintainers
3
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

koa-pagination - npm Package Compare versions

Comparing version 3.0.0 to 4.0.0

157

CHANGELOG.md
# Changelog
## [v3.0.0](https://github.com/seegno/koa-pagination/tree/v3.0.0) (2017-03-30)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v2.0.1...v3.0.0)
## [v4.0.0](https://github.com/uphold/koa-pagination/releases/tag/v4.0.0) (2019-10-15)
- Add github-changelog-generator as dev-dependency [\#59](https://github.com/uphold/koa-pagination/pull/59) ([eduardoconceicao](https://github.com/eduardoconceicao))
- Update sshpk to 1.16.1 [\#58](https://github.com/uphold/koa-pagination/pull/58) ([eduardoconceicao](https://github.com/eduardoconceicao))
- Update dependencies [\#57](https://github.com/uphold/koa-pagination/pull/57) ([eduardoconceicao](https://github.com/eduardoconceicao))
- Remove is-safe-integer dependency [\#54](https://github.com/uphold/koa-pagination/pull/54) ([nunofgs](https://github.com/nunofgs))
- Update standard-http-error@2.0.1 [\#55](https://github.com/uphold/koa-pagination/pull/55) ([nunofgs](https://github.com/nunofgs))
- Expose `Accept-Ranges` header [\#52](https://github.com/uphold/koa-pagination/pull/52) ([nunofgs](https://github.com/nunofgs))
- Fix invalid range unit override [\#51](https://github.com/uphold/koa-pagination/pull/51) ([nunofgs](https://github.com/nunofgs))
- Do not overwrite status if it is not successful [\#50](https://github.com/uphold/koa-pagination/pull/50) ([nunofgs](https://github.com/nunofgs))
- Update ownership [\#46](https://github.com/uphold/koa-pagination/pull/46) ([ruimarinho](https://github.com/ruimarinho))
**Merged pull requests:**
## [v3.0.0](https://github.com/uphold/koa-pagination/releases/tag/v3.0.0) (2017-03-30)
- Move source to /src [\#45](https://github.com/uphold/koa-pagination/pull/45) ([kurayama](https://github.com/kurayama))
- Improve README [\#44](https://github.com/uphold/koa-pagination/pull/44) ([kurayama](https://github.com/kurayama))
- Replace default export by named middleware and errors [\#43](https://github.com/uphold/koa-pagination/pull/43) ([nunofgs](https://github.com/nunofgs))
- Add .npmignore [\#42](https://github.com/uphold/koa-pagination/pull/42) ([ruimarinho](https://github.com/ruimarinho))
- Update koa@2 [\#40](https://github.com/uphold/koa-pagination/pull/40) ([kurayama](https://github.com/kurayama))
- Add LICENSE [\#41](https://github.com/uphold/koa-pagination/pull/41) ([ruimarinho](https://github.com/ruimarinho))
- Update README [\#38](https://github.com/uphold/koa-pagination/pull/38) ([franciscocardoso](https://github.com/franciscocardoso))
- Add `allowAll` parameter to disable asterisk [\#37](https://github.com/uphold/koa-pagination/pull/37) ([nunofgs](https://github.com/nunofgs))
- Move source to /src [\#45](https://github.com/seegno/koa-pagination/pull/45) ([kurayama](https://github.com/kurayama))
- Improve README [\#44](https://github.com/seegno/koa-pagination/pull/44) ([kurayama](https://github.com/kurayama))
- Replace default export by named middleware and errors [\#43](https://github.com/seegno/koa-pagination/pull/43) ([nunofgs](https://github.com/nunofgs))
- Add .npmignore [\#42](https://github.com/seegno/koa-pagination/pull/42) ([ruimarinho](https://github.com/ruimarinho))
- Add LICENSE [\#41](https://github.com/seegno/koa-pagination/pull/41) ([ruimarinho](https://github.com/ruimarinho))
- Update koa@2 [\#40](https://github.com/seegno/koa-pagination/pull/40) ([kurayama](https://github.com/kurayama))
- Update README [\#38](https://github.com/seegno/koa-pagination/pull/38) ([franciscocardoso](https://github.com/franciscocardoso))
- Add `allowAll` parameter to disable asterisk [\#37](https://github.com/seegno/koa-pagination/pull/37) ([nunofgs](https://github.com/nunofgs))
## [v2.0.1](https://github.com/uphold/koa-pagination/releases/tag/v2.0.1) (2016-05-18)
- Update range-specifier-parser@1.0.2 [\#35](https://github.com/uphold/koa-pagination/pull/35) ([nunofgs](https://github.com/nunofgs))
- Add asterisk instructions to readme [\#34](https://github.com/uphold/koa-pagination/pull/34) ([nunofgs](https://github.com/nunofgs))
## [v2.0.1](https://github.com/seegno/koa-pagination/tree/v2.0.1) (2016-05-18)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v2.0.0...v2.0.1)
## [v2.0.0](https://github.com/uphold/koa-pagination/releases/tag/v2.0.0) (2016-05-18)
- Add asterisk support [\#32](https://github.com/uphold/koa-pagination/pull/32) ([nunofgs](https://github.com/nunofgs))
- Refactor to es6 standards [\#31](https://github.com/uphold/koa-pagination/pull/31) ([nunofgs](https://github.com/nunofgs))
- Update dependencies [\#30](https://github.com/uphold/koa-pagination/pull/30) ([nunofgs](https://github.com/nunofgs))
**Merged pull requests:**
## [v1.1.1](https://github.com/uphold/koa-pagination/releases/tag/v1.1.1) (2016-05-04)
- Update README [\#29](https://github.com/uphold/koa-pagination/pull/29) ([franciscocardoso](https://github.com/franciscocardoso))
- Update range-specifier-parser@1.0.2 [\#35](https://github.com/seegno/koa-pagination/pull/35) ([nunofgs](https://github.com/nunofgs))
- Add asterisk instructions to readme [\#34](https://github.com/seegno/koa-pagination/pull/34) ([nunofgs](https://github.com/nunofgs))
## [v1.1.0](https://github.com/uphold/koa-pagination/releases/tag/v1.1.0) (2016-05-04)
## [v2.0.0](https://github.com/seegno/koa-pagination/tree/v2.0.0) (2016-05-18)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v1.1.1...v2.0.0)
## [v0.1.1](https://github.com/uphold/koa-pagination/releases/tag/v0.1.1) (2016-05-04)
**Merged pull requests:**
## [v0.1.2](https://github.com/uphold/koa-pagination/releases/tag/v0.1.2) (2016-05-04)
- Add asterisk support [\#32](https://github.com/seegno/koa-pagination/pull/32) ([nunofgs](https://github.com/nunofgs))
- Refactor to es6 standards [\#31](https://github.com/seegno/koa-pagination/pull/31) ([nunofgs](https://github.com/nunofgs))
- Update dependencies [\#30](https://github.com/seegno/koa-pagination/pull/30) ([nunofgs](https://github.com/nunofgs))
## [v0.1.3](https://github.com/uphold/koa-pagination/releases/tag/v0.1.3) (2016-05-04)
## [v1.1.1](https://github.com/seegno/koa-pagination/tree/v1.1.1) (2016-05-04)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v1.1.0...v1.1.1)
## [v0.2.0](https://github.com/uphold/koa-pagination/releases/tag/v0.2.0) (2016-05-04)
**Merged pull requests:**
## [v0.3.0](https://github.com/uphold/koa-pagination/releases/tag/v0.3.0) (2016-05-04)
- Update README [\#29](https://github.com/seegno/koa-pagination/pull/29) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.3.1](https://github.com/uphold/koa-pagination/releases/tag/v0.3.1) (2016-05-04)
## [v1.1.0](https://github.com/seegno/koa-pagination/tree/v1.1.0) (2016-05-04)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v1.0.0...v1.1.0)
## [v1.0.0](https://github.com/uphold/koa-pagination/releases/tag/v1.0.0) (2016-05-04)
**Merged pull requests:**
- Update changelog and version scripts [\#28](https://github.com/seegno/koa-pagination/pull/28) ([franciscocardoso](https://github.com/franciscocardoso))
- Improve error message [\#27](https://github.com/seegno/koa-pagination/pull/27) ([ruimarinho](https://github.com/ruimarinho))
- Expose `range-unit` [\#26](https://github.com/seegno/koa-pagination/pull/26) ([franciscocardoso](https://github.com/franciscocardoso))
## [v1.0.0](https://github.com/seegno/koa-pagination/tree/v1.0.0) (2015-12-10)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.3.1...v1.0.0)
**Merged pull requests:**
- Remove usage of `chai` [\#25](https://github.com/seegno/koa-pagination/pull/25) ([franciscocardoso](https://github.com/franciscocardoso))
- Prevent usage of unsafe numbers [\#24](https://github.com/seegno/koa-pagination/pull/24) ([franciscocardoso](https://github.com/franciscocardoso))
- Replace `create-error` with `standard-http-error` [\#23](https://github.com/seegno/koa-pagination/pull/23) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.3.1](https://github.com/seegno/koa-pagination/tree/v0.3.1) (2015-02-26)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.3.0...v0.3.1)
**Merged pull requests:**
- Fix readme headers example [\#21](https://github.com/seegno/koa-pagination/pull/21) ([nunorafaelrocha](https://github.com/nunorafaelrocha))
## [v0.3.0](https://github.com/seegno/koa-pagination/tree/v0.3.0) (2015-02-09)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.2.0...v0.3.0)
**Merged pull requests:**
- Change default unit to `items` [\#20](https://github.com/seegno/koa-pagination/pull/20) ([fixe](https://github.com/fixe))
- Allow specifying `unit` option [\#19](https://github.com/seegno/koa-pagination/pull/19) ([fixe](https://github.com/fixe))
## [v0.2.0](https://github.com/seegno/koa-pagination/tree/v0.2.0) (2015-02-03)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.1.3...v0.2.0)
**Merged pull requests:**
- Update response status [\#18](https://github.com/seegno/koa-pagination/pull/18) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.1.3](https://github.com/seegno/koa-pagination/tree/v0.1.3) (2015-02-02)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.1.2...v0.1.3)
**Merged pull requests:**
- Add npm badge [\#14](https://github.com/seegno/koa-pagination/pull/14) ([fixe](https://github.com/fixe))
- Add codeclimate `gpa` and `coverage` badges [\#13](https://github.com/seegno/koa-pagination/pull/13) ([franciscocardoso](https://github.com/franciscocardoso))
- Rename test file to `index\_test` [\#12](https://github.com/seegno/koa-pagination/pull/12) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix error in example `content-range` value [\#11](https://github.com/seegno/koa-pagination/pull/11) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.1.2](https://github.com/seegno/koa-pagination/tree/v0.1.2) (2015-01-29)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.1.1...v0.1.2)
**Merged pull requests:**
- Fix github repository name [\#10](https://github.com/seegno/koa-pagination/pull/10) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.1.1](https://github.com/seegno/koa-pagination/tree/v0.1.1) (2015-01-29)
[Full Changelog](https://github.com/seegno/koa-pagination/compare/v0.1.0...v0.1.1)
**Merged pull requests:**
- Fix pagination limit value [\#9](https://github.com/seegno/koa-pagination/pull/9) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.1.0](https://github.com/seegno/koa-pagination/tree/v0.1.0) (2015-01-28)
**Merged pull requests:**
- Fix `limit` and `offset` interpretation [\#8](https://github.com/seegno/koa-pagination/pull/8) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix count in README [\#7](https://github.com/seegno/koa-pagination/pull/7) ([fixe](https://github.com/fixe))
- Remove non existent precommit configurations [\#6](https://github.com/seegno/koa-pagination/pull/6) ([franciscocardoso](https://github.com/franciscocardoso))
- Update README [\#5](https://github.com/seegno/koa-pagination/pull/5) ([franciscocardoso](https://github.com/franciscocardoso))
- Add Travis [\#4](https://github.com/seegno/koa-pagination/pull/4) ([fixe](https://github.com/fixe))
- Add range parser modules [\#3](https://github.com/seegno/koa-pagination/pull/3) ([franciscocardoso](https://github.com/franciscocardoso))
## [v0.1.0](https://github.com/uphold/koa-pagination/releases/tag/v0.1.0) (2016-05-04)
- Update changelog and version scripts [\#28](https://github.com/uphold/koa-pagination/pull/28) ([franciscocardoso](https://github.com/franciscocardoso))
- Expose `range-unit` [\#26](https://github.com/uphold/koa-pagination/pull/26) ([franciscocardoso](https://github.com/franciscocardoso))
- Improve error message [\#27](https://github.com/uphold/koa-pagination/pull/27) ([ruimarinho](https://github.com/ruimarinho))
- Remove usage of `chai` [\#25](https://github.com/uphold/koa-pagination/pull/25) ([franciscocardoso](https://github.com/franciscocardoso))
- Replace `create-error` with `standard-http-error` [\#23](https://github.com/uphold/koa-pagination/pull/23) ([franciscocardoso](https://github.com/franciscocardoso))
- Prevent usage of unsafe numbers [\#24](https://github.com/uphold/koa-pagination/pull/24) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix readme headers example [\#21](https://github.com/uphold/koa-pagination/pull/21) ([nunorafaelrocha](https://github.com/nunorafaelrocha))
- Change default unit to `items` [\#20](https://github.com/uphold/koa-pagination/pull/20) ([fixe](https://github.com/fixe))
- Allow specifying `unit` option [\#19](https://github.com/uphold/koa-pagination/pull/19) ([fixe](https://github.com/fixe))
- Update response status [\#18](https://github.com/uphold/koa-pagination/pull/18) ([franciscocardoso](https://github.com/franciscocardoso))
- Add codeclimate `gpa` and `coverage` badges [\#13](https://github.com/uphold/koa-pagination/pull/13) ([franciscocardoso](https://github.com/franciscocardoso))
- Add npm badge [\#14](https://github.com/uphold/koa-pagination/pull/14) ([fixe](https://github.com/fixe))
- Rename test file to `index_test` [\#12](https://github.com/uphold/koa-pagination/pull/12) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix error in example `content-range` value [\#11](https://github.com/uphold/koa-pagination/pull/11) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix github repository name [\#10](https://github.com/uphold/koa-pagination/pull/10) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix pagination limit value [\#9](https://github.com/uphold/koa-pagination/pull/9) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix `limit` and `offset` interpretation [\#8](https://github.com/uphold/koa-pagination/pull/8) ([franciscocardoso](https://github.com/franciscocardoso))
- Fix count in README [\#7](https://github.com/uphold/koa-pagination/pull/7) ([fixe](https://github.com/fixe))
- Update README [\#5](https://github.com/uphold/koa-pagination/pull/5) ([franciscocardoso](https://github.com/franciscocardoso))
- Remove non existent precommit configurations [\#6](https://github.com/uphold/koa-pagination/pull/6) ([franciscocardoso](https://github.com/franciscocardoso))
- Add Travis [\#4](https://github.com/uphold/koa-pagination/pull/4) ([fixe](https://github.com/fixe))
- Add range parser modules [\#3](https://github.com/uphold/koa-pagination/pull/3) ([franciscocardoso](https://github.com/franciscocardoso))
{
"name": "koa-pagination",
"version": "3.0.0",
"version": "4.0.0",
"description": "A middleware to handle Range Pagination Headers using Range & Content-Range entity-headers",
"license": "MIT",
"author": "Seegno",
"author": "Uphold",
"main": "src",
"repository": "seegno/koa-pagination",
"repository": "uphold/koa-pagination",
"scripts": {
"changelog": "github_changelog_generator --no-issues --header-label='# Changelog' --future-release=v$npm_config_future_release && sed -i '' -e :a -e '$d;N;2,4ba' -e 'P;D' CHANGELOG.md",
"changelog": "github-changelog-generator -f v$npm_package_version > CHANGELOG.md",
"lint": "eslint src test",
"lint-staged": "lint-staged",
"test": "jest --coverage --verbose --env=node",
"version": "npm run changelog --future-release=$npm_package_version && git add -A CHANGELOG.md"
"version": "npm run changelog && git add -A CHANGELOG.md"
},
"dependencies": {
"debug": "^2.6.3",
"debug": "^4.1.1",
"http-content-range-format": "^1.0.0",
"is-safe-integer": "^1.0.2",
"range-specifier-parser": "^1.0.2",
"standard-http-error": "^2.0.0"
"standard-http-error": "^2.0.1"
},
"devDependencies": {
"eslint": "^3.16.1",
"eslint-config-seegno": "^9.0.0",
"jest": "^19.0.2",
"koa": "^2.0.1",
"lint-staged": "^3.4.0",
"@uphold/github-changelog-generator": "^1.0.1",
"eslint": "^6.5.1",
"eslint-config-uphold": "^1.0.1",
"jest": "^24.9.0",
"koa": "^2.10.0",
"lint-staged": "^9.4.2",
"pre-commit": "^1.2.2",
"supertest": "^3.0.0"
"prettier": "^1.18.2",
"supertest": "^4.0.2"
},
"engines": {
"node": ">=7.6"
"node": ">=8.16.0"
},

@@ -35,0 +36,0 @@ "lint-staged": {

@@ -29,3 +29,3 @@ # koa-pagination

- `maximum`: Maximum number of items allowed per page (`50` by default).
- `unit`: Range unit to be used when no `Range` header is provided (`items` by default).
- `unit`: Accepted range unit (`items` by default).

@@ -82,9 +82,10 @@ You can change the defaults by doing:

The first example will generate a response with the following `Content-Range` header:
The first example will generate a response with the following headers:
```javascript
'Accepted-Ranges': 'items'
'Content-Range: items 0-4/*'
```
The `*` will be replaced with the total number of items provided in the `length` variable.
The `*` in the `Content-Range` header will be replaced with the total number of items provided in the `length` variable.

@@ -115,3 +116,3 @@ #### Codes

[npm-url]: https://npmjs.org/package/koa-pagination
[travis-image]: https://img.shields.io/travis/seegno/koa-pagination.svg?style=flat-square
[travis-url]: https://travis-ci.org/seegno/koa-pagination
[travis-image]: https://img.shields.io/travis/uphold/koa-pagination.svg?style=flat-square
[travis-url]: https://travis-ci.org/uphold/koa-pagination

@@ -9,3 +9,2 @@ 'use strict';

const errors = require('./errors');
const isSafeInteger = require('is-safe-integer');
const rangeSpecifierParser = require('range-specifier-parser').default;

@@ -30,3 +29,3 @@

// Prevent invalid `maximum` value configuration.
if (!isFinite(maximum) || !isSafeInteger(maximum) || maximum <= 0) {
if (!isFinite(maximum) || !Number.isSafeInteger(maximum) || maximum <= 0) {
throw new InvalidConfigurationError();

@@ -47,6 +46,9 @@ }

// Update `limit`, `offset` and `unit` values.
if (range.unit !== unit) {
throw new MalformedRangeError();
}
// Update `limit`, `offset` values.
first = range.first;
last = range.last;
unit = range.unit;

@@ -57,3 +59,3 @@ if (!allowAll && last === '*') {

if (!isSafeInteger(first) || last !== '*' && !isSafeInteger(last)) {
if (!Number.isSafeInteger(first) || (last !== '*' && !Number.isSafeInteger(last))) {
throw new RangeNotSatisfiableError();

@@ -63,3 +65,3 @@ }

if (isSafeInteger(last)) {
if (Number.isSafeInteger(last)) {
// Prevent pages to be longer than allowed.

@@ -83,3 +85,3 @@ if (last - first + 1 > maximum) {

const length = ctx.pagination.length;
const { length } = ctx.pagination;

@@ -107,9 +109,13 @@ // Prevent nonexistent pages.

// Set `Content-Range` based on available units.
// Set response headers based on available units.
ctx.set('Accept-Ranges', unit);
ctx.set('Content-Range', contentRangeFormat({ first, last, length, unit }));
// Allow non-successful status codes.
if (ctx.status < 200 || ctx.status > 300) {
return;
}
// Set the response as `Partial Content`.
if (ctx.get('Range')) {
ctx.status = 206;
}
ctx.status = 206;
};

@@ -116,0 +122,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc