Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.0 v1 sync #114

Merged
merged 35 commits into from
Mar 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4e299a0
build: Node.js@18.7
dougwilson Aug 2, 2022
58205b4
build: Node.js@16.16
dougwilson Aug 2, 2022
ac6a759
build: Node.js@14.20
dougwilson Aug 2, 2022
d7a7c4d
build: supertest@6.2.4
dougwilson Aug 4, 2022
03fff1c
build: eslint@8.23.1
dougwilson Sep 23, 2022
9c9a2a2
build: eslint-plugin-markdown@3.0.0
dougwilson Sep 24, 2022
2075428
build: mocha@10.0.0
dougwilson Sep 24, 2022
91a860b
build: Node.js@16.17
dougwilson Sep 24, 2022
0e3ddce
Fix routing requests without method
dougwilson Sep 24, 2022
df7ccba
build: eslint@8.24.0
dougwilson Sep 24, 2022
f76ecfd
build: Node.js@18.9
dougwilson Sep 24, 2022
5a99eb6
build: supertest@6.3.1
dougwilson Oct 25, 2022
806dfe5
build: Node.js@14.21
dougwilson Nov 3, 2022
7b0fad1
build: Node.js@16.18
dougwilson Nov 3, 2022
a8d531b
build: eslint@8.28.0
dougwilson Nov 20, 2022
99b60b1
build: Node.js@18.12
dougwilson Dec 2, 2022
5b4cead
build: support Node.js 19.x
dougwilson Dec 2, 2022
3e79ad9
build: mocha@10.2.0
dougwilson Dec 29, 2022
20b8fc6
build: supertest@6.3.3
dougwilson Dec 29, 2022
ba19a64
build: Node.js@16.19
dougwilson Jan 25, 2023
8cd3849
build: Node.js@18.13
dougwilson Jan 25, 2023
6264a1d
build: eslint@8.32.0
dougwilson Jan 25, 2023
15d9a48
build: Node.js@19.5
dougwilson Jan 25, 2023
5665cf7
build: Node.js@19.7
dougwilson Feb 24, 2023
f06b5f8
build: Node.js@18.14
dougwilson Feb 24, 2023
14bc38f
build: eslint@8.34.0
dougwilson Feb 24, 2023
33a76a9
build: actions/checkout@v3
dougwilson Feb 24, 2023
b4ee44b
build: actions/upload-artifact@v3
dougwilson Feb 24, 2023
1f1dffd
build: use $GITHUB_OUTPUT for environment list
dougwilson Feb 24, 2023
ceddead
build: actions/download-artifact@v3
dougwilson Feb 24, 2023
86a5f76
1.3.8
dougwilson Feb 24, 2023
361202d
build: enable ci workflow trigger
wesleytodd Mar 16, 2024
17086e6
Merge branch 'master' into 2.0-v1-sync
wesleytodd Mar 16, 2024
d40e4b0
build: legacy-peer-deps in new node
wesleytodd Mar 16, 2024
4835526
lint: fix lint in ci
wesleytodd Mar 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 37 additions & 16 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
name: ci

on:
- pull_request
- push
workflow_dispatch:
push:
branches:
- master
pull_request:
types: [opened, synchronize, reopened, ready_for_review]

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
name:
- Node.js 0.10
Expand All @@ -30,6 +35,7 @@ jobs:
- Node.js 16.x
- Node.js 17.x
- Node.js 18.x
- Node.js 19.x

include:
- name: Node.js 0.10
Expand Down Expand Up @@ -70,11 +76,11 @@ jobs:

- name: Node.js 8.x
node-version: "8.17"
npm-i: mocha@7.2.0
npm-i: mocha@7.2.0 nyc@14.1.1

- name: Node.js 9.x
node-version: "9.11"
npm-i: mocha@7.2.0
npm-i: mocha@7.2.0 nyc@14.1.1

- name: Node.js 10.x
node-version: "10.24"
Expand All @@ -86,27 +92,37 @@ jobs:

- name: Node.js 12.x
node-version: "12.22"
npm-i: mocha@9.2.2

- name: Node.js 13.x
node-version: "13.14"
npm-i: mocha@9.2.2

- name: Node.js 14.x
node-version: "14.19"
node-version: "14.21"

- name: Node.js 15.x
node-version: "15.14"
legacy-peer-deps: true

- name: Node.js 16.x
node-version: "16.15"
node-version: "16.19"
legacy-peer-deps: true

- name: Node.js 17.x
node-version: "17.9"
legacy-peer-deps: true

- name: Node.js 18.x
node-version: "18.0"
node-version: "18.14"
legacy-peer-deps: true

- name: Node.js 19.x
node-version: "19.7"
legacy-peer-deps: true

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install Node.js ${{ matrix.node-version }}
shell: bash -eo pipefail -l {0}
Expand All @@ -115,7 +131,12 @@ jobs:
dirname "$(nvm which ${{ matrix.node-version }})" >> "$GITHUB_PATH"

- name: Configure npm
run: npm config set shrinkwrap false
run: |
if [[ "$(npm config get package-lock)" == "true" ]]; then
npm config set package-lock false
else
npm config set shrinkwrap false
fi

- name: Install npm module(s) ${{ matrix.npm-i }}
run: npm install --save-dev ${{ matrix.npm-i }}
Expand All @@ -125,16 +146,16 @@ jobs:
shell: bash
run: |
# eslint for linting
# - remove on Node.js < 10
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 10 ]]; then
# - remove on Node.js < 12
if [[ "$(cut -d. -f1 <<< "${{ matrix.node-version }}")" -lt 12 ]]; then
node -pe 'Object.keys(require("./package").devDependencies).join("\n")' | \
grep -E '^eslint(-|$)' | \
sort -r | \
xargs -n1 npm rm --silent --save-dev
fi

- name: Install Node.js dependencies
run: npm install
run: ${{ matrix.legacy-peer-deps && 'npm install --legacy-peer-deps' || 'npm install' }}

- name: List environment
id: list_env
Expand All @@ -143,7 +164,7 @@ jobs:
echo "node@$(node -v)"
echo "npm@$(npm -v)"
npm -s ls ||:
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print "::set-output name=" $2 "::" $3 }'
(npm -s ls --depth=0 ||:) | awk -F'[ @]' 'NR>1 && $2 { print $2 "=" $3 }' >> "$GITHUB_OUTPUT"

- name: Run tests
shell: bash
Expand All @@ -168,7 +189,7 @@ jobs:
mv "./${{ matrix.name }}" "./coverage/${{ matrix.name }}"
fi
- name: Upload code coverage
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3

if: steps.list_env.outputs.nyc != ''
with:
Expand All @@ -180,14 +201,14 @@ jobs:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Install lcov
shell: bash
run: sudo apt-get -y install lcov

- name: Collect coverage reports
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: coverage
path: ./coverage
Expand Down
7 changes: 6 additions & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
2.x
===

This incorporates all changes after 1.3.5 up to 1.3.7.
This incorporates all changes after 1.3.5 up to 1.3.8.

* Add support for returned, rejected Promises to `router.param`

Expand Down Expand Up @@ -42,6 +42,11 @@ This incorporates all changes after 1.3.3 up to 1.3.5.
- Remove `DEBUG_FD` environment variable support
- Support 256 namespace colors

1.3.8 / 2023-02-24
==================

* Fix routing requests without method

1.3.7 / 2022-04-28
==================

Expand Down
9 changes: 7 additions & 2 deletions lib/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ Route.prototype._handlesMethod = function _handlesMethod (method) {
}

// normalize name
var name = method.toLowerCase()
var name = typeof method === 'string'
? method.toLowerCase()
: method

if (name === 'head' && !this.methods.head) {
name = 'get'
Expand Down Expand Up @@ -104,7 +106,10 @@ Route.prototype.dispatch = function dispatch (req, res, done) {
return done()
}

var method = req.method.toLowerCase()
var method = typeof req.method === 'string'
? req.method.toLowerCase()
: req.method

if (method === 'head' && !this.methods.head) {
method = 'get'
}
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,18 @@
},
"devDependencies": {
"after": "0.8.2",
"eslint": "7.32.0",
"eslint": "8.34.0",
"eslint-config-standard": "14.1.1",
"eslint-plugin-import": "2.26.0",
"eslint-plugin-markdown": "2.2.1",
"eslint-plugin-markdown": "3.0.0",
"eslint-plugin-node": "11.1.0",
"eslint-plugin-promise": "5.2.0",
"eslint-plugin-standard": "4.1.0",
"finalhandler": "1.2.0",
"mocha": "9.2.2",
"mocha": "10.2.0",
"nyc": "15.1.0",
"safe-buffer": "5.2.1",
"supertest": "6.2.3"
"supertest": "6.3.3"
},
"files": [
"lib/",
Expand Down
24 changes: 24 additions & 0 deletions test/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ describe('Router', function () {
.expect(404, cb)
})

it('should route without method', function (done) {
var router = new Router()
var route = router.route('/foo')
var server = createServer(function (req, res, next) {
req.method = undefined
router(req, res, next)
})

route.post(createHitHandle(1))
route.all(createHitHandle(2))
route.get(createHitHandle(3))

router.get('/foo', createHitHandle(4))
router.use(saw)

request(server)
.get('/foo')
.expect(shouldNotHitHandle(1))
.expect(shouldHitHandle(2))
.expect(shouldNotHitHandle(3))
.expect(shouldNotHitHandle(4))
.expect(200, 'saw undefined /foo', done)
})

it('should stack', function (done) {
var cb = after(3, done)
var router = new Router()
Expand Down
Loading