Skip to content
This repository was archived by the owner on Jul 29, 2021. It is now read-only.

Commit 04175c2

Browse files
authored
chore(package): Engine parameter targets node 10+ (#83)
* chore: engine parameter targets node 10+ * chore: Fixing linting errors BREAKING CHANGE: removal of Node 8 support
1 parent 686c4f7 commit 04175c2

File tree

3 files changed

+48
-56
lines changed

3 files changed

+48
-56
lines changed

index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ function defaultResponse (request, response) {
2020
@param {object} [options.protectionConfig] - options passed directly to 'overload-protection' module
2121
*/
2222
module.exports = function (app, options = {}) {
23-
const protectCfg = Object.assign({
23+
const protectCfg = {
2424
production: process.env.NODE_ENV === 'production',
2525
maxHeapUsedBytes: 0, // Maximum heap used threshold (0 to disable) [default 0]
26-
maxRssBytes: 0 // Maximum rss size threshold (0 to disable) [default 0]
27-
}, options.protectionConfig);
26+
maxRssBytes: 0, // Maximum rss size threshold (0 to disable) [default 0]
27+
...options.protectionConfig
28+
};
2829
const readiness = options.readinessURL || READINESS_URL;
2930
const liveness = options.livenessURL || LIVENESS_URL;
3031
const protect = protection('http', protectCfg);

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
"index.js",
2727
"LICENSE"
2828
],
29+
"engines": {
30+
"node": ">= 10"
31+
},
2932
"repository": {
3033
"type": "git",
3134
"url": "git://github.com/nodeshift/kube-probe.git"

test/kube-probe-test.js

+41-53
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,27 @@ const supertest = require('supertest');
66
const connect = require('connect');
77
const probe = require('..');
88

9-
test('test defaults for readiness', t => {
9+
test('test defaults for readiness', async t => {
1010
const app = connect();
1111
probe(app);
1212

13-
supertest(app)
14-
.get('/api/health/readiness')
15-
.expect(200)
16-
.then(response => {
17-
t.equal(response.text, 'OK', 'should just return OK for the text');
18-
t.end();
19-
});
13+
const response = await supertest(app).get('/api/health/readiness').expect(200);
14+
15+
t.equal(response.text, 'OK', 'should just return OK for the text');
16+
t.end();
2017
});
2118

22-
test('test defaults for liveness', t => {
19+
test('test defaults for liveness', async t => {
2320
const app = connect();
2421
probe(app);
2522

26-
supertest(app)
27-
.get('/api/health/liveness')
28-
.expect(200)
29-
.then(response => {
30-
t.equal(response.text, 'OK', 'should just return OK for the text');
31-
t.end();
32-
});
23+
const response = await supertest(app).get('/api/health/liveness').expect(200);
24+
25+
t.equal(response.text, 'OK', 'should just return OK for the text');
26+
t.end();
3327
});
3428

35-
test('test different url and callback for readiness', t => {
29+
test('test different url and callback for readiness', async t => {
3630
const app = connect();
3731
const options = {
3832
readinessURL: '/different/api/ready',
@@ -43,16 +37,13 @@ test('test different url and callback for readiness', t => {
4337

4438
probe(app, options);
4539

46-
supertest(app)
47-
.get('/different/api/ready')
48-
.expect(200)
49-
.then(response => {
50-
t.equal(response.text, 'Different Callback', 'Different Callback shold be the new text');
51-
t.end();
52-
});
40+
const response = await supertest(app).get('/different/api/ready').expect(200);
41+
42+
t.equal(response.text, 'Different Callback', 'Different Callback shold be the new text');
43+
t.end();
5344
});
5445

55-
test('test different url and callback for liveness', t => {
46+
test('test different url and callback for liveness', async t => {
5647
const app = connect();
5748
const options = {
5849
livenessURL: '/different/api/ready',
@@ -63,44 +54,41 @@ test('test different url and callback for liveness', t => {
6354

6455
probe(app, options);
6556

66-
supertest(app)
67-
.get('/different/api/ready')
68-
.expect(200)
69-
.then(response => {
70-
t.equal(response.text, 'Different Callback', 'Different Callback shold be the new text');
71-
t.end();
72-
});
57+
const response = await supertest(app).get('/different/api/ready').expect(200);
58+
59+
t.equal(response.text, 'Different Callback', 'Different Callback should be the new text');
60+
t.end();
7361
});
7462

75-
test('default content type for readiness endpoint', t => {
63+
test('default content type for readiness endpoint', async t => {
7664
t.plan(1);
7765
const app = connect();
7866
probe(app);
79-
supertest(app)
67+
68+
const response = await supertest(app)
8069
.get('/api/health/readiness')
8170
.expect(200)
82-
.expect('Content-Type', /text\/html/)
83-
.then(response => {
84-
t.strictEqual(response.text, 'OK', 'expected response');
85-
t.end();
86-
});
71+
.expect('Content-Type', /text\/html/);
72+
73+
t.strictEqual(response.text, 'OK', 'expected response');
74+
t.end();
8775
});
8876

89-
test('default content type for liveness endpoint', t => {
77+
test('default content type for liveness endpoint', async t => {
9078
t.plan(1);
9179
const app = connect();
9280
probe(app);
93-
supertest(app)
81+
82+
const response = await supertest(app)
9483
.get('/api/health/liveness')
9584
.expect(200)
96-
.expect('Content-Type', /text\/html/)
97-
.then(response => {
98-
t.strictEqual(response.text, 'OK', 'expected response');
99-
t.end();
100-
});
85+
.expect('Content-Type', /text\/html/);
86+
87+
t.strictEqual(response.text, 'OK', 'expected response');
88+
t.end();
10189
});
10290

103-
test('custom content type for liveness endpoint', t => {
91+
test('custom content type for liveness endpoint', async t => {
10492
t.plan(1);
10593
const app = connect();
10694
probe(app, {
@@ -109,12 +97,12 @@ test('custom content type for liveness endpoint', t => {
10997
response.end(JSON.stringify({status: 'OK'}));
11098
}
11199
});
112-
supertest(app)
100+
101+
const response = await supertest(app)
113102
.get('/api/health/liveness')
114103
.expect(200)
115-
.expect('Content-Type', /json/)
116-
.then(response => {
117-
t.strictEqual(response.body.status, 'OK', 'expected response');
118-
t.end();
119-
});
104+
.expect('Content-Type', /json/);
105+
106+
t.strictEqual(response.body.status, 'OK', 'expected response');
107+
t.end();
120108
});

0 commit comments

Comments
 (0)