Skip to content

Commit

Permalink
Merge pull request #17 from smartiniOnGitHub/update-to-fastify-1.13.0…
Browse files Browse the repository at this point in the history
…-and-all-plugins

update to latest fastify and all plugin to latest release;  configure…
  • Loading branch information
cemremengu authored Nov 22, 2018
2 parents 4bf1567 + b954363 commit d0d6a34
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 24 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
Measure process load with automatic handling of *"Service Unavailable"* plugin for Fastify.
It can check `maxEventLoopDelay`, `maxHeapUsedBytes` and `maxRssBytes` values.

<a name="requirements"></a>
## Requirements

Fastify ^1.1.0 .

<a name="install"></a>
## Install
```
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ function underPressure (fastify, opts, next) {
type: 'object',
properties: {
status: { type: 'string' }
}}
}
}
} }
},
handler: onStatus
})
Expand Down Expand Up @@ -110,6 +110,6 @@ function now () {
}

module.exports = fp(underPressure, {
fastify: '>=0.39.0',
fastify: '^1.1.0',
name: 'under-pressure'
})
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"main": "index.js",
"scripts": {
"lint": "standard | snazzy",
"unit": "tap test.js",
"unit": "tap -J test.js",
"test": "npm run lint && npm run unit",
"coverage": "npm run unit -- --cov --coverage-report=html"
},
Expand All @@ -26,14 +26,14 @@
"author": "Tomas Della Vedova - @delvedor (http://delved.org)",
"license": "MIT",
"dependencies": {
"fastify-plugin": "^1.2.0"
"fastify-plugin": "^1.2.1"
},
"devDependencies": {
"fastify": "^1.7.0",
"fastify": "^1.13.0",
"pre-commit": "^1.2.2",
"simple-get": "^3.0.2",
"snazzy": "^7.1.1",
"standard": "^11.0.1",
"tap": "^12.0.1"
"simple-get": "^3.0.3",
"snazzy": "^8.0.0",
"standard": "^12.0.1",
"tap": "^12.1.0"
}
}
35 changes: 21 additions & 14 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ test('Should return 503 on maxEventLoopDelay', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
fastify.server.unref()

// Increased to prevent Travis to fail
process.nextTick(() => sleep(1000))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 503)
Expand All @@ -52,13 +53,14 @@ test('Should return 503 on maxHeapUsedBytes', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 503)
Expand All @@ -85,13 +87,14 @@ test('Should return 503 on maxRssBytes', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 503)
Expand Down Expand Up @@ -120,13 +123,14 @@ test('Custom message and retry after header', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 503)
Expand Down Expand Up @@ -158,14 +162,15 @@ test('memoryUsage name space', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
t.is(typeof fastify.memoryUsage, 'function')
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
Expand All @@ -188,14 +193,15 @@ test('memoryUsage name space (without check)', t => {
reply.send({ hello: 'world' })
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
t.is(typeof fastify.memoryUsage, 'function')
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port
url: address
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
Expand All @@ -213,13 +219,14 @@ test('Expose status route', t => {
exposeStatusRoute: true
})

fastify.listen(0, err => {
fastify.listen(0, (err, address) => {
t.error(err)
fastify.server.unref()

process.nextTick(() => sleep(500))
sget({
method: 'GET',
url: 'http://localhost:' + fastify.server.address().port + '/status'
url: `${address}/status`
}, (err, response, body) => {
t.error(err)
t.strictEqual(response.statusCode, 200)
Expand Down

0 comments on commit d0d6a34

Please sign in to comment.