Skip to content

Commit 5ccbe34

Browse files
build!: require node.js 10x and up (#37)
BREAKING CHANGE: Drops support for node.js 6 and node.js 8.
1 parent 292464c commit 5ccbe34

5 files changed

Lines changed: 37 additions & 42 deletions

File tree

.circleci/config.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@ workflows:
33
version: 2
44
test:
55
jobs:
6-
- node6
7-
- node8
86
- node10
9-
- node11
7+
- node12
8+
- node13
109
- lint
1110
- publish_npm:
1211
requires:
13-
- node6
14-
- node8
1512
- node10
16-
- node11
13+
- node12
14+
- node13
1715
- lint
1816
filters:
1917
branches:
@@ -26,44 +24,39 @@ unit_tests: &unit_tests
2624
- run: npm test
2725

2826
jobs:
29-
node6:
30-
docker:
31-
- image: node:6
32-
user: node
33-
<<: *unit_tests
34-
node8:
27+
node10:
3528
docker:
36-
- image: node:8
29+
- image: node:10
3730
user: node
3831
<<: *unit_tests
39-
node10:
32+
node12:
4033
docker:
41-
- image: node:10
34+
- image: node:12
4235
user: node
4336
<<: *unit_tests
44-
node11:
37+
node13:
4538
docker:
46-
- image: node:11
39+
- image: node:13
4740
user: node
4841
<<: *unit_tests
4942
lint:
5043
docker:
51-
- image: node:11
44+
- image: node:13
5245
steps:
5346
- checkout
5447
- run: npm install
5548
- run: npm run lint
5649
coverage:
5750
docker:
58-
- image: node:11
51+
- image: node:13
5952
steps:
6053
- checkout
6154
- run: npm install
6255
- run: npm test
6356
- run: npm run coverage
6457
publish_npm:
6558
docker:
66-
- image: node:11
59+
- image: node:13
6760
steps:
6861
- checkout
6962
- run: npm install

example/app.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const app = express();
66
// Use the yes-https connect middleware. Note - this will only work if NODE_ENV is set to production.
77
app.use(yes());
88

9-
app.get('/', (req, res) => {
10-
res.end('Thanks for checking it out!');
9+
app.get('/', (request, response) => {
10+
response.end('Thanks for checking it out!');
1111
});
1212

1313
const server = app.listen(process.env.PORT || 3000, () => {

lib/index.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ module.exports = function (options) {
33
const maxAge = options.maxAge ? options.maxAge : 86400;
44
const includeSubDomains = options.includeSubDomains === undefined ? true : options.includeSubdomains;
55

6-
return function (req, res, next) {
6+
return function (request, response, next) {
77
let ignoreRequest = (process.env.NODE_ENV !== 'production');
8-
const secure = req.connection.encrypted || (req.get('X-Forwarded-Proto') === 'https');
8+
const secure = request.connection.encrypted || (request.get('X-Forwarded-Proto') === 'https');
99

1010
if (options.ignoreFilter) {
11-
ignoreRequest = ignoreRequest || options.ignoreFilter(req);
11+
ignoreRequest = ignoreRequest || options.ignoreFilter(request);
1212
}
1313

1414
if (ignoreRequest) {
@@ -26,13 +26,13 @@ module.exports = function (options) {
2626
header += '; preload';
2727
}
2828

29-
res.setHeader('Strict-Transport-Security', header);
29+
response.setHeader('Strict-Transport-Security', header);
3030
next();
3131
} else {
32-
res.writeHead(301, {
33-
Location: 'https://' + req.get('host') + req.url
32+
response.writeHead(301, {
33+
Location: 'https://' + request.get('host') + request.url
3434
});
35-
res.end();
35+
response.end();
3636
}
3737
};
3838
};

package.json

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@
2323
},
2424
"homepage": "https://github.com/JustinBeckwith/yes-https#readme",
2525
"devDependencies": {
26-
"express": "^4.16.3",
27-
"mocha": "^6.0.0",
28-
"request": "^2.87.0",
29-
"supertest": "^4.0.0",
30-
"xo": "^0.27.0"
26+
"express": "^4.17.1",
27+
"mocha": "^7.1.1",
28+
"supertest": "^4.0.2",
29+
"xo": "^0.29.0"
3130
},
3231
"xo": {
3332
"overrides": [
@@ -36,5 +35,8 @@
3635
"env": "mocha"
3736
}
3837
]
38+
},
39+
"engines": {
40+
"node": ">=10"
3941
}
4042
}

test/test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ describe('yes', () => {
1111
// Configure a minimal web server with the defaults
1212
const app = express();
1313
app.use(yes());
14-
app.get('/test', (req, res) => {
15-
res.sendStatus(200);
14+
app.get('/test', (request_, response) => {
15+
response.sendStatus(200);
1616
});
1717

1818
// Verify the request returns a 301
@@ -32,8 +32,8 @@ describe('yes', () => {
3232
// Configure a minimal web server with the defaults
3333
const app = express();
3434
app.use(yes());
35-
app.get('/test', (req, res) => {
36-
res.sendStatus(200);
35+
app.get('/test', (_request, response) => {
36+
response.sendStatus(200);
3737
});
3838

3939
// Verify the request returns the right header when using https
@@ -56,13 +56,13 @@ describe('yes', () => {
5656
// Configure a minimal web server with the defaults
5757
const app = express();
5858
app.use(yes({
59-
ignoreFilter: req => {
60-
return (req.url.includes('/_ah/health'));
59+
ignoreFilter: request_ => {
60+
return (request_.url.includes('/_ah/health'));
6161
}
6262
}));
6363

64-
app.get('/_ah/health', (req, res) => {
65-
res.sendStatus(200);
64+
app.get('/_ah/health', (_request, response) => {
65+
response.sendStatus(200);
6666
});
6767

6868
// Verify the request returns a 200 for health checks

0 commit comments

Comments
 (0)