How to use the @hapi/boom.entityTooLarge function in @hapi/boom

To help you get started, we’ve selected a few @hapi/boom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ArkEcosystem / core / packages / core-http-utils / src / plugins / transaction-payload.ts View on Github external
if (!transactionPool) {
                    return h.continue;
                }

                // NOTE: this will only trigger if the JSON content-type header is not
                // present. This will be avoided by the "content-type.js" plugin in the
                // future which is currently disabled due to v1 still being on mainnet.
                if (!request.payload.transactions) {
                    return Boom.badRequest();
                }

                const transactionsCount = request.payload.transactions.length;
                const maxTransactionsPerRequest = transactionPool.maxTransactionsPerRequest;

                if (transactionsCount > maxTransactionsPerRequest) {
                    return Boom.entityTooLarge(
                        `Received ${transactionsCount} transactions. Only ${maxTransactionsPerRequest} are allowed per request.`,
                        {
                            allowed: maxTransactionsPerRequest,
                            received: transactionsCount,
                        },
                    );
                }

                return h.continue;
            },
        });
github hapijs / wreck / lib / recorder.js View on Github external
_write(chunk, encoding, next) {

        if (this.settings.maxBytes &&
            this.length + chunk.length > this.settings.maxBytes) {

            return this.emit('error', Boom.entityTooLarge('Payload content length greater than maximum allowed: ' + this.settings.maxBytes));
        }

        this.length = this.length + chunk.length;
        this.buffers.push(chunk);
        next();
    }
github hapijs / pez / lib / index.js View on Github external
const onReqData = (data) => {

            this._bytes += Buffer.byteLength(data);

            if (this._bytes > this._maxBytes) {
                finish(Boom.entityTooLarge('Maximum size exceeded'));
            }
        };