under-pressure
Advanced tools
Comparing version 1.0.0 to 2.0.0
15
index.js
@@ -62,5 +62,5 @@ 'use strict' | ||
function onRequest (req, res, next) { | ||
function onRequest (req, reply, next) { | ||
if (checkMaxEventLoopDelay && eventLoopDelay > maxEventLoopDelay) { | ||
sendError(res, next) | ||
sendError(reply, next) | ||
return | ||
@@ -70,3 +70,3 @@ } | ||
if (checkMaxHeapUsedBytes && heapUsed > maxHeapUsedBytes) { | ||
sendError(res, next) | ||
sendError(reply, next) | ||
return | ||
@@ -76,3 +76,3 @@ } | ||
if (checkMaxRssBytes && rssBytes > maxRssBytes) { | ||
sendError(res, next) | ||
sendError(reply, next) | ||
return | ||
@@ -84,5 +84,4 @@ } | ||
function sendError (res, next) { | ||
res.statusCode = 503 | ||
res.setHeader('Retry-After', retryAfter) | ||
function sendError (reply, next) { | ||
reply.status(503).header('Retry-After', retryAfter) | ||
next(serviceUnavailableError) | ||
@@ -117,4 +116,4 @@ } | ||
module.exports = fp(underPressure, { | ||
fastify: '^1.1.0', | ||
fastify: '>=2.0.0', | ||
name: 'under-pressure' | ||
}) |
{ | ||
"name": "under-pressure", | ||
"version": "1.0.0", | ||
"version": "2.0.0", | ||
"description": "Measure process load with automatic handling of 'Service Unavailable' plugin for Fastify.", | ||
@@ -32,3 +32,3 @@ "main": "index.js", | ||
"devDependencies": { | ||
"fastify": "^1.13.3", | ||
"fastify": "2.0.0-rc.3", | ||
"pre-commit": "^1.2.2", | ||
@@ -35,0 +35,0 @@ "simple-get": "^3.0.3", |
@@ -13,3 +13,3 @@ # under-pressure | ||
Fastify ^1.1.0 . | ||
Fastify ^2.0.0. Please refer to [this branch](https://github.com/fastify/under-pressure/tree/1.x) and related versions for Fastify ^1.1.0 compatibility. | ||
@@ -16,0 +16,0 @@ <a name="install"></a> |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
165082
8
319