jayson
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -217,2 +217,3 @@ import net = require('net'); | ||
methodConstructor?: Function; | ||
maxBatchLength?: number; | ||
} | ||
@@ -219,0 +220,0 @@ |
@@ -20,2 +20,3 @@ 'use strict'; | ||
* @param {Number} [options.version=2] JSON-RPC version to use (1|2) | ||
* @param {Number} [options.maxBatchLength=Infinity] Maximum requests allowed in a batch | ||
* @param {Function} [options.router] Function to use for routing methods | ||
@@ -43,2 +44,3 @@ * @property {Object} options A reference to the internal options object that can be modified directly | ||
methodConstructor: jayson.Method, | ||
maxBatchLength: Infinity, | ||
router: function(method) { | ||
@@ -101,3 +103,4 @@ return this.getMethod(method); | ||
INVALID_PARAMS: -32602, | ||
INTERNAL_ERROR: -32603 | ||
INTERNAL_ERROR: -32603, | ||
INVALID_REQUEST_MAX_BATCH_LENGTH_EXCEEDED: -32099, | ||
}; | ||
@@ -116,2 +119,3 @@ | ||
Server.errorMessages[Server.errors.INTERNAL_ERROR] = 'Internal error'; | ||
Server.errorMessages[Server.errors.INVALID_REQUEST_MAX_BATCH_LENGTH_EXCEEDED] = 'Invalid request: Maximum batch length exceeded'; | ||
@@ -272,2 +276,10 @@ /** | ||
} | ||
// verify number of batch requests does not exceed maximum allowed length | ||
if (self.options.maxBatchLength >= 0 && request.length > self.options.maxBatchLength) { | ||
error = self.error(Server.errors.INVALID_REQUEST_MAX_BATCH_LENGTH_EXCEEDED); | ||
callback(utils.response(error, undefined, undefined, self.options.version)); | ||
return; | ||
} | ||
self._batch(request, context, callback); | ||
@@ -274,0 +286,0 @@ return; |
{ | ||
"name": "jayson", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "JSON-RPC 1.0/2.0 compliant server and client", | ||
@@ -72,6 +72,6 @@ "license": "MIT", | ||
"express": "^4.17.1", | ||
"ink-docstrap": "^1.3.2", | ||
"jsdoc": "^3.6.5", | ||
"ink-docstrap": "github:docstrap/docstrap#pull/345/head", | ||
"jsdoc": "^4.0.2", | ||
"jshint": "^2.12.0", | ||
"mocha": "^7.2.0", | ||
"mocha": "^10.2.0", | ||
"node-fetch": "^2.6.7", | ||
@@ -78,0 +78,0 @@ "nyc": "^14.1.1", |
@@ -218,2 +218,3 @@ import net = require('net'); | ||
methodConstructor?: Function; | ||
maxBatchLength?: number; | ||
} | ||
@@ -220,0 +221,0 @@ |
@@ -9,8 +9,5 @@ # Jayson | ||
[jayson-npm]: https://www.npmjs.com/package/jayson | ||
[jayson-travis]: https://travis-ci.org/tedeh/jayson | ||
[badge-travis]: https://img.shields.io/travis/tedeh/jayson/master.svg | ||
[badge-npm]: https://img.shields.io/npm/v/jayson.svg | ||
[badge-downloads-month]: https://img.shields.io/npm/dm/jayson.svg | ||
[![travis build status][badge-travis]][jayson-travis] | ||
[![Coverage Status](https://coveralls.io/repos/github/tedeh/jayson/badge.svg?branch=master)](https://coveralls.io/github/tedeh/jayson?branch=master) | ||
@@ -118,2 +115,4 @@ ![GitHub issues](https://img.shields.io/github/issues/tedeh/jayson) | ||
- *4.1.0* | ||
- New server option `maxBatchLength` | ||
- *4.0.0* | ||
@@ -158,3 +157,3 @@ - Remove `lodash` dependency which should halve bundle size. There might be minor incompatibilities if you pass funky object or array types to jayson methods. | ||
Jayson does not have any special dependencies that cannot be resolved with a simple `npm install`. It is being [continuously tested][jayson-travis] using [travis-ci](https://travis-ci.org/). You can look inside [.travis.yml](.travis.yml) if you want to see which versions are tested against. | ||
Jayson does not have any special dependencies that cannot be resolved with a simple `npm install` or `yarn install`. | ||
@@ -487,2 +486,3 @@ ## Class documentation | ||
| `version` | 2 | `Number` | JSON-RPC version to support (1 or 2) | | ||
| `maxBatchLength` | Infinity | `Number` | Maximum batch requests allowed | | ||
@@ -489,0 +489,0 @@ ##### Server.tcp |
161968
2922