Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f7ffb93

Browse files
authoredAug 15, 2024··
Refactor to use native Node.js modules, support Node.js v20+ and modernize the code (#180)
* refactor: upgrade deps + refactor code to be with oop class style + support node.js 20+ ...etc * fix: add fix for #179 issue
1 parent 31deae8 commit f7ffb93

File tree

10 files changed

+2711
-3090
lines changed

10 files changed

+2711
-3090
lines changed
 

Diff for: ‎.github/workflows/ci.yml

+2-3
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ jobs:
1010
os:
1111
- ubuntu-latest
1212
node_version:
13-
- 14
14-
- 16
15-
- 18
13+
- 20
14+
- 22
1615
name: Node ${{ matrix.node_version }} on ${{ matrix.os }}
1716
steps:
1817
- uses: actions/checkout@v3

Diff for: ‎.xo-config.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ module.exports = {
3232
'unicorn/explicit-length-check': 'warn',
3333
'unicorn/no-array-reduce': 'warn',
3434
'unicorn/prefer-spread': 'warn',
35-
'unicorn/prefer-node-protocol': 'off'
35+
'unicorn/prefer-node-protocol': 'off',
36+
'unicorn/expiring-todo-comments': 'off',
37+
'max-nested-callbacks': 'off'
3638
}
3739
};

Diff for: ‎README.md

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ See [API Reference](./API.md) for more documentation.
6969
| ---------------- |
7070
| **Alex Mingoia** |
7171
| **@koajs** |
72+
| **Imed Jaberi** |
7273

7374

7475
## License

Diff for: ‎bench/server.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,20 @@
1-
const Koa = require('koa');
2-
const Router = require('../');
1+
const process = require('node:process');
32
const env = require('@ladjs/env')({
43
path: '../.env',
54
includeProcessEnv: true,
65
assignToProcessEnv: true
76
});
7+
const Koa = require('koa');
8+
9+
const Router = require('../');
810

911
const app = new Koa();
1012
const router = new Router();
1113

12-
const ok = (ctx) => (ctx.status = 200);
14+
const ok = (ctx) => {
15+
ctx.status = 200;
16+
};
17+
1318
const n = Number.parseInt(env.FACTOR || '10', 10);
1419
const useMiddleware = env.USE_MIDDLEWARE === 'true';
1520

Diff for: ‎lib/layer.js

+192-197
Large diffs are not rendered by default.

Diff for: ‎lib/router.js

+656-678
Large diffs are not rendered by default.

Diff for: ‎package.json

+19-16
Original file line numberDiff line numberDiff line change
@@ -8,41 +8,44 @@
88
"email": "niftylettuce@gmail.com"
99
},
1010
"contributors": [
11-
"Alex Mingoia <talk@alexmingoia.com>",
12-
"@koajs"
11+
{
12+
"name": "Alex Mingoia",
13+
"email": "talk@alexmingoia.com"
14+
},
15+
{
16+
"name": "@koajs"
17+
},
18+
{
19+
"name": "Imed Jaberi",
20+
"email": "imed-jaberi@outlook.com"
21+
}
1322
],
1423
"dependencies": {
15-
"debug": "^4.3.4",
24+
"debug": "^4.3.6",
Has a conversation. Original line has a conversation.
1625
"http-errors": "^2.0.0",
1726
"koa-compose": "^4.1.0",
18-
"methods": "^1.1.2",
19-
"path-to-regexp": "^6.2.1"
27+
"path-to-regexp": "^6.2.2"
2028
},
2129
"devDependencies": {
2230
"@commitlint/cli": "^17.7.2",
2331
"@commitlint/config-conventional": "^17.7.0",
2432
"@ladjs/env": "^4.0.0",
25-
"ava": "^5.3.1",
26-
"cross-env": "^7.0.3",
27-
"eslint": "8.39.0",
33+
"eslint": "^8.39.0",
2834
"eslint-config-xo-lass": "^2.0.1",
29-
"expect.js": "^0.3.1",
3035
"fixpack": "^4.0.0",
3136
"husky": "^8.0.3",
3237
"jsdoc-to-markdown": "^8.0.0",
33-
"koa": "^2.14.2",
38+
"koa": "^2.15.3",
3439
"lint-staged": "^14.0.1",
35-
"mocha": "^10.2.0",
36-
"nyc": "^15.1.0",
40+
"mocha": "^10.7.3",
41+
"nyc": "^17.0.0",
3742
"remark-cli": "11",
3843
"remark-preset-github": "^4.0.4",
39-
"should": "^13.2.3",
40-
"supertest": "^6.3.3",
41-
"wrk": "^1.2.1",
44+
"supertest": "^7.0.0",
4245
"xo": "0.53.1"
4346
},
4447
"engines": {
45-
"node": ">= 12"
48+
"node": ">= 20"
4649
},
4750
"files": [
4851
"lib"

Diff for: ‎test/index.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
11
/**
22
* Module tests
33
*/
4+
const assert = require('node:assert');
45

5-
const should = require('should');
6-
7-
describe('module', function () {
8-
it('should expose Router', function (done) {
6+
describe('module', () => {
7+
it('should expose Router', () => {
98
const Router = require('..');
10-
should.exist(Router);
11-
Router.should.be.type('function');
12-
done();
9+
assert.strictEqual(Boolean(Router), true);
10+
assert.strictEqual(typeof Router, 'function');
1311
});
1412
});

Diff for: ‎test/lib/layer.js

+129-151
Large diffs are not rendered by default.

Diff for: ‎test/lib/router.js

+1,696-2,034
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)
Please sign in to comment.