mirror of
https://github.com/expressjs/express.git
synced 2026-02-27 19:20:15 +00:00
Compare commits
152 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b4ab7d65d7 | ||
|
|
c4cc78bdf5 | ||
|
|
925a1dff1e | ||
|
|
9c85a25c02 | ||
|
|
1140301f6a | ||
|
|
c76ed5ae05 | ||
|
|
2d4192ebb3 | ||
|
|
66404b347a | ||
|
|
d12772393c | ||
|
|
6b7ccfcf12 | ||
|
|
c9ecf7b658 | ||
|
|
a479419b16 | ||
|
|
5a4568abfe | ||
|
|
912893c07c | ||
|
|
ae265a90c7 | ||
|
|
9a3f7ff412 | ||
|
|
2cd372e34c | ||
|
|
04d3a49976 | ||
|
|
bc7d155f53 | ||
|
|
00bb633ca6 | ||
|
|
3c0ad4e8dc | ||
|
|
4ae96bdf5e | ||
|
|
6cd404eb28 | ||
|
|
3e81873b52 | ||
|
|
b5aae87594 | ||
|
|
b8fc000f31 | ||
|
|
c2fb76e99f | ||
|
|
9eb700151b | ||
|
|
dbac741a49 | ||
|
|
697547cde6 | ||
|
|
4007ad103b | ||
|
|
2f64f68c37 | ||
|
|
ed0ba3f1dc | ||
|
|
8eace4603c | ||
|
|
30bae81027 | ||
|
|
758d4355d4 | ||
|
|
77bcd5274a | ||
|
|
f33caf1f89 | ||
|
|
54af593b73 | ||
|
|
2551a7d8af | ||
|
|
4453d83cca | ||
|
|
db507669ca | ||
|
|
374fc1a0f9 | ||
|
|
1b196c8b82 | ||
|
|
64e7373d69 | ||
|
|
e4fb370ad8 | ||
|
|
60d4c16cc9 | ||
|
|
9e6760e186 | ||
|
|
ffa89f2ccf | ||
|
|
b9b9f52b2f | ||
|
|
9a7afb2886 | ||
|
|
2eb42059f3 | ||
|
|
aa907945cd | ||
|
|
89f198c6a5 | ||
|
|
d9a62f9833 | ||
|
|
8f21493cc5 | ||
|
|
6616e39d4d | ||
|
|
ed64290e4a | ||
|
|
b52ff7ca60 | ||
|
|
9420cd3f9b | ||
|
|
ef5f2e13ef | ||
|
|
c5b8d55a6a | ||
|
|
7a9311216a | ||
|
|
b0ed15b452 | ||
|
|
3910323d09 | ||
|
|
98c85eb0dd | ||
|
|
a039e49175 | ||
|
|
ffc562c7d1 | ||
|
|
52872b84ca | ||
|
|
b8ab46594d | ||
|
|
fedd60e642 | ||
|
|
99a0bd3354 | ||
|
|
dfd1851245 | ||
|
|
9f4dbe3a13 | ||
|
|
9784321e89 | ||
|
|
ee1ef41bd3 | ||
|
|
1ca803dd55 | ||
|
|
73555815b9 | ||
|
|
a1161b4686 | ||
|
|
f9954dd317 | ||
|
|
5da5a11a49 | ||
|
|
3dc96995df | ||
|
|
fa40ecfe76 | ||
|
|
cd7d4397c3 | ||
|
|
4c4f3ea105 | ||
|
|
cb4c56e9a7 | ||
|
|
7b44e1d850 | ||
|
|
eb6d12587a | ||
|
|
f1a2dc884d | ||
|
|
6b51e8ef97 | ||
|
|
1f311c59d4 | ||
|
|
9e97144222 | ||
|
|
29d09803c1 | ||
|
|
1d63162dbf | ||
|
|
4a2175dfc9 | ||
|
|
0bb00e1906 | ||
|
|
1e359f57fc | ||
|
|
9cbe2c2cbb | ||
|
|
35e15362ab | ||
|
|
90e522ac90 | ||
|
|
59703c2321 | ||
|
|
caa4f68ee8 | ||
|
|
6ed3439584 | ||
|
|
327af123a1 | ||
|
|
d2de128a32 | ||
|
|
2a53336e5d | ||
|
|
a42413d4e3 | ||
|
|
c2f576cbe9 | ||
|
|
99473c593a | ||
|
|
2d589b644a | ||
|
|
85e48bb8c1 | ||
|
|
55869f49a6 | ||
|
|
af7cd90893 | ||
|
|
ae6a4621bc | ||
|
|
8d39345902 | ||
|
|
a5cb681eb8 | ||
|
|
511d9dfca8 | ||
|
|
7f13d572c1 | ||
|
|
62336717bf | ||
|
|
3bbffdc41c | ||
|
|
ff86319ed5 | ||
|
|
1c5cf0fead | ||
|
|
256a3d1527 | ||
|
|
4f952a953b | ||
|
|
41113599af | ||
|
|
6a40af8293 | ||
|
|
246f6f5aee | ||
|
|
b11122be85 | ||
|
|
43020ff275 | ||
|
|
e4a61bd88e | ||
|
|
39f5d633b5 | ||
|
|
52ed64606f | ||
|
|
4e92ac9031 | ||
|
|
9f8589e31c | ||
|
|
cc751cff8f | ||
|
|
805ef52ae6 | ||
|
|
9e3dbb4374 | ||
|
|
b31910c542 | ||
|
|
c70197ad33 | ||
|
|
8cb53ea5c3 | ||
|
|
e162764f0f | ||
|
|
508c74091f | ||
|
|
b274047a5d | ||
|
|
082d6d1253 | ||
|
|
94546a3cc5 | ||
|
|
ab02240336 | ||
|
|
a46cfdc37f | ||
|
|
d14b2de782 | ||
|
|
2027b87a27 | ||
|
|
2cbf22721d | ||
|
|
3e1a1cedb2 | ||
|
|
6340d1509f |
@@ -1,4 +1,4 @@
|
||||
# http://editorconfig.org
|
||||
# https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
|
||||
@@ -8,3 +8,7 @@ rules:
|
||||
indent: [error, 2, { MemberExpression: "off", SwitchCase: 1 }]
|
||||
no-trailing-spaces: error
|
||||
no-unused-vars: [error, { vars: all, args: none, ignoreRestSiblings: true }]
|
||||
no-restricted-globals:
|
||||
- error
|
||||
- name: Buffer
|
||||
message: Use `import { Buffer } from "node:buffer"` instead of the global Buffer.
|
||||
|
||||
17
.github/dependabot.yml
vendored
Normal file
17
.github/dependabot.yml
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
version: 2
|
||||
updates:
|
||||
- package-ecosystem: github-actions
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
|
||||
- package-ecosystem: npm
|
||||
directory: /
|
||||
schedule:
|
||||
interval: monthly
|
||||
time: "23:00"
|
||||
timezone: Europe/London
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
76
.github/workflows/ci.yml
vendored
76
.github/workflows/ci.yml
vendored
@@ -11,8 +11,10 @@ on:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# Cancel in progress workflows
|
||||
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
|
||||
@@ -25,15 +27,16 @@ jobs:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Node.js {{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||
with:
|
||||
node-version: 'lts/*'
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm install --ignore-scripts --only=dev
|
||||
run: npm install --ignore-scripts --include=dev
|
||||
|
||||
- name: Run lint
|
||||
run: npm run lint
|
||||
@@ -43,19 +46,19 @@ jobs:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
node-version: [18, 19, 20, 21, 22]
|
||||
node-version: [18, 19, 20, 21, 22, 23, 24, 25]
|
||||
# Node.js release schedule: https://nodejs.org/en/about/releases/
|
||||
|
||||
name: Node.js ${{ matrix.node-version }} - ${{matrix.os}}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
@@ -74,44 +77,41 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
npm run test-ci
|
||||
cp coverage/lcov.info "coverage/${{ matrix.node-version }}.lcov"
|
||||
|
||||
- name: Collect code coverage
|
||||
run: |
|
||||
mv ./coverage "./${{ matrix.node-version }}"
|
||||
mkdir ./coverage
|
||||
mv "./${{ matrix.node-version }}" "./coverage/${{ matrix.node-version }}"
|
||||
run: npm run test-ci
|
||||
|
||||
- name: Upload code coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }}
|
||||
path: ./coverage/lcov.info
|
||||
retention-days: 1
|
||||
|
||||
coverage:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
checks: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install lcov
|
||||
shell: bash
|
||||
run: sudo apt-get -y install lcov
|
||||
- name: Install lcov
|
||||
shell: bash
|
||||
run: sudo apt-get -y install lcov
|
||||
|
||||
- name: Collect coverage reports
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
- name: Collect coverage reports
|
||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
||||
with:
|
||||
path: ./coverage
|
||||
pattern: coverage-node-*
|
||||
|
||||
- name: Merge coverage reports
|
||||
shell: bash
|
||||
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
|
||||
- name: Merge coverage reports
|
||||
shell: bash
|
||||
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Upload coverage report
|
||||
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
|
||||
with:
|
||||
file: ./lcov.info
|
||||
|
||||
20
.github/workflows/codeql.yml
vendored
20
.github/workflows/codeql.yml
vendored
@@ -19,6 +19,7 @@ on:
|
||||
branches: ["master"]
|
||||
schedule:
|
||||
- cron: "0 0 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
@@ -31,16 +32,25 @@ jobs:
|
||||
actions: read
|
||||
contents: read
|
||||
security-events: write
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
language: [javascript, actions]
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
|
||||
uses: github/codeql-action/init@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
|
||||
with:
|
||||
languages: javascript
|
||||
languages: ${{ matrix.language }}
|
||||
config: |
|
||||
paths-ignore:
|
||||
- test
|
||||
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||
# By default, queries listed here will override any specified in a config file.
|
||||
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||
@@ -61,6 +71,4 @@ jobs:
|
||||
# ./location_of_script_within_repo/buildscript.sh
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@3ab4101902695724f9365a384f86c1074d94e18c # v3.24.7
|
||||
with:
|
||||
category: "/language:javascript"
|
||||
uses: github/codeql-action/analyze@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
|
||||
|
||||
61
.github/workflows/legacy.yml
vendored
61
.github/workflows/legacy.yml
vendored
@@ -13,6 +13,10 @@ on:
|
||||
pull_request:
|
||||
paths-ignore:
|
||||
- '*.md'
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
# Cancel in progress workflows
|
||||
# in the scenario where we already had a run going for that PR/branch/tag but then triggered a new run
|
||||
@@ -33,12 +37,12 @@ jobs:
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v4
|
||||
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
@@ -57,44 +61,41 @@ jobs:
|
||||
|
||||
- name: Run tests
|
||||
shell: bash
|
||||
run: |
|
||||
npm run test-ci
|
||||
cp coverage/lcov.info "coverage/${{ matrix.node-version }}.lcov"
|
||||
|
||||
- name: Collect code coverage
|
||||
run: |
|
||||
mv ./coverage "./${{ matrix.node-version }}"
|
||||
mkdir ./coverage
|
||||
mv "./${{ matrix.node-version }}" "./coverage/${{ matrix.node-version }}"
|
||||
run: npm run test-ci
|
||||
|
||||
- name: Upload code coverage
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
name: coverage-node-${{ matrix.node-version }}-${{ matrix.os }}
|
||||
path: ./coverage/lcov.info
|
||||
retention-days: 1
|
||||
|
||||
coverage:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
contents: read
|
||||
checks: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Install lcov
|
||||
shell: bash
|
||||
run: sudo apt-get -y install lcov
|
||||
- name: Install lcov
|
||||
shell: bash
|
||||
run: sudo apt-get -y install lcov
|
||||
|
||||
- name: Collect coverage reports
|
||||
uses: actions/download-artifact@v3
|
||||
with:
|
||||
name: coverage
|
||||
path: ./coverage
|
||||
- name: Collect coverage reports
|
||||
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
|
||||
with:
|
||||
path: ./coverage
|
||||
pattern: coverage-node-*
|
||||
|
||||
- name: Merge coverage reports
|
||||
shell: bash
|
||||
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./coverage/lcov.info
|
||||
- name: Merge coverage reports
|
||||
shell: bash
|
||||
run: find ./coverage -name lcov.info -exec printf '-a %q\n' {} \; | xargs lcov -o ./lcov.info
|
||||
|
||||
- name: Upload coverage report
|
||||
uses: coverallsapp/github-action@master
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Upload coverage report
|
||||
uses: coverallsapp/github-action@5cbfd81b66ca5d10c19b062c04de0199c215fb6e # v2.3.7
|
||||
with:
|
||||
file: ./lcov.info
|
||||
|
||||
72
.github/workflows/scorecard.yml
vendored
Normal file
72
.github/workflows/scorecard.yml
vendored
Normal file
@@ -0,0 +1,72 @@
|
||||
# This workflow uses actions that are not certified by GitHub. They are provided
|
||||
# by a third-party and are governed by separate terms of service, privacy
|
||||
# policy, and support documentation.
|
||||
|
||||
name: Scorecard supply-chain security
|
||||
on:
|
||||
# For Branch-Protection check. Only the default branch is supported. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#branch-protection
|
||||
branch_protection_rule:
|
||||
# To guarantee Maintained check is occasionally updated. See
|
||||
# https://github.com/ossf/scorecard/blob/main/docs/checks.md#maintained
|
||||
schedule:
|
||||
- cron: '16 21 * * 1'
|
||||
push:
|
||||
branches: [ "master" ]
|
||||
|
||||
# Declare default permissions as read only.
|
||||
permissions: read-all
|
||||
|
||||
jobs:
|
||||
analysis:
|
||||
name: Scorecard analysis
|
||||
runs-on: ubuntu-latest
|
||||
permissions:
|
||||
# Needed to upload the results to code-scanning dashboard.
|
||||
security-events: write
|
||||
# Needed to publish results and get a badge (see publish_results below).
|
||||
id-token: write
|
||||
# Uncomment the permissions below if installing in a private repository.
|
||||
# contents: read
|
||||
# actions: read
|
||||
|
||||
steps:
|
||||
- name: "Checkout code"
|
||||
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: "Run analysis"
|
||||
uses: ossf/scorecard-action@4eaacf0543bb3f2c246792bd56e8cdeffafb205a # v2.4.3
|
||||
with:
|
||||
results_file: results.sarif
|
||||
results_format: sarif
|
||||
# (Optional) "write" PAT token. Uncomment the `repo_token` line below if:
|
||||
# - you want to enable the Branch-Protection check on a *public* repository, or
|
||||
# - you are installing Scorecard on a *private* repository
|
||||
# To create the PAT, follow the steps in https://github.com/ossf/scorecard-action#authentication-with-pat.
|
||||
# repo_token: ${{ secrets.SCORECARD_TOKEN }}
|
||||
|
||||
# Public repositories:
|
||||
# - Publish results to OpenSSF REST API for easy access by consumers
|
||||
# - Allows the repository to include the Scorecard badge.
|
||||
# - See https://github.com/ossf/scorecard-action#publishing-results.
|
||||
# For private repositories:
|
||||
# - `publish_results` will always be set to `false`, regardless
|
||||
# of the value entered here.
|
||||
publish_results: true
|
||||
|
||||
# Upload the results as artifacts (optional). Commenting out will disable uploads of run results in SARIF
|
||||
# format to the repository Actions tab.
|
||||
- name: "Upload artifact"
|
||||
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
|
||||
with:
|
||||
name: SARIF file
|
||||
path: results.sarif
|
||||
retention-days: 5
|
||||
|
||||
# Upload the results to GitHub's code scanning dashboard.
|
||||
- name: "Upload to code-scanning"
|
||||
uses: github/codeql-action/upload-sarif@b20883b0cd1f46c72ae0ba6d1090936928f9fa30 # v4.32.0
|
||||
with:
|
||||
sarif_file: results.sarif
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -5,6 +5,10 @@ npm-shrinkwrap.json
|
||||
*.log
|
||||
*.gz
|
||||
|
||||
# Yarn
|
||||
yarn-error.log
|
||||
yarn.lock
|
||||
|
||||
# Coveralls
|
||||
.nyc_output
|
||||
coverage
|
||||
|
||||
92
Charter.md
92
Charter.md
@@ -1,92 +0,0 @@
|
||||
# Express Charter
|
||||
|
||||
## Section 0: Guiding Principles
|
||||
|
||||
The Express project is part of the OpenJS Foundation which operates
|
||||
transparently, openly, collaboratively, and ethically.
|
||||
Project proposals, timelines, and status must not merely be open, but
|
||||
also easily visible to outsiders.
|
||||
|
||||
## Section 1: Scope
|
||||
|
||||
Express is a HTTP web server framework with a simple and expressive API
|
||||
which is highly aligned with Node.js core. We aim to be the best in
|
||||
class for writing performant, spec compliant, and powerful web servers
|
||||
in Node.js. As one of the oldest and most popular web frameworks in
|
||||
the ecosystem, we have an important place for new users and experts
|
||||
alike.
|
||||
|
||||
### 1.1: In-scope
|
||||
|
||||
Express is made of many modules spread between three GitHub Orgs:
|
||||
|
||||
- [expressjs](http://github.com/expressjs/): Top level middleware and
|
||||
libraries
|
||||
- [pillarjs](http://github.com/pillarjs/): Components which make up
|
||||
Express but can also be used for other web frameworks
|
||||
- [jshttp](http://github.com/jshttp/): Low level HTTP libraries
|
||||
|
||||
### 1.2: Out-of-Scope
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
## Section 2: Relationship with OpenJS Foundation CPC.
|
||||
|
||||
Technical leadership for the projects within the OpenJS Foundation is
|
||||
delegated to the projects through their project charters by the OpenJS
|
||||
Cross Project Council (CPC). In the case of the Express project, it is
|
||||
delegated to the Express Technical Committee ("TC").
|
||||
|
||||
This Technical Committee is in charge of both the day-to-day operations
|
||||
of the project, as well as its technical management. This charter can
|
||||
be amended by the TC requiring at least two approvals and a minimum two
|
||||
week comment period for other TC members or CPC members to object. Any
|
||||
changes the CPC wishes to propose will be considered a priority but
|
||||
will follow the same process.
|
||||
|
||||
### 2.1 Other Formal Project Relationships
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
## Section 3: Express Governing Body
|
||||
|
||||
The Express project is managed by the Technical Committee ("TC").
|
||||
Members can be added to the TC at any time. Any committer can nominate
|
||||
another committer to the TC and the TC uses its standard consensus
|
||||
seeking process to evaluate whether or not to add this new member.
|
||||
Members who do not participate consistently at the level of a majority
|
||||
of the other members are expected to resign.
|
||||
|
||||
## Section 4: Roles & Responsibilities
|
||||
|
||||
The Express TC manages all aspects of both the technical and community
|
||||
parts of the project. Members of the TC should attend the regular
|
||||
meetings when possible, and be available for discussion of time
|
||||
sensitive or important issues.
|
||||
|
||||
### Section 4.1 Project Operations & Management
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
### Section 4.2: Decision-making, Voting, and/or Elections
|
||||
|
||||
The Express TC uses a "consensus seeking" process for issues that are
|
||||
escalated to the TC. The group tries to find a resolution that has no
|
||||
open objections among TC members. If a consensus cannot be reached
|
||||
that has no objections then a majority wins vote is called. It is also
|
||||
expected that the majority of decisions made by the TC are via a
|
||||
consensus seeking process and that voting is only used as a last-resort.
|
||||
|
||||
Resolution may involve returning the issue to committers with
|
||||
suggestions on how to move forward towards a consensus. It is not
|
||||
expected that a meeting of the TC will resolve all issues on its
|
||||
agenda during that meeting and may prefer to continue the discussion
|
||||
happening among the committers.
|
||||
|
||||
### Section 4.3: Other Project Roles
|
||||
|
||||
Section Intentionally Left Blank
|
||||
|
||||
## Section 5: Definitions
|
||||
|
||||
Section Intentionally Left Blank
|
||||
@@ -1,139 +0,0 @@
|
||||
# Contributor Covenant Code of Conduct
|
||||
|
||||
As a member of the Open JS Foundation, Express has adopted the
|
||||
[Contributor Covenant 2.0][cc-20-doc].
|
||||
|
||||
If an issue arises and you cannot resolve it directly with the parties
|
||||
involved, you can report it to the Express project TC through the following
|
||||
email: express-coc@lists.openjsf.org
|
||||
|
||||
In addition, the OpenJS Foundation maintains a Code of Conduct Panel (CoCP).
|
||||
This is a foundation-wide team established to manage escalation when a reporter
|
||||
believes that a report to a member project or the CPC has not been properly
|
||||
handled. In order to escalate to the CoCP send an email to
|
||||
coc-escalation@lists.openjsf.org.
|
||||
|
||||
## Our Pledge
|
||||
|
||||
We as members, contributors, and leaders pledge to make participation in our
|
||||
community a harassment-free experience for everyone, regardless of age, body
|
||||
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
||||
identity and expression, level of experience, education, socio-economic status,
|
||||
nationality, personal appearance, race, religion, or sexual identity and
|
||||
orientation.
|
||||
|
||||
We pledge to act and interact in ways that contribute to an open, welcoming,
|
||||
diverse, inclusive, and healthy community.
|
||||
|
||||
## Our Standards
|
||||
|
||||
Examples of behavior that contributes to a positive environment for our
|
||||
community include:
|
||||
|
||||
* Demonstrating empathy and kindness toward other people
|
||||
* Being respectful of differing opinions, viewpoints, and experiences
|
||||
* Giving and gracefully accepting constructive feedback
|
||||
* Accepting responsibility and apologizing to those affected by our mistakes,
|
||||
and learning from the experience
|
||||
* Focusing on what is best not just for us as individuals, but for the overall
|
||||
community
|
||||
|
||||
Examples of unacceptable behavior include:
|
||||
|
||||
* The use of sexualized language or imagery, and sexual attention or advances
|
||||
of any kind
|
||||
* Trolling, insulting or derogatory comments, and personal or political attacks
|
||||
* Public or private harassment
|
||||
* Publishing others' private information, such as a physical or email address,
|
||||
without their explicit permission
|
||||
* Other conduct which could reasonably be considered inappropriate in a
|
||||
professional setting
|
||||
|
||||
## Enforcement Responsibilities
|
||||
|
||||
Community leaders are responsible for clarifying and enforcing our standards of
|
||||
acceptable behavior and will take appropriate and fair corrective action in
|
||||
response to any behavior that they deem inappropriate, threatening, offensive,
|
||||
or harmful.
|
||||
|
||||
Community leaders have the right and responsibility to remove, edit, or reject
|
||||
comments, commits, code, wiki edits, issues, and other contributions that are
|
||||
not aligned to this Code of Conduct, and will communicate reasons for
|
||||
moderation decisions when appropriate.
|
||||
|
||||
## Scope
|
||||
|
||||
This Code of Conduct applies within all community spaces, and also applies when
|
||||
an individual is officially representing the community in public spaces.
|
||||
Examples of representing our community include using an official e-mail
|
||||
address, posting via an official social media account, or acting as an
|
||||
appointed representative at an online or offline event.
|
||||
|
||||
## Enforcement
|
||||
|
||||
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||
reported to the community leaders responsible for enforcement at
|
||||
express-coc@lists.openjsf.org. All complaints will be reviewed and
|
||||
investigated promptly and fairly.
|
||||
|
||||
All community leaders are obligated to respect the privacy and security of the
|
||||
reporter of any incident.
|
||||
|
||||
## Enforcement Guidelines
|
||||
|
||||
Community leaders will follow these Community Impact Guidelines in determining
|
||||
the consequences for any action they deem in violation of this Code of Conduct:
|
||||
|
||||
### 1. Correction
|
||||
|
||||
**Community Impact**: Use of inappropriate language or other behavior deemed
|
||||
unprofessional or unwelcome in the community.
|
||||
|
||||
**Consequence**: A private, written warning from community leaders, providing
|
||||
clarity around the nature of the violation and an explanation of why the
|
||||
behavior was inappropriate. A public apology may be requested.
|
||||
|
||||
### 2. Warning
|
||||
|
||||
**Community Impact**: A violation through a single incident or series of
|
||||
actions.
|
||||
|
||||
**Consequence**: A warning with consequences for continued behavior. No
|
||||
interaction with the people involved, including unsolicited interaction with
|
||||
those enforcing the Code of Conduct, for a specified period of time. This
|
||||
includes avoiding interactions in community spaces as well as external channels
|
||||
like social media. Violating these terms may lead to a temporary or permanent
|
||||
ban.
|
||||
|
||||
### 3. Temporary Ban
|
||||
|
||||
**Community Impact**: A serious violation of community standards, including
|
||||
sustained inappropriate behavior.
|
||||
|
||||
**Consequence**: A temporary ban from any sort of interaction or public
|
||||
communication with the community for a specified period of time. No public or
|
||||
private interaction with the people involved, including unsolicited
|
||||
interaction with those enforcing the Code of Conduct, is allowed during this
|
||||
period. Violating these terms may lead to a permanent ban.
|
||||
|
||||
### 4. Permanent Ban
|
||||
|
||||
**Community Impact**: Demonstrating a pattern of violation of community
|
||||
standards, including sustained inappropriate behavior, harassment of an
|
||||
individual, or aggression toward or disparagement of classes of individuals.
|
||||
|
||||
**Consequence**: A permanent ban from any sort of public interaction within the
|
||||
project community.
|
||||
|
||||
## Attribution
|
||||
|
||||
This Code of Conduct is adapted from the [Contributor Covenant, version 2.0][cc-20-doc].
|
||||
|
||||
Community Impact Guidelines were inspired by
|
||||
[Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
|
||||
|
||||
[cc-20-doc]: https://www.contributor-covenant.org/version/2/0/code_of_conduct/
|
||||
|
||||
For answers to common questions about this code of conduct, see the FAQ at
|
||||
https://www.contributor-covenant.org/faq. Translations are available at
|
||||
https://www.contributor-covenant.org/translations.
|
||||
@@ -1,51 +0,0 @@
|
||||
# Express Collaborator Guide
|
||||
|
||||
## Website Issues
|
||||
|
||||
Open issues for the expressjs.com website in https://github.com/expressjs/expressjs.com.
|
||||
|
||||
## PRs and Code contributions
|
||||
|
||||
* Tests must pass.
|
||||
* Follow the [JavaScript Standard Style](http://standardjs.com/) and `npm run lint`.
|
||||
* If you fix a bug, add a test.
|
||||
|
||||
## Branches
|
||||
|
||||
Use the `master` branch for bug fixes or minor work that is intended for the
|
||||
current release stream.
|
||||
|
||||
Use the correspondingly named branch, e.g. `5.0`, for anything intended for
|
||||
a future release of Express.
|
||||
|
||||
## Steps for contributing
|
||||
|
||||
1. [Create an issue](https://github.com/expressjs/express/issues/new) for the
|
||||
bug you want to fix or the feature that you want to add.
|
||||
2. Create your own [fork](https://github.com/expressjs/express) on GitHub, then
|
||||
checkout your fork.
|
||||
3. Write your code in your local copy. It's good practice to create a branch for
|
||||
each new issue you work on, although not compulsory.
|
||||
4. To run the test suite, first install the dependencies by running `npm install`,
|
||||
then run `npm test`.
|
||||
5. Ensure your code is linted by running `npm run lint` -- fix any issue you
|
||||
see listed.
|
||||
6. If the tests pass, you can commit your changes to your fork and then create
|
||||
a pull request from there. Make sure to reference your issue from the pull
|
||||
request comments by including the issue number e.g. `#123`.
|
||||
|
||||
## Issues which are questions
|
||||
|
||||
We will typically close any vague issues or questions that are specific to some
|
||||
app you are writing. Please double check the docs and other references before
|
||||
being trigger happy with posting a question issue.
|
||||
|
||||
Things that will help get your question issue looked at:
|
||||
|
||||
* Full and runnable JS code.
|
||||
* Clear description of the problem or unexpected behavior.
|
||||
* Clear description of the expected result.
|
||||
* Steps you have taken to debug it yourself.
|
||||
|
||||
If you post a question and do not outline the above items or make it easy for
|
||||
us to understand and reproduce your issue, it will be closed.
|
||||
209
Contributing.md
209
Contributing.md
@@ -1,209 +0,0 @@
|
||||
# Express.js Community Contributing Guide 1.0
|
||||
|
||||
The goal of this document is to create a contribution process that:
|
||||
|
||||
* Encourages new contributions.
|
||||
* Encourages contributors to remain involved.
|
||||
* Avoids unnecessary processes and bureaucracy whenever possible.
|
||||
* Creates a transparent decision making process that makes it clear how
|
||||
contributors can be involved in decision making.
|
||||
|
||||
## Vocabulary
|
||||
|
||||
* A **Contributor** is any individual creating or commenting on an issue or pull request.
|
||||
* A **Committer** is a subset of contributors who have been given write access to the repository.
|
||||
* A **Project Captain** is the lead maintainer of a repository.
|
||||
* A **TC (Technical Committee)** is a group of committers representing the required technical
|
||||
expertise to resolve rare disputes.
|
||||
* A **Triager** is a subset of contributors who have been given triage access to the repository.
|
||||
|
||||
## Logging Issues
|
||||
|
||||
Log an issue for any question or problem you might have. When in doubt, log an issue, and
|
||||
any additional policies about what to include will be provided in the responses. The only
|
||||
exception is security disclosures which should be sent privately.
|
||||
|
||||
Committers may direct you to another repository, ask for additional clarifications, and
|
||||
add appropriate metadata before the issue is addressed.
|
||||
|
||||
Please be courteous and respectful. Every participant is expected to follow the
|
||||
project's Code of Conduct.
|
||||
|
||||
## Contributions
|
||||
|
||||
Any change to resources in this repository must be through pull requests. This applies to all changes
|
||||
to documentation, code, binary files, etc. Even long term committers and TC members must use
|
||||
pull requests.
|
||||
|
||||
No pull request can be merged without being reviewed.
|
||||
|
||||
For non-trivial contributions, pull requests should sit for at least 36 hours to ensure that
|
||||
contributors in other timezones have time to review. Consideration should also be given to
|
||||
weekends and other holiday periods to ensure active committers all have reasonable time to
|
||||
become involved in the discussion and review process if they wish.
|
||||
|
||||
The default for each contribution is that it is accepted once no committer has an objection.
|
||||
During a review, committers may also request that a specific contributor who is most versed in a
|
||||
particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off"
|
||||
process for contributions to land. Once all issues brought by committers are addressed it can
|
||||
be landed by any committer.
|
||||
|
||||
In the case of an objection being raised in a pull request by another committer, all involved
|
||||
committers should seek to arrive at a consensus by way of addressing concerns being expressed
|
||||
by discussion, compromise on the proposed change, or withdrawal of the proposed change.
|
||||
|
||||
If a contribution is controversial and committers cannot agree about how to get it to land
|
||||
or if it should land then it should be escalated to the TC. TC members should regularly
|
||||
discuss pending contributions in order to find a resolution. It is expected that only a
|
||||
small minority of issues be brought to the TC for resolution and that discussion and
|
||||
compromise among committers be the default resolution mechanism.
|
||||
|
||||
## Becoming a Triager
|
||||
|
||||
Anyone can become a triager! Read more about the process of being a triager in
|
||||
[the triage process document](Triager-Guide.md).
|
||||
|
||||
Currently, any existing [organization member](https://github.com/orgs/expressjs/people) can nominate
|
||||
a new triager. If you are interested in becoming a triager, our best advice is to actively participate
|
||||
in the community by helping triaging issues and pull requests. As well we recommend
|
||||
to engage in other community activities like attending the TC meetings, and participating in the Slack
|
||||
discussions.
|
||||
|
||||
You can also reach out to any of the [organization members](https://github.com/orgs/expressjs/people)
|
||||
if you have questions or need guidance.
|
||||
|
||||
## Becoming a Committer
|
||||
|
||||
All contributors who land a non-trivial contribution should be on-boarded in a timely manner,
|
||||
and added as a committer, and be given write access to the repository.
|
||||
|
||||
Committers are expected to follow this policy and continue to send pull requests, go through
|
||||
proper review, and have other committers merge their pull requests.
|
||||
|
||||
## TC Process
|
||||
|
||||
The TC uses a "consensus seeking" process for issues that are escalated to the TC.
|
||||
The group tries to find a resolution that has no open objections among TC members.
|
||||
If a consensus cannot be reached that has no objections then a majority wins vote
|
||||
is called. It is also expected that the majority of decisions made by the TC are via
|
||||
a consensus seeking process and that voting is only used as a last-resort.
|
||||
|
||||
Resolution may involve returning the issue to project captains with suggestions on
|
||||
how to move forward towards a consensus. It is not expected that a meeting of the TC
|
||||
will resolve all issues on its agenda during that meeting and may prefer to continue
|
||||
the discussion happening among the project captains.
|
||||
|
||||
Members can be added to the TC at any time. Any TC member can nominate another committer
|
||||
to the TC and the TC uses its standard consensus seeking process to evaluate whether or
|
||||
not to add this new member. The TC will consist of a minimum of 3 active members and a
|
||||
maximum of 10. If the TC should drop below 5 members the active TC members should nominate
|
||||
someone new. If a TC member is stepping down, they are encouraged (but not required) to
|
||||
nominate someone to take their place.
|
||||
|
||||
TC members will be added as admin's on the Github orgs, npm orgs, and other resources as
|
||||
necessary to be effective in the role.
|
||||
|
||||
To remain "active" a TC member should have participation within the last 12 months and miss
|
||||
no more than six consecutive TC meetings. Our goal is to increase participation, not punish
|
||||
people for any lack of participation, this guideline should be only be used as such
|
||||
(replace an inactive member with a new active one, for example). Members who do not meet this
|
||||
are expected to step down. If A TC member does not step down, an issue can be opened in the
|
||||
discussions repo to move them to inactive status. TC members who step down or are removed due
|
||||
to inactivity will be moved into inactive status.
|
||||
|
||||
Inactive status members can become active members by self nomination if the TC is not already
|
||||
larger than the maximum of 10. They will also be given preference if, while at max size, an
|
||||
active member steps down.
|
||||
|
||||
## Project Captains
|
||||
|
||||
The Express TC can designate captains for individual projects/repos in the
|
||||
organizations. These captains are responsible for being the primary
|
||||
day-to-day maintainers of the repo on a technical and community front.
|
||||
Repo captains are empowered with repo ownership and package publication rights.
|
||||
When there are conflicts, especially on topics that effect the Express project
|
||||
at large, captains are responsible to raise it up to the TC and drive
|
||||
those conflicts to resolution. Captains are also responsible for making sure
|
||||
community members follow the community guidelines, maintaining the repo
|
||||
and the published package, as well as in providing user support.
|
||||
|
||||
Like TC members, Repo captains are a subset of committers.
|
||||
|
||||
To become a captain for a project the candidate is expected to participate in that
|
||||
project for at least 6 months as a committer prior to the request. They should have
|
||||
helped with code contributions as well as triaging issues. They are also required to
|
||||
have 2FA enabled on both their GitHub and npm accounts. Any TC member or existing
|
||||
captain on the repo can nominate another committer to the captain role, submit a PR to
|
||||
this doc, under `Current Project Captains` section (maintaining the sort order) with
|
||||
the project, their GitHub handle and npm username (if different). The PR will require
|
||||
at least 2 approvals from TC members and 2 weeks hold time to allow for comment and/or
|
||||
dissent. When the PR is merged, a TC member will add them to the proper GitHub/npm groups.
|
||||
|
||||
### Active Projects and Captains
|
||||
|
||||
- `expressjs/badgeboard`: @wesleytodd
|
||||
- `expressjs/basic-auth-connect`: N/A
|
||||
- `expressjs/body-parser`: @wesleytodd, @jonchurch
|
||||
- `expressjs/compression`: N/A
|
||||
- `expressjs/connect-multiparty`: N/A
|
||||
- `expressjs/cookie-parser`: @wesleytodd, @UlisesGascon
|
||||
- `expressjs/cookie-session`: N/A
|
||||
- `expressjs/cors`: @jonchurch
|
||||
- `expressjs/discussions`: @wesleytodd
|
||||
- `expressjs/errorhandler`: N/A
|
||||
- `expressjs/express-paginate`: N/A
|
||||
- `expressjs/express`: @wesleytodd
|
||||
- `expressjs/expressjs.com`: @crandmck, @jonchurch
|
||||
- `expressjs/flash`: N/A
|
||||
- `expressjs/generator`: @wesleytodd
|
||||
- `expressjs/method-override`: N/A
|
||||
- `expressjs/morgan`: @jonchurch
|
||||
- `expressjs/multer`: @LinusU
|
||||
- `expressjs/response-time`: @blakeembrey
|
||||
- `expressjs/serve-favicon`: N/A
|
||||
- `expressjs/serve-index`: N/A
|
||||
- `expressjs/serve-static`: N/A
|
||||
- `expressjs/session`: N/A
|
||||
- `expressjs/statusboard`: @wesleytodd
|
||||
- `expressjs/timeout`: N/A
|
||||
- `expressjs/vhost`: N/A
|
||||
- `jshttp/accepts`: @blakeembrey
|
||||
- `jshttp/basic-auth`: @blakeembrey
|
||||
- `jshttp/compressible`: @blakeembrey
|
||||
- `jshttp/content-disposition`: @blakeembrey
|
||||
- `jshttp/content-type`: @blakeembrey
|
||||
- `jshttp/cookie`: @wesleytodd
|
||||
- `jshttp/etag`: @blakeembrey
|
||||
- `jshttp/forwarded`: @blakeembrey
|
||||
- `jshttp/fresh`: @blakeembrey
|
||||
- `jshttp/http-assert`: @wesleytodd, @jonchurch
|
||||
- `jshttp/http-errors`: @wesleytodd, @jonchurch
|
||||
- `jshttp/media-typer`: @blakeembrey
|
||||
- `jshttp/methods`: @blakeembrey
|
||||
- `jshttp/mime-db`: @blakeembrey, @UlisesGascon
|
||||
- `jshttp/mime-types`: @blakeembrey, @UlisesGascon
|
||||
- `jshttp/negotiator`: @blakeembrey
|
||||
- `jshttp/on-finished`: @wesleytodd
|
||||
- `jshttp/on-headers`: @blakeembrey
|
||||
- `jshttp/proxy-addr`: @wesleytodd
|
||||
- `jshttp/range-parser`: @blakeembrey
|
||||
- `jshttp/statuses`: @blakeembrey
|
||||
- `jshttp/type-is`: @blakeembrey
|
||||
- `jshttp/vary`: @blakeembrey
|
||||
- `pillarjs/cookies`: @blakeembrey
|
||||
- `pillarjs/csrf`: N/A
|
||||
- `pillarjs/encodeurl`: @blakeembrey
|
||||
- `pillarjs/finalhandler`: @wesleytodd
|
||||
- `pillarjs/hbs`: N/A
|
||||
- `pillarjs/multiparty`: @blakeembrey
|
||||
- `pillarjs/parseurl`: @blakeembrey
|
||||
- `pillarjs/path-to-regexp`: @blakeembrey
|
||||
- `pillarjs/request`: @wesleytodd
|
||||
- `pillarjs/resolve-path`: @blakeembrey
|
||||
- `pillarjs/router`: @blakeembrey
|
||||
- `pillarjs/send`: @blakeembrey
|
||||
- `pillarjs/understanding-csrf`: N/A
|
||||
|
||||
### Current Initiative Captains
|
||||
|
||||
- Triage team [ref](https://github.com/expressjs/discussions/issues/227): @UlisesGascon
|
||||
58
History.md
58
History.md
@@ -1,3 +1,60 @@
|
||||
# Unreleased Changes
|
||||
|
||||
## 🚀 Improvements
|
||||
|
||||
* Improve HTML structure in `res.redirect()` responses when HTML format is accepted by adding `<!DOCTYPE html>`, `<title>`, and `<body>` tags for better browser compatibility - by [@Bernice55231](https://github.com/Bernice55231) in [#5167](https://github.com/expressjs/express/pull/5167)
|
||||
|
||||
* When calling `app.render` with options set to null, the locals object is handled correctly, preventing unexpected errors and making the method behave the same as when options is omitted or an empty object is passed - by [AkaHarshit](https://github.com/AkaHarshit) in [#6903](https://github.com/expressjs/express/pull/6903)
|
||||
|
||||
```js
|
||||
app.render('index', null, callback); // now works as expected
|
||||
```
|
||||
|
||||
## ⚡ Performance
|
||||
|
||||
* Avoid duplicate Content-Type header processing in `res.send()` when sending string responses without an explicit Content-Type header - by [@bjohansebas](https://github.com/bjohansebas) in [#6991](https://github.com/expressjs/express/pull/6991)
|
||||
|
||||
5.2.1 / 2025-12-01
|
||||
=======================
|
||||
|
||||
* Revert security fix for [CVE-2024-51999](https://www.cve.org/CVERecord?id=CVE-2024-51999) ([GHSA-pj86-cfqh-vqx6](https://github.com/expressjs/express/security/advisories/GHSA-pj86-cfqh-vqx6))
|
||||
* The prior release (5.2.0) included an erroneous breaking change related to the extended query parser. There is no actual security vulnerability associated with this behavior (CVE-2024-51999 has been rejected). The change has been fully reverted in this release.
|
||||
|
||||
5.2.0 / 2025-12-01
|
||||
========================
|
||||
|
||||
* Security fix for [CVE-2024-51999](https://www.cve.org/CVERecord?id=CVE-2024-51999) ([GHSA-pj86-cfqh-vqx6](https://github.com/expressjs/express/security/advisories/GHSA-pj86-cfqh-vqx6))
|
||||
* deps: `body-parser@^2.2.1`
|
||||
* A deprecation warning was added when using `res.redirect` with undefined arguments, Express now emits a warning to help detect calls that pass undefined as the status or URL and make them easier to fix.
|
||||
|
||||
5.1.0 / 2025-03-31
|
||||
========================
|
||||
|
||||
* Add support for `Uint8Array` in `res.send()`
|
||||
* Add support for ETag option in `res.sendFile()`
|
||||
* Add support for multiple links with the same rel in `res.links()`
|
||||
* Add funding field to package.json
|
||||
* perf: use loop for acceptParams
|
||||
* refactor: prefix built-in node module imports
|
||||
* deps: remove `setprototypeof`
|
||||
* deps: remove `safe-buffer`
|
||||
* deps: remove `utils-merge`
|
||||
* deps: remove `methods`
|
||||
* deps: remove `depd`
|
||||
* deps: `debug@^4.4.0`
|
||||
* deps: `body-parser@^2.2.0`
|
||||
* deps: `router@^2.2.0`
|
||||
* deps: `content-type@^1.0.5`
|
||||
* deps: `finalhandler@^2.1.0`
|
||||
* deps: `qs@^6.14.0`
|
||||
* deps: `server-static@2.2.0`
|
||||
* deps: `type-is@2.0.1`
|
||||
|
||||
5.0.1 / 2024-10-08
|
||||
==========
|
||||
|
||||
* Update `cookie` semver lock to address [CVE-2024-47764](https://nvd.nist.gov/vuln/detail/CVE-2024-47764)
|
||||
|
||||
5.0.0 / 2024-09-10
|
||||
=========================
|
||||
* remove:
|
||||
@@ -71,6 +128,7 @@ changes from 5.0.0-alpha.8.
|
||||
- Change `dotfiles` option default to `'ignore'`
|
||||
- Remove `hidden` option; use `dotfiles` option instead
|
||||
- Use `mime-types` for file to content type mapping
|
||||
- Remove `express.static.mime` export; use `mime-types` package instead
|
||||
- deps: send@1.0.0-beta.1
|
||||
|
||||
5.0.0-alpha.8 / 2020-03-25
|
||||
|
||||
125
Readme-Guide.md
125
Readme-Guide.md
@@ -1,125 +0,0 @@
|
||||
# README guidelines
|
||||
|
||||
Every module in the expressjs, pillarjs, and jshttp organizations should have
|
||||
a README file named `README.md`. The purpose of the README is to:
|
||||
|
||||
- Explain the purpose of the module and how to use it.
|
||||
- Act as a landing page (both on GitHub and npmjs.com) for the module to help
|
||||
people find it via search. Middleware module READMEs are also incorporated
|
||||
into https://expressjs.com/en/resources/middleware.html.
|
||||
- Encourage community contributions and participation.
|
||||
|
||||
Use the [README template](https://github.com/expressjs/express/wiki/README-template)
|
||||
to quickly create a new README file.
|
||||
|
||||
## Top-level items
|
||||
|
||||
**Badges** (optional): At the very top (with no subheading), include any
|
||||
applicable badges, such as npm version/downloads, build status, test coverage,
|
||||
and so on. Badges should resolve properly (not display a broken image).
|
||||
|
||||
Possible badges include:
|
||||
- npm version: `[![NPM Version][npm-image]][npm-url]`
|
||||
- npm downloads: `[![NPM Downloads][downloads-image]][downloads-url]`
|
||||
- Build status: `[![Build Status][travis-image]][travis-url]`
|
||||
- Test coverage: `[![Test Coverage][coveralls-image]][coveralls-url]`
|
||||
- Tips: `[![Gratipay][gratipay-image]][gratipay-url]`
|
||||
|
||||
**Summary**: Following badges, provide a one- or two-sentence description of
|
||||
what the module does. This should be the same as the npmjs.org blurb (which
|
||||
comes from the description property of `package.json`). Since npm doesn't
|
||||
handle markdown for the blurb, avoid using markdown in the summary sentence.
|
||||
|
||||
**TOC** (Optional): For longer READMEs, provide a table of contents that has
|
||||
a relative link to each section. A tool such as
|
||||
[doctoc](https://www.npmjs.com/package/doctoc) makes it very easy to generate
|
||||
a TOC.
|
||||
|
||||
## Overview
|
||||
|
||||
Optionally, include a section of one or two paragraphs with more high-level
|
||||
information on what the module does, what problems it solves, why one would
|
||||
use it and how. Don't just repeat what's in the summary.
|
||||
|
||||
## Installation
|
||||
|
||||
Required. This section is typically just:
|
||||
|
||||
```sh
|
||||
$ npm install module-name
|
||||
```
|
||||
|
||||
But include any other steps or requirements.
|
||||
|
||||
NOTE: Use the `sh` code block to make the shell command display properly on
|
||||
the website.
|
||||
|
||||
## Basic use
|
||||
|
||||
- Provide a general description of how to use the module with code sample.
|
||||
Include any important caveats or restrictions.
|
||||
- Explain the most common use cases.
|
||||
- Optional: a simple "hello world" type example (where applicable). This
|
||||
example is in addition to the more comprehensive [example section](#examples)
|
||||
later.
|
||||
|
||||
## API
|
||||
|
||||
Provide complete API documentation.
|
||||
|
||||
Formatting conventions: Each function is listed in a 3rd-level heading (`###`),
|
||||
like this:
|
||||
|
||||
```
|
||||
### Function_name(arg, options [, optional_arg] ... )
|
||||
```
|
||||
|
||||
**Options objects**
|
||||
|
||||
For arguments that are objects (for example, options object), describe the
|
||||
properties in a table, as follows. This matches the formatting used in the
|
||||
[Express API docs](https://expressjs.com/en/4x/api.html).
|
||||
|
||||
|Property | Description | Type | Default|
|
||||
|----------|-----------|------------|-------------|
|
||||
|Name of the property in `monospace`. | Brief description | String, Number, Boolean, etc. | If applicable.|
|
||||
|
||||
If all the properties are required (i.e. there are no defaults), then you
|
||||
can omit the default column.
|
||||
|
||||
Instead of very lengthy descriptions, link out to subsequent paragraphs for
|
||||
more detailed explanation of specific cases (e.g. "When this property is set
|
||||
to 'foobar', xyz happens; see <link to following section >.)
|
||||
|
||||
If there are options properties that are themselves options, use additional
|
||||
tables. See [`trust proxy` and `etag` properties](https://expressjs.com/en/4x/api.html#app.settings.table).
|
||||
|
||||
## Examples
|
||||
|
||||
Every README should have at least one example; ideally more. For code samples,
|
||||
be sure to use the `js` code block, for proper display in the website, e.g.:
|
||||
|
||||
```js
|
||||
var csurf = require('csurf')
|
||||
...
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
What tests are included.
|
||||
|
||||
How to run them.
|
||||
|
||||
The convention for running tests is `npm test`. All our projects should follow
|
||||
this convention.
|
||||
|
||||
## Contributors
|
||||
|
||||
Names of module "owners" (lead developers) and other developers who have
|
||||
contributed.
|
||||
|
||||
## License
|
||||
|
||||
Link to the license, with a short description of what it is, e.g. "MIT" or
|
||||
whatever. Ideally, avoid putting the license text directly in the README; link
|
||||
to it instead.
|
||||
162
Readme.md
162
Readme.md
@@ -1,39 +1,48 @@
|
||||
[](http://expressjs.com/)
|
||||
[](https://expressjs.com/)
|
||||
|
||||
**Fast, unopinionated, minimalist web framework for [Node.js](http://nodejs.org).**
|
||||
**Fast, unopinionated, minimalist web framework for [Node.js](https://nodejs.org).**
|
||||
|
||||
**This project has a [Code of Conduct][].**
|
||||
**This project has a [Code of Conduct].**
|
||||
|
||||
## Table of contents
|
||||
|
||||
* [Installation](#Installation)
|
||||
* [Features](#Features)
|
||||
* [Docs & Community](#docs--community)
|
||||
* [Quick Start](#Quick-Start)
|
||||
* [Running Tests](#Running-Tests)
|
||||
* [Philosophy](#Philosophy)
|
||||
* [Examples](#Examples)
|
||||
* [Contributing to Express](#Contributing)
|
||||
* [TC (Technical Committee)](#tc-technical-committee)
|
||||
* [Triagers](#triagers)
|
||||
* [License](#license)
|
||||
- [Table of contents](#table-of-contents)
|
||||
- [Installation](#installation)
|
||||
- [Features](#features)
|
||||
- [Docs \& Community](#docs--community)
|
||||
- [Quick Start](#quick-start)
|
||||
- [Philosophy](#philosophy)
|
||||
- [Examples](#examples)
|
||||
- [Contributing](#contributing)
|
||||
- [Security Issues](#security-issues)
|
||||
- [Running Tests](#running-tests)
|
||||
- [Current project team members](#current-project-team-members)
|
||||
- [TC (Technical Committee)](#tc-technical-committee)
|
||||
- [TC emeriti members](#tc-emeriti-members)
|
||||
- [Triagers](#triagers)
|
||||
- [Emeritus Triagers](#emeritus-triagers)
|
||||
- [License](#license)
|
||||
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Install Size][npm-install-size-image]][npm-install-size-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-downloads-url]
|
||||
[![Linux Build][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]
|
||||
|
||||
|
||||
```js
|
||||
const express = require('express')
|
||||
import express from 'express'
|
||||
|
||||
const app = express()
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
app.get('/', (req, res) => {
|
||||
res.send('Hello World')
|
||||
})
|
||||
|
||||
app.listen(3000)
|
||||
app.listen(3000, () => {
|
||||
console.log('Server is running on http://localhost:3000')
|
||||
})
|
||||
```
|
||||
|
||||
## Installation
|
||||
@@ -42,7 +51,7 @@ This is a [Node.js](https://nodejs.org/en/) module available through the
|
||||
[npm registry](https://www.npmjs.com/).
|
||||
|
||||
Before installing, [download and install Node.js](https://nodejs.org/en/download/).
|
||||
Node.js 0.10 or higher is required.
|
||||
Node.js 18 or higher is required.
|
||||
|
||||
If this is a brand new project, make sure to create a `package.json` first with
|
||||
the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
|
||||
@@ -50,11 +59,11 @@ the [`npm init` command](https://docs.npmjs.com/creating-a-package-json-file).
|
||||
Installation is done using the
|
||||
[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
|
||||
|
||||
```console
|
||||
$ npm install express
|
||||
```bash
|
||||
npm install express
|
||||
```
|
||||
|
||||
Follow [our installing guide](http://expressjs.com/en/starter/installing.html)
|
||||
Follow [our installing guide](https://expressjs.com/en/starter/installing.html)
|
||||
for more information.
|
||||
|
||||
## Features
|
||||
@@ -69,14 +78,11 @@ for more information.
|
||||
|
||||
## Docs & Community
|
||||
|
||||
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
||||
* [#express](https://web.libera.chat/#express) on [Libera Chat](https://libera.chat) IRC
|
||||
* [Website and Documentation](https://expressjs.com/) - [[website repo](https://github.com/expressjs/expressjs.com)]
|
||||
* [GitHub Organization](https://github.com/expressjs) for Official Middleware & Modules
|
||||
* Visit the [Wiki](https://github.com/expressjs/express/wiki)
|
||||
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
||||
* [Gitter](https://gitter.im/expressjs/express) for support and discussion
|
||||
* [Github Discussions](https://github.com/expressjs/discussions) for discussion on the development and usage of Express
|
||||
|
||||
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/expressjs/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/expressjs/express/wiki/New-features-in-4.x).
|
||||
**PROTIP** Be sure to read the [migration guide to v5](https://expressjs.com/en/guide/migrating-5)
|
||||
|
||||
## Quick Start
|
||||
|
||||
@@ -84,26 +90,26 @@ for more information.
|
||||
|
||||
Install the executable. The executable's major version will match Express's:
|
||||
|
||||
```console
|
||||
$ npm install -g express-generator@4
|
||||
```bash
|
||||
npm install -g express-generator@4
|
||||
```
|
||||
|
||||
Create the app:
|
||||
|
||||
```console
|
||||
$ express /tmp/foo && cd /tmp/foo
|
||||
```bash
|
||||
express /tmp/foo && cd /tmp/foo
|
||||
```
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```console
|
||||
$ npm install
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Start the server:
|
||||
|
||||
```console
|
||||
$ npm start
|
||||
```bash
|
||||
npm start
|
||||
```
|
||||
|
||||
View the website at: http://localhost:3000
|
||||
@@ -115,51 +121,58 @@ $ npm start
|
||||
HTTP APIs.
|
||||
|
||||
Express does not force you to use any specific ORM or template engine. With support for over
|
||||
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
||||
14 template engines via [@ladjs/consolidate](https://github.com/ladjs/consolidate),
|
||||
you can quickly craft your perfect framework.
|
||||
|
||||
## Examples
|
||||
|
||||
To view the examples, clone the Express repo and install the dependencies:
|
||||
To view the examples, clone the Express repository:
|
||||
|
||||
```console
|
||||
$ git clone https://github.com/expressjs/express.git --depth 1
|
||||
$ cd express
|
||||
$ npm install
|
||||
```bash
|
||||
git clone https://github.com/expressjs/express.git --depth 1 && cd express
|
||||
```
|
||||
|
||||
Then install the dependencies:
|
||||
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
Then run whichever example you want:
|
||||
|
||||
```console
|
||||
$ node examples/content-negotiation
|
||||
```bash
|
||||
node examples/content-negotiation
|
||||
```
|
||||
|
||||
## Contributing
|
||||
|
||||
[![Linux Build][github-actions-ci-image]][github-actions-ci-url]
|
||||
[![Windows Build][appveyor-image]][appveyor-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
The Express.js project welcomes all constructive contributions. Contributions take many forms,
|
||||
from code for bug fixes and enhancements, to additions and fixes to documentation, additional
|
||||
tests, triaging incoming pull requests and issues, and more!
|
||||
|
||||
See the [Contributing Guide](Contributing.md) for more technical details on contributing.
|
||||
See the [Contributing Guide] for more technical details on contributing.
|
||||
|
||||
### Security Issues
|
||||
|
||||
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](Security.md).
|
||||
If you discover a security vulnerability in Express, please see [Security Policies and Procedures](https://github.com/expressjs/express/security/policy).
|
||||
|
||||
### Running Tests
|
||||
|
||||
To run the test suite, first install the dependencies, then run `npm test`:
|
||||
To run the test suite, first install the dependencies:
|
||||
|
||||
```console
|
||||
$ npm install
|
||||
$ npm test
|
||||
```bash
|
||||
npm install
|
||||
```
|
||||
|
||||
## People
|
||||
Then run `npm test`:
|
||||
|
||||
```bash
|
||||
npm test
|
||||
```
|
||||
|
||||
## Current project team members
|
||||
|
||||
For information about the governance of the express.js project, see [GOVERNANCE.md](https://github.com/expressjs/discussions/blob/HEAD/docs/GOVERNANCE.md).
|
||||
|
||||
The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||
|
||||
@@ -192,18 +205,16 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||
### Triagers
|
||||
|
||||
* [aravindvnair99](https://github.com/aravindvnair99) - **Aravind Nair**
|
||||
* [bjohansebas](https://github.com/bjohansebas) - **Sebastian Beltran**
|
||||
* [carpasse](https://github.com/carpasse) - **Carlos Serrano**
|
||||
* [CBID2](https://github.com/CBID2) - **Christine Belzie**
|
||||
* [enyoghasim](https://github.com/enyoghasim) - **David Enyoghasim**
|
||||
* [UlisesGascon](https://github.com/UlisesGascon) - **Ulises Gascón** (he/him)
|
||||
* [mertcanaltin](https://github.com/mertcanaltin) - **Mert Can Altin**
|
||||
* [0ss](https://github.com/0ss) - **Salah**
|
||||
* [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)
|
||||
* [3imed-jaberi](https://github.com/3imed-jaberi) - **Imed Jaberi**
|
||||
* [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)
|
||||
* [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**
|
||||
* [IamLizu](https://github.com/IamLizu) - **S M Mahmudul Hasan** (he/him)
|
||||
* [Sushmeet](https://github.com/Sushmeet) - **Sushmeet Sunger**
|
||||
* [Phillip9587](https://github.com/Phillip9587) - **Phillip Barta**
|
||||
* [efekrskl](https://github.com/efekrskl) - **Efe Karasakal**
|
||||
* [rxmarbles](https://github.com/rxmarbles) - **Rick Markins** (he/him)
|
||||
* [krzysdz](https://github.com/krzysdz)
|
||||
* [GroophyLifefor](https://github.com/GroophyLifefor) - **Murat Kirazkaya**
|
||||
|
||||
<details>
|
||||
<summary>Triagers emeriti members</summary>
|
||||
@@ -236,6 +247,16 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||
* [sheplu](https://github.com/sheplu) - **Jean Burellier**
|
||||
* [tarunyadav1](https://github.com/tarunyadav1) - **Tarun yadav**
|
||||
* [tunniclm](https://github.com/tunniclm) - **Mike Tunnicliffe**
|
||||
* [enyoghasim](https://github.com/enyoghasim) - **David Enyoghasim**
|
||||
* [0ss](https://github.com/0ss) - **Salah**
|
||||
* [import-brain](https://github.com/import-brain) - **Eric Cheng** (he/him)
|
||||
* [dakshkhetan](https://github.com/dakshkhetan) - **Daksh Khetan** (he/him)
|
||||
* [lucasraziel](https://github.com/lucasraziel) - **Lucas Soares Do Rego**
|
||||
* [mertcanaltin](https://github.com/mertcanaltin) - **Mert Can Altin**
|
||||
* [dpopp07](https://github.com/dpopp07) - **Dustin Popp**
|
||||
* [Sushmeet](https://github.com/Sushmeet) - **Sushmeet Sunger**
|
||||
* [3imed-jaberi](https://github.com/3imed-jaberi) - **Imed Jaberi**
|
||||
|
||||
</details>
|
||||
|
||||
|
||||
@@ -243,18 +264,15 @@ The original author of Express is [TJ Holowaychuk](https://github.com/tj)
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[appveyor-image]: https://badgen.net/appveyor/ci/dougwilson/express/master?label=windows
|
||||
[appveyor-url]: https://ci.appveyor.com/project/dougwilson/express
|
||||
[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/express/master
|
||||
[coveralls-image]: https://img.shields.io/coverallsCoverage/github/expressjs/express?branch=master
|
||||
[coveralls-url]: https://coveralls.io/r/expressjs/express?branch=master
|
||||
[github-actions-ci-image]: https://badgen.net/github/checks/expressjs/express/master?label=linux
|
||||
[github-actions-ci-image]: https://img.shields.io/github/actions/workflow/status/expressjs/express/ci.yml?branch=master&label=ci
|
||||
[github-actions-ci-url]: https://github.com/expressjs/express/actions/workflows/ci.yml
|
||||
[npm-downloads-image]: https://badgen.net/npm/dm/express
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/express
|
||||
[npm-downloads-url]: https://npmcharts.com/compare/express?minimal=true
|
||||
[npm-install-size-image]: https://badgen.net/packagephobia/install/express
|
||||
[npm-install-size-url]: https://packagephobia.com/result?p=express
|
||||
[npm-url]: https://npmjs.org/package/express
|
||||
[npm-version-image]: https://badgen.net/npm/v/express
|
||||
[npm-version-image]: https://img.shields.io/npm/v/express
|
||||
[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/express/badge
|
||||
[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/express
|
||||
[Code of Conduct]: https://github.com/expressjs/express/blob/master/Code-Of-Conduct.md
|
||||
[Code of Conduct]: https://github.com/expressjs/.github/blob/HEAD/CODE_OF_CONDUCT.md
|
||||
[Contributing Guide]: https://github.com/expressjs/.github/blob/HEAD/CONTRIBUTING.md
|
||||
|
||||
@@ -1,199 +0,0 @@
|
||||
# Express Release Process
|
||||
|
||||
This document contains the technical aspects of the Express release process. The
|
||||
intended audience is those who have been authorized by the Express Technical
|
||||
Committee (TC) to create, promote and sign official release builds for Express,
|
||||
as npm packages hosted on https://npmjs.com/package/express.
|
||||
|
||||
## Who can make releases?
|
||||
|
||||
Release authorization is given by the Express TC. Once authorized, an individual
|
||||
must have the following access permissions:
|
||||
|
||||
### 1. Github release access
|
||||
|
||||
The individual making the release will need to be a member of the
|
||||
expressjs/express team with Write permission level so they are able to tag the
|
||||
release commit and push changes to the expressjs/express repository
|
||||
(see Steps 4 and 5).
|
||||
|
||||
### 2. npmjs.com release access
|
||||
|
||||
The individual making the release will need to be made an owner on the
|
||||
`express` package on npmjs.com so they are able to publish the release
|
||||
(see Step 6).
|
||||
|
||||
## How to publish a release
|
||||
|
||||
Before publishing, the following preconditions should be met:
|
||||
|
||||
- A release proposal issue or tracking pull request (see "Proposal branch"
|
||||
below) will exist documenting:
|
||||
- the proposed changes
|
||||
- the type of release: patch, minor or major
|
||||
- the version number (according to semantic versioning - http://semver.org)
|
||||
- The proposed changes should be complete.
|
||||
|
||||
There are two main release flows: patch and non-patch.
|
||||
|
||||
The patch flow is for making **patch releases**. As per semantic versioning,
|
||||
patch releases are for simple changes, eg: typo fixes, patch dependency updates,
|
||||
and simple/low-risk bug fixes. Every other type of change is made via the
|
||||
non-patch flow.
|
||||
|
||||
### Branch terminology
|
||||
|
||||
"Master branch"
|
||||
|
||||
- There is a branch in git used for the current major version of Express, named
|
||||
`master`.
|
||||
- This branch contains the completed commits for the next patch release of the
|
||||
current major version.
|
||||
- Releases for the current major version are published from this branch.
|
||||
|
||||
"Version branch"
|
||||
|
||||
- For any given major version of Express (current, previous or next) there is
|
||||
a branch in git for that release named `<major-version>.x` (eg: `4.x`).
|
||||
- This branch points to the commit of the latest tag for the given major version.
|
||||
|
||||
"Release branch"
|
||||
|
||||
- For any given major version of Express, there is a branch used for publishing
|
||||
releases.
|
||||
- For the current major version of Express, the release branch is the
|
||||
"Master branch" named `master`.
|
||||
- For all other major versions of Express, the release branch is the
|
||||
"Version branch" named `<major-version>.x`.
|
||||
|
||||
"Proposal branch"
|
||||
|
||||
- A branch in git representing a proposed new release of Express. This can be a
|
||||
minor or major release, named `<major-version>.0` for a major release,
|
||||
`<major-version>.<minor-version>` for a minor release.
|
||||
- A tracking pull request should exist to document the proposed release,
|
||||
targeted at the appropriate release branch. Prior to opening the tracking
|
||||
pull request the content of the release may have be discussed in an issue.
|
||||
- This branch contains the commits accepted so far that implement the proposal
|
||||
in the tracking pull request.
|
||||
|
||||
### Pre-release Versions
|
||||
|
||||
Alpha and Beta releases are made from a proposal branch. The version number should be
|
||||
incremented to the next minor version with a `-beta` or `-alpha` suffix.
|
||||
For example, if the next beta release is `5.0.1`, the beta release would be `5.0.1-beta.0`.
|
||||
The pre-releases are unstable and not suitable for production use.
|
||||
|
||||
### Patch flow
|
||||
|
||||
In the patch flow, simple changes are committed to the release branch which
|
||||
acts as an ever-present branch for the next patch release of the associated
|
||||
major version of Express.
|
||||
|
||||
The release branch is usually kept in a state where it is ready to release.
|
||||
Releases are made when sufficient time or change has been made to warrant it.
|
||||
This is usually proposed and decided using a github issue.
|
||||
|
||||
### Non-patch flow
|
||||
|
||||
In the non-patch flow, changes are committed to a temporary proposal branch
|
||||
created specifically for that release proposal. The branch is based on the
|
||||
most recent release of the major version of Express that the release targets.
|
||||
|
||||
Releases are made when all the changes on a proposal branch are complete and
|
||||
approved. This is done by merging the proposal branch into the release branch
|
||||
(using a fast-forward merge), tagging it with the new version number and
|
||||
publishing the release package to npmjs.com.
|
||||
|
||||
### Flow
|
||||
|
||||
Below is a detailed description of the steps to publish a release.
|
||||
|
||||
#### Step 1. Check the release is ready to publish
|
||||
|
||||
Check any relevant information to ensure the release is ready, eg: any
|
||||
milestone, label, issue or tracking pull request for the release. The release
|
||||
is ready when all proposed code, tests and documentation updates are complete
|
||||
(either merged, closed or re-targeted to another release).
|
||||
|
||||
#### Step 2. (Non-patch flow only) Merge the proposal branch into the release branch
|
||||
|
||||
In the patch flow: skip this step.
|
||||
|
||||
In the non-patch flow:
|
||||
```sh
|
||||
$ git checkout <release-branch>
|
||||
$ git merge --ff-only <proposal-branch>
|
||||
```
|
||||
|
||||
<release-branch> - see "Release branch" of "Branches" above.
|
||||
<proposal-branch> - see "Proposal branch" of "Non-patch flow" above.
|
||||
|
||||
**NOTE:** You may need to rebase the proposal branch to allow a fast-forward
|
||||
merge. Using a fast-forward merge keeps the history clean as it does
|
||||
not introduce merge commits.
|
||||
|
||||
### Step 3. Update the History.md and package.json to the new version number
|
||||
|
||||
The changes so far for the release should already be documented under the
|
||||
"unreleased" section at the top of the History.md file, as per the usual
|
||||
development practice. Change "unreleased" to the new release version / date.
|
||||
Example diff fragment:
|
||||
|
||||
```diff
|
||||
-unreleased
|
||||
-==========
|
||||
+4.13.3 / 2015-08-02
|
||||
+===================
|
||||
```
|
||||
|
||||
The version property in the package.json should already contain the version of
|
||||
the previous release. Change it to the new release version.
|
||||
|
||||
Commit these changes together under a single commit with the message set to
|
||||
the new release version (eg: `4.13.3`):
|
||||
|
||||
```sh
|
||||
$ git checkout <release-branch>
|
||||
<..edit files..>
|
||||
$ git add History.md package.json
|
||||
$ git commit -m '<version-number>'
|
||||
```
|
||||
|
||||
### Step 4. Identify and tag the release commit with the new release version
|
||||
|
||||
Create a lightweight tag (rather than an annotated tag) named after the new
|
||||
release version (eg: `4.13.3`).
|
||||
|
||||
```sh
|
||||
$ git tag <version-number>
|
||||
```
|
||||
|
||||
### Step 5. Push the release branch changes and tag to github
|
||||
|
||||
The branch and tag should be pushed directly to the main repository
|
||||
(https://github.com/expressjs/express).
|
||||
|
||||
```sh
|
||||
$ git push origin <release-branch>
|
||||
$ git push origin <version-number>
|
||||
```
|
||||
|
||||
### Step 6. Publish to npmjs.com
|
||||
|
||||
Ensure your local working copy is completely clean (no extra or changed files).
|
||||
You can use `git status` for this purpose.
|
||||
|
||||
```sh
|
||||
$ npm login <npm-username>
|
||||
$ npm publish
|
||||
```
|
||||
|
||||
**NOTE:** The version number to publish will be picked up automatically from
|
||||
package.json.
|
||||
|
||||
### Step 7. Update documentation website
|
||||
|
||||
The documentation website https://expressjs.com/ documents the current release version in various places. For a new release:
|
||||
1. Change the value of `current_version` in https://github.com/expressjs/expressjs.com/blob/gh-pages/_data/express.yml to match the latest version number.
|
||||
2. Add a new section to the change log. For example, for a 4.x release, https://github.com/expressjs/expressjs.com/blob/gh-pages/en/changelog/4x.md,
|
||||
56
Security.md
56
Security.md
@@ -1,56 +0,0 @@
|
||||
# Security Policies and Procedures
|
||||
|
||||
This document outlines security procedures and general policies for the Express
|
||||
project.
|
||||
|
||||
* [Reporting a Bug](#reporting-a-bug)
|
||||
* [Disclosure Policy](#disclosure-policy)
|
||||
* [Comments on this Policy](#comments-on-this-policy)
|
||||
|
||||
## Reporting a Bug
|
||||
|
||||
The Express team and community take all security bugs in Express seriously.
|
||||
Thank you for improving the security of Express. We appreciate your efforts and
|
||||
responsible disclosure and will make every effort to acknowledge your
|
||||
contributions.
|
||||
|
||||
Report security bugs by emailing the lead maintainer in the Readme.md file.
|
||||
|
||||
To ensure the timely response to your report, please ensure that the entirety
|
||||
of the report is contained within the email body and not solely behind a web
|
||||
link or an attachment.
|
||||
|
||||
The lead maintainer will acknowledge your email within 48 hours, and will send a
|
||||
more detailed response within 48 hours indicating the next steps in handling
|
||||
your report. After the initial reply to your report, the security team will
|
||||
endeavor to keep you informed of the progress towards a fix and full
|
||||
announcement, and may ask for additional information or guidance.
|
||||
|
||||
Report security bugs in third-party modules to the person or team maintaining
|
||||
the module.
|
||||
|
||||
## Pre-release Versions
|
||||
|
||||
Alpha and Beta releases are unstable and **not suitable for production use**.
|
||||
Vulnerabilities found in pre-releases should be reported according to the [Reporting a Bug](#reporting-a-bug) section.
|
||||
Due to the unstable nature of the branch it is not guaranteed that any fixes will be released in the next pre-release.
|
||||
|
||||
## Disclosure Policy
|
||||
|
||||
When the security team receives a security bug report, they will assign it to a
|
||||
primary handler. This person will coordinate the fix and release process,
|
||||
involving the following steps:
|
||||
|
||||
* Confirm the problem and determine the affected versions.
|
||||
* Audit code to find any potential similar problems.
|
||||
* Prepare fixes for all releases still under maintenance. These fixes will be
|
||||
released as fast as possible to npm.
|
||||
|
||||
## The Express Threat Model
|
||||
|
||||
We are currently working on a new version of the security model, the most updated version can be found [here](https://github.com/expressjs/security-wg/blob/main/docs/ThreatModel.md)
|
||||
|
||||
## Comments on this Policy
|
||||
|
||||
If you have suggestions on how this process could be improved please submit a
|
||||
pull request.
|
||||
@@ -1,70 +0,0 @@
|
||||
# Express Triager Guide
|
||||
|
||||
## Issue Triage Process
|
||||
|
||||
When a new issue or pull request is opened the issue will be labeled with `needs triage`.
|
||||
If a triage team member is available they can help make sure all the required information
|
||||
is provided. Depending on the issue or PR there are several next labels they can add for further
|
||||
classification:
|
||||
|
||||
* `needs triage`: This can be kept if the triager is unsure which next steps to take
|
||||
* `awaiting more info`: If more info has been requested from the author, apply this label.
|
||||
* `bug`: Issues that present a reasonable conviction there is a reproducible bug.
|
||||
* `enhancement`: Issues that are found to be a reasonable candidate feature additions.
|
||||
|
||||
If the issue is a question or discussion, it should be moved to GitHub Discussions.
|
||||
|
||||
### Moving Discussions and Questions to GitHub Discussions
|
||||
|
||||
For issues labeled with `question` or `discuss`, it is recommended to move them to GitHub Discussions instead:
|
||||
|
||||
* **Questions**: User questions that do not appear to be bugs or enhancements should be moved to GitHub Discussions.
|
||||
* **Discussions**: Topics for discussion should be moved to GitHub Discussions. If the discussion leads to a new feature or bug identification, it can be moved back to Issues.
|
||||
|
||||
In all cases, issues may be closed by maintainers if they don't receive a timely response when
|
||||
further information is sought, or when additional questions are asked.
|
||||
|
||||
## Approaches and Best Practices for getting into triage contributions
|
||||
|
||||
Review the organization's [StatusBoard](https://expressjs.github.io/statusboard/),
|
||||
pay special attention to these columns: stars, watchers, open issues, and contributors.
|
||||
This gives you a general idea about the criticality and health of the repository.
|
||||
Pick a few projects based on that criteria, your interests, and skills (existing or aspiring).
|
||||
|
||||
Review the project's contribution guideline if present. In a nutshell,
|
||||
commit to the community's standards and values. Review the
|
||||
documentation, for most of the projects it is just the README.md, and
|
||||
make sure you understand the key APIs, semantics, configurations, and use cases.
|
||||
|
||||
It might be helpful to write your own test apps to re-affirm your
|
||||
understanding of the key functions. This may identify some gaps in
|
||||
documentation, record those as they might be good PR's to open.
|
||||
Skim through the issue backlog; identify low hanging issues and mostly new ones.
|
||||
From those, attempt to recreate issues based on the OP description and
|
||||
ask questions if required. No question is a bad question!
|
||||
|
||||
## Removal of Triage Role
|
||||
|
||||
There are a few cases where members can be removed as triagers:
|
||||
|
||||
- Breaking the CoC or project contributor guidelines
|
||||
- Abuse or misuse of the role as deemed by the TC
|
||||
- Lack of participation for more than 6 months
|
||||
|
||||
If any of these happen we will discuss as a part of the triage portion of the regular TC meetings.
|
||||
If you have questions feel free to reach out to any of the TC members.
|
||||
|
||||
## Other Helpful Hints:
|
||||
|
||||
- Everyone is welcome to attend the [Express Technical Committee Meetings](https://github.com/expressjs/discussions#expressjs-tc-meetings), and as a triager, it might help to get a better idea of what's happening with the project.
|
||||
- When exploring the module's functionality there are a few helpful steps:
|
||||
- Turn on `DEBUG=*` (see https://www.npmjs.com/package/debug) to get detailed log information
|
||||
- It is also a good idea to do live debugging to follow the control flow, try using `node --inspect`
|
||||
- It is a good idea to make at least one pass of reading through the entire source
|
||||
- When reviewing the list of open issues there are some common types and suggested actions:
|
||||
- New/unattended issues or simple questions: A good place to start
|
||||
- Hard bugs & ongoing discussions: always feel free to chime in and help
|
||||
- Issues that imply gaps in the documentation: open PRs with changes or help the user to do so
|
||||
- For recurring issues, it is helpful to create functional examples to demonstrate (publish as gists or a repo)
|
||||
- Review and identify the maintainers. If necessary, at-mention one or more of them if you are unsure what to do
|
||||
- Make sure all your interactions are professional, welcoming, and respectful to the parties involved.
|
||||
@@ -1,17 +0,0 @@
|
||||
|
||||
all:
|
||||
@./run 1 middleware 50
|
||||
@./run 5 middleware 50
|
||||
@./run 10 middleware 50
|
||||
@./run 15 middleware 50
|
||||
@./run 20 middleware 50
|
||||
@./run 30 middleware 50
|
||||
@./run 50 middleware 50
|
||||
@./run 100 middleware 50
|
||||
@./run 10 middleware 100
|
||||
@./run 10 middleware 250
|
||||
@./run 10 middleware 500
|
||||
@./run 10 middleware 1000
|
||||
@echo
|
||||
|
||||
.PHONY: all
|
||||
@@ -1,34 +0,0 @@
|
||||
# Express Benchmarks
|
||||
|
||||
## Installation
|
||||
|
||||
You will need to install [wrk](https://github.com/wg/wrk/blob/master/INSTALL) in order to run the benchmarks.
|
||||
|
||||
## Running
|
||||
|
||||
To run the benchmarks, first install the dependencies `npm i`, then run `make`
|
||||
|
||||
The output will look something like this:
|
||||
|
||||
```
|
||||
50 connections
|
||||
1 middleware
|
||||
7.15ms
|
||||
6784.01
|
||||
|
||||
[...redacted...]
|
||||
|
||||
1000 connections
|
||||
10 middleware
|
||||
139.21ms
|
||||
6155.19
|
||||
|
||||
```
|
||||
|
||||
### Tip: Include Node.js version in output
|
||||
|
||||
You can use `make && node -v` to include the node.js version in the output.
|
||||
|
||||
### Tip: Save the results to a file
|
||||
|
||||
You can use `make > results.log` to save the results to a file `results.log`.
|
||||
@@ -1,20 +0,0 @@
|
||||
|
||||
var express = require('..');
|
||||
var app = express();
|
||||
|
||||
// number of middleware
|
||||
|
||||
var n = parseInt(process.env.MW || '1', 10);
|
||||
console.log(' %s middleware', n);
|
||||
|
||||
while (n--) {
|
||||
app.use(function(req, res, next){
|
||||
next();
|
||||
});
|
||||
}
|
||||
|
||||
app.use(function(req, res){
|
||||
res.send('Hello World')
|
||||
});
|
||||
|
||||
app.listen(3333);
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo
|
||||
MW=$1 node $2 &
|
||||
pid=$!
|
||||
|
||||
echo " $3 connections"
|
||||
|
||||
sleep 2
|
||||
|
||||
wrk 'http://localhost:3333/?foo[bar]=baz' \
|
||||
-d 3 \
|
||||
-c $3 \
|
||||
-t 8 \
|
||||
| grep 'Requests/sec\|Latency' \
|
||||
| awk '{ print " " $2 }'
|
||||
|
||||
kill $pid
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
var express = require('../..');
|
||||
var hash = require('pbkdf2-password')()
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var session = require('express-session');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
font: 13px Helvetica, Arial, sans-serif;
|
||||
}
|
||||
.error {
|
||||
color: red
|
||||
color: red;
|
||||
}
|
||||
.success {
|
||||
color: green;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
var express = require('../../');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = module.exports = express();
|
||||
var logger = require('morgan');
|
||||
var silent = process.env.NODE_ENV === 'test'
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
|
||||
var escapeHtml = require('escape-html');
|
||||
var express = require('../..');
|
||||
var fs = require('fs');
|
||||
var fs = require('node:fs');
|
||||
var marked = require('marked');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
|
||||
var app = module.exports = express();
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
var express = require('../..');
|
||||
var logger = require('morgan');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var session = require('express-session');
|
||||
var methodOverride = require('method-override');
|
||||
|
||||
|
||||
@@ -5,8 +5,8 @@
|
||||
*/
|
||||
|
||||
var express = require('../../..');
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var fs = require('node:fs');
|
||||
var path = require('node:path');
|
||||
|
||||
module.exports = function(parent, options){
|
||||
var dir = path.join(__dirname, '..', 'controllers');
|
||||
|
||||
@@ -32,7 +32,8 @@ app.param(['to', 'from'], function(req, res, next, num, name){
|
||||
// Load user by id
|
||||
|
||||
app.param('user', function(req, res, next, id){
|
||||
if (req.user = users[id]) {
|
||||
req.user = users[id]
|
||||
if (req.user) {
|
||||
next();
|
||||
} else {
|
||||
next(createError(404, 'failed to find user'));
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = express();
|
||||
var logger = require('morgan');
|
||||
var cookieParser = require('cookie-parser');
|
||||
|
||||
@@ -12,35 +12,51 @@
|
||||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var redis = require('redis');
|
||||
|
||||
var db = redis.createClient();
|
||||
|
||||
// npm install redis
|
||||
|
||||
var app = express();
|
||||
|
||||
app.use(express.static(path.join(__dirname, 'public')));
|
||||
|
||||
// populate search
|
||||
// npm install redis
|
||||
|
||||
db.sadd('ferret', 'tobi');
|
||||
db.sadd('ferret', 'loki');
|
||||
db.sadd('ferret', 'jane');
|
||||
db.sadd('cat', 'manny');
|
||||
db.sadd('cat', 'luna');
|
||||
/**
|
||||
* Redis Initialization
|
||||
*/
|
||||
|
||||
async function initializeRedis() {
|
||||
try {
|
||||
// connect to Redis
|
||||
|
||||
await db.connect();
|
||||
|
||||
// populate search
|
||||
|
||||
await db.sAdd('ferret', 'tobi');
|
||||
await db.sAdd('ferret', 'loki');
|
||||
await db.sAdd('ferret', 'jane');
|
||||
await db.sAdd('cat', 'manny');
|
||||
await db.sAdd('cat', 'luna');
|
||||
} catch (err) {
|
||||
console.error('Error initializing Redis:', err);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* GET search for :query.
|
||||
*/
|
||||
|
||||
app.get('/search/:query?', function(req, res, next){
|
||||
var query = req.params.query;
|
||||
db.smembers(query, function(err, vals){
|
||||
if (err) return next(err);
|
||||
res.send(vals);
|
||||
});
|
||||
app.get('/search/{:query}', function (req, res, next) {
|
||||
var query = req.params.query || '';
|
||||
db.sMembers(query)
|
||||
.then((vals) => res.send(vals))
|
||||
.catch((err) => {
|
||||
console.error(`Redis error for query "${query}":`, err);
|
||||
next(err);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
@@ -54,8 +70,14 @@ app.get('/client.js', function(req, res){
|
||||
res.sendFile(path.join(__dirname, 'client.js'));
|
||||
});
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (!module.parent) {
|
||||
app.listen(3000);
|
||||
console.log('Express started on port 3000');
|
||||
}
|
||||
/**
|
||||
* Start the Server
|
||||
*/
|
||||
|
||||
(async () => {
|
||||
await initializeRedis();
|
||||
if (!module.parent) {
|
||||
app.listen(3000);
|
||||
console.log('Express started on port 3000');
|
||||
}
|
||||
})();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
var express = require('../..');
|
||||
var logger = require('morgan');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var app = express();
|
||||
|
||||
// log requests
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var https = require('https');
|
||||
var path = require('path');
|
||||
var https = require('node:https');
|
||||
var path = require('node:path');
|
||||
var extname = path.extname;
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
var express = require('../..');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var User = require('./user');
|
||||
var app = express();
|
||||
|
||||
|
||||
@@ -14,18 +14,16 @@
|
||||
*/
|
||||
|
||||
var finalhandler = require('finalhandler');
|
||||
var methods = require('methods');
|
||||
var debug = require('debug')('express:application');
|
||||
var View = require('./view');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var methods = require('./utils').methods;
|
||||
var compileETag = require('./utils').compileETag;
|
||||
var compileQueryParser = require('./utils').compileQueryParser;
|
||||
var compileTrust = require('./utils').compileTrust;
|
||||
var merge = require('utils-merge');
|
||||
var resolve = require('path').resolve;
|
||||
var resolve = require('node:path').resolve;
|
||||
var once = require('once')
|
||||
var Router = require('router');
|
||||
var setPrototypeOf = require('setprototypeof')
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
@@ -117,10 +115,10 @@ app.defaultConfiguration = function defaultConfiguration() {
|
||||
}
|
||||
|
||||
// inherit protos
|
||||
setPrototypeOf(this.request, parent.request)
|
||||
setPrototypeOf(this.response, parent.response)
|
||||
setPrototypeOf(this.engines, parent.engines)
|
||||
setPrototypeOf(this.settings, parent.settings)
|
||||
Object.setPrototypeOf(this.request, parent.request)
|
||||
Object.setPrototypeOf(this.response, parent.response)
|
||||
Object.setPrototypeOf(this.engines, parent.engines)
|
||||
Object.setPrototypeOf(this.settings, parent.settings)
|
||||
});
|
||||
|
||||
// setup locals
|
||||
@@ -168,8 +166,8 @@ app.handle = function handle(req, res, callback) {
|
||||
res.req = req;
|
||||
|
||||
// alter the prototypes
|
||||
setPrototypeOf(req, this.request)
|
||||
setPrototypeOf(res, this.response)
|
||||
Object.setPrototypeOf(req, this.request)
|
||||
Object.setPrototypeOf(res, this.response)
|
||||
|
||||
// setup locals
|
||||
if (!res.locals) {
|
||||
@@ -232,8 +230,8 @@ app.use = function use(fn) {
|
||||
router.use(path, function mounted_app(req, res, next) {
|
||||
var orig = req.app;
|
||||
fn.handle(req, res, function (err) {
|
||||
setPrototypeOf(req, orig.request)
|
||||
setPrototypeOf(res, orig.response)
|
||||
Object.setPrototypeOf(req, orig.request)
|
||||
Object.setPrototypeOf(res, orig.response)
|
||||
next(err);
|
||||
});
|
||||
});
|
||||
@@ -470,8 +468,8 @@ app.disable = function disable(setting) {
|
||||
* Delegate `.VERB(...)` calls to `router.VERB(...)`.
|
||||
*/
|
||||
|
||||
methods.forEach(function(method){
|
||||
app[method] = function(path){
|
||||
methods.forEach(function (method) {
|
||||
app[method] = function (path) {
|
||||
if (method === 'get' && arguments.length === 1) {
|
||||
// app.get(setting)
|
||||
return this.set(path);
|
||||
@@ -525,8 +523,7 @@ app.render = function render(name, options, callback) {
|
||||
var cache = this.cache;
|
||||
var done = callback;
|
||||
var engines = this.engines;
|
||||
var opts = options;
|
||||
var renderOptions = {};
|
||||
var opts = options || {};
|
||||
var view;
|
||||
|
||||
// support callback function as second arg
|
||||
@@ -535,16 +532,8 @@ app.render = function render(name, options, callback) {
|
||||
opts = {};
|
||||
}
|
||||
|
||||
// merge app.locals
|
||||
merge(renderOptions, this.locals);
|
||||
|
||||
// merge options._locals
|
||||
if (opts._locals) {
|
||||
merge(renderOptions, opts._locals);
|
||||
}
|
||||
|
||||
// merge options
|
||||
merge(renderOptions, opts);
|
||||
var renderOptions = { ...this.locals, ...opts._locals, ...opts };
|
||||
|
||||
// set .cache unless explicitly provided
|
||||
if (renderOptions.cache == null) {
|
||||
@@ -594,8 +583,8 @@ app.render = function render(name, options, callback) {
|
||||
* and HTTPS server you may do so with the "http"
|
||||
* and "https" modules as shown here:
|
||||
*
|
||||
* var http = require('http')
|
||||
* , https = require('https')
|
||||
* var http = require('node:http')
|
||||
* , https = require('node:https')
|
||||
* , express = require('express')
|
||||
* , app = express();
|
||||
*
|
||||
@@ -606,9 +595,9 @@ app.render = function render(name, options, callback) {
|
||||
* @public
|
||||
*/
|
||||
|
||||
app.listen = function listen () {
|
||||
app.listen = function listen() {
|
||||
var server = http.createServer(this)
|
||||
var args = Array.prototype.slice.call(arguments)
|
||||
var args = slice.call(arguments)
|
||||
if (typeof args[args.length - 1] === 'function') {
|
||||
var done = args[args.length - 1] = once(args[args.length - 1])
|
||||
server.once('error', done)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
*/
|
||||
|
||||
var bodyParser = require('body-parser')
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
var EventEmitter = require('node:events').EventEmitter;
|
||||
var mixin = require('merge-descriptors');
|
||||
var proto = require('./application');
|
||||
var Router = require('router');
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
*/
|
||||
|
||||
var accepts = require('accepts');
|
||||
var isIP = require('net').isIP;
|
||||
var isIP = require('node:net').isIP;
|
||||
var typeis = require('type-is');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var fresh = require('fresh');
|
||||
var parseRange = require('range-parser');
|
||||
var parse = require('parseurl');
|
||||
@@ -83,16 +83,13 @@ req.header = function header(name) {
|
||||
};
|
||||
|
||||
/**
|
||||
* To do: update docs.
|
||||
*
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* the best match when true, otherwise `false`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single MIME type string
|
||||
* such as "application/json", an extension name
|
||||
* such as "json", a comma-delimited list such as "json, html, text/plain",
|
||||
* an argument list such as `"json", "html", "text/plain"`,
|
||||
* such as "json", an argument list such as `"json", "html", "text/plain"`,
|
||||
* or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given, the _best_ match, if any is returned.
|
||||
*
|
||||
@@ -107,7 +104,7 @@ req.header = function header(name) {
|
||||
* // => "html"
|
||||
* req.accepts('text/html');
|
||||
* // => "text/html"
|
||||
* req.accepts('json, text');
|
||||
* req.accepts('json', 'text');
|
||||
* // => "json"
|
||||
* req.accepts('application/json');
|
||||
* // => "application/json"
|
||||
@@ -115,12 +112,11 @@ req.header = function header(name) {
|
||||
* // Accept: text/*, application/json
|
||||
* req.accepts('image/png');
|
||||
* req.accepts('png');
|
||||
* // => undefined
|
||||
* // => false
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* req.accepts(['html', 'json']);
|
||||
* req.accepts('html', 'json');
|
||||
* req.accepts('html, json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} type(s)
|
||||
@@ -147,17 +143,34 @@ req.acceptsEncodings = function(){
|
||||
};
|
||||
|
||||
/**
|
||||
* Check if the given `charset`s are acceptable,
|
||||
* otherwise you should respond with 406 "Not Acceptable".
|
||||
* Checks if the specified `charset`s are acceptable based on the request's `Accept-Charset` header.
|
||||
* Returns the best matching charset or an array of acceptable charsets.
|
||||
*
|
||||
* @param {String} ...charset
|
||||
* @return {String|Array}
|
||||
* The `charset` argument(s) can be:
|
||||
* - A single charset string (e.g., "utf-8")
|
||||
* - Multiple charset strings as arguments (e.g., `"utf-8", "iso-8859-1"`)
|
||||
* - A comma-delimited list of charsets (e.g., `"utf-8, iso-8859-1"`)
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept-Charset: utf-8, iso-8859-1
|
||||
* req.acceptsCharsets('utf-8');
|
||||
* // => "utf-8"
|
||||
*
|
||||
* req.acceptsCharsets('utf-8', 'iso-8859-1');
|
||||
* // => "utf-8"
|
||||
*
|
||||
* req.acceptsCharsets('utf-8, utf-16');
|
||||
* // => "utf-8"
|
||||
*
|
||||
* @param {...String} charsets - The charset(s) to check against the `Accept-Charset` header.
|
||||
* @return {String|Array} - The best matching charset, or an array of acceptable charsets.
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsCharsets = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.charsets.apply(accept, arguments);
|
||||
req.acceptsCharsets = function(...charsets) {
|
||||
const accept = accepts(this);
|
||||
return accept.charsets(...charsets);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -169,9 +182,8 @@ req.acceptsCharsets = function(){
|
||||
* @public
|
||||
*/
|
||||
|
||||
req.acceptsLanguages = function(){
|
||||
var accept = accepts(this);
|
||||
return accept.languages.apply(accept, arguments);
|
||||
req.acceptsLanguages = function(...languages) {
|
||||
return accepts(this).languages(...languages);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -283,12 +295,12 @@ req.is = function is(types) {
|
||||
*/
|
||||
|
||||
defineGetter(req, 'protocol', function protocol(){
|
||||
var proto = this.connection.encrypted
|
||||
var proto = this.socket.encrypted
|
||||
? 'https'
|
||||
: 'http';
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
|
||||
if (!trust(this.connection.remoteAddress, 0)) {
|
||||
if (!trust(this.socket.remoteAddress, 0)) {
|
||||
return proto;
|
||||
}
|
||||
|
||||
@@ -407,7 +419,7 @@ defineGetter(req, 'host', function host(){
|
||||
var trust = this.app.get('trust proxy fn');
|
||||
var val = this.get('X-Forwarded-Host');
|
||||
|
||||
if (!val || !trust(this.connection.remoteAddress, 0)) {
|
||||
if (!val || !trust(this.socket.remoteAddress, 0)) {
|
||||
val = this.get('Host');
|
||||
} else if (val.indexOf(',') !== -1) {
|
||||
// Note: X-Forwarded-Host is normally only ever a
|
||||
|
||||
@@ -12,18 +12,17 @@
|
||||
* @private
|
||||
*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var contentDisposition = require('content-disposition');
|
||||
var createError = require('http-errors')
|
||||
var deprecate = require('depd')('express');
|
||||
var encodeUrl = require('encodeurl');
|
||||
var escapeHtml = require('escape-html');
|
||||
var http = require('http');
|
||||
var http = require('node:http');
|
||||
var onFinished = require('on-finished');
|
||||
var mime = require('mime-types')
|
||||
var path = require('path');
|
||||
var pathIsAbsolute = require('path').isAbsolute;
|
||||
var path = require('node:path');
|
||||
var pathIsAbsolute = require('node:path').isAbsolute;
|
||||
var statuses = require('statuses')
|
||||
var merge = require('utils-merge');
|
||||
var sign = require('cookie-signature').sign;
|
||||
var normalizeType = require('./utils').normalizeType;
|
||||
var normalizeTypes = require('./utils').normalizeTypes;
|
||||
@@ -33,6 +32,7 @@ var send = require('send');
|
||||
var extname = path.extname;
|
||||
var resolve = path.resolve;
|
||||
var vary = require('vary');
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
/**
|
||||
* Response prototype.
|
||||
@@ -82,7 +82,11 @@ res.status = function status(code) {
|
||||
*
|
||||
* res.links({
|
||||
* next: 'http://api.example.com/users?page=2',
|
||||
* last: 'http://api.example.com/users?page=5'
|
||||
* last: 'http://api.example.com/users?page=5',
|
||||
* pages: [
|
||||
* 'http://api.example.com/users?page=1',
|
||||
* 'http://api.example.com/users?page=2'
|
||||
* ]
|
||||
* });
|
||||
*
|
||||
* @param {Object} links
|
||||
@@ -90,11 +94,18 @@ res.status = function status(code) {
|
||||
* @public
|
||||
*/
|
||||
|
||||
res.links = function(links){
|
||||
res.links = function(links) {
|
||||
var link = this.get('Link') || '';
|
||||
if (link) link += ', ';
|
||||
return this.set('Link', link + Object.keys(links).map(function(rel){
|
||||
return '<' + links[rel] + '>; rel="' + rel + '"';
|
||||
return this.set('Link', link + Object.keys(links).map(function(rel) {
|
||||
// Allow multiple links if links[rel] is an array
|
||||
if (Array.isArray(links[rel])) {
|
||||
return links[rel].map(function (singleLink) {
|
||||
return `<${singleLink}>; rel="${rel}"`;
|
||||
}).join(', ');
|
||||
} else {
|
||||
return `<${links[rel]}>; rel="${rel}"`;
|
||||
}
|
||||
}).join(', '));
|
||||
};
|
||||
|
||||
@@ -115,7 +126,6 @@ res.send = function send(body) {
|
||||
var chunk = body;
|
||||
var encoding;
|
||||
var req = this.req;
|
||||
var type;
|
||||
|
||||
// settings
|
||||
var app = this.app;
|
||||
@@ -123,7 +133,12 @@ res.send = function send(body) {
|
||||
switch (typeof chunk) {
|
||||
// string defaulting to html
|
||||
case 'string':
|
||||
if (!this.get('Content-Type')) {
|
||||
encoding = 'utf8';
|
||||
const type = this.get('Content-Type');
|
||||
|
||||
if (typeof type === 'string') {
|
||||
this.set('Content-Type', setCharset(type, 'utf-8'));
|
||||
} else {
|
||||
this.type('html');
|
||||
}
|
||||
break;
|
||||
@@ -132,7 +147,7 @@ res.send = function send(body) {
|
||||
case 'object':
|
||||
if (chunk === null) {
|
||||
chunk = '';
|
||||
} else if (Buffer.isBuffer(chunk)) {
|
||||
} else if (ArrayBuffer.isView(chunk)) {
|
||||
if (!this.get('Content-Type')) {
|
||||
this.type('bin');
|
||||
}
|
||||
@@ -142,17 +157,6 @@ res.send = function send(body) {
|
||||
break;
|
||||
}
|
||||
|
||||
// write strings in utf-8
|
||||
if (typeof chunk === 'string') {
|
||||
encoding = 'utf8';
|
||||
type = this.get('Content-Type');
|
||||
|
||||
// reflect this in content-type
|
||||
if (typeof type === 'string') {
|
||||
this.set('Content-Type', setCharset(type, 'utf-8'));
|
||||
}
|
||||
}
|
||||
|
||||
// determine if ETag should be generated
|
||||
var etagFn = app.get('etag fn')
|
||||
var generateETag = !this.get('ETag') && typeof etagFn === 'function'
|
||||
@@ -391,6 +395,9 @@ res.sendFile = function sendFile(path, options, callback) {
|
||||
|
||||
// create file stream
|
||||
var pathname = encodeURI(path);
|
||||
|
||||
// wire application etag option to send
|
||||
opts.etag = this.app.enabled('etag');
|
||||
var file = send(req, pathname, opts);
|
||||
|
||||
// transfer
|
||||
@@ -733,7 +740,7 @@ res.clearCookie = function clearCookie(name, options) {
|
||||
*/
|
||||
|
||||
res.cookie = function (name, value, options) {
|
||||
var opts = merge({}, options);
|
||||
var opts = { ...options };
|
||||
var secret = this.req.secret;
|
||||
var signed = opts.signed;
|
||||
|
||||
@@ -813,6 +820,18 @@ res.redirect = function redirect(url) {
|
||||
address = arguments[1]
|
||||
}
|
||||
|
||||
if (!address) {
|
||||
deprecate('Provide a url argument');
|
||||
}
|
||||
|
||||
if (typeof address !== 'string') {
|
||||
deprecate('Url must be a string');
|
||||
}
|
||||
|
||||
if (typeof status !== 'number') {
|
||||
deprecate('Status must be a number');
|
||||
}
|
||||
|
||||
// Set location header
|
||||
address = this.location(address).get('Location');
|
||||
|
||||
@@ -824,7 +843,8 @@ res.redirect = function redirect(url) {
|
||||
|
||||
html: function(){
|
||||
var u = escapeHtml(address);
|
||||
body = '<p>' + statuses.message[status] + '. Redirecting to ' + u + '</p>'
|
||||
body = '<!DOCTYPE html><head><title>' + statuses.message[status] + '</title></head>'
|
||||
+ '<body><p>' + statuses.message[status] + '. Redirecting to ' + u + '</p></body>'
|
||||
},
|
||||
|
||||
default: function(){
|
||||
|
||||
56
lib/utils.js
56
lib/utils.js
@@ -12,13 +12,21 @@
|
||||
* @api private
|
||||
*/
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var { METHODS } = require('node:http');
|
||||
var contentType = require('content-type');
|
||||
var etag = require('etag');
|
||||
var mime = require('mime-types')
|
||||
var proxyaddr = require('proxy-addr');
|
||||
var qs = require('qs');
|
||||
var querystring = require('querystring');
|
||||
var querystring = require('node:querystring');
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
|
||||
/**
|
||||
* A list of lowercased HTTP methods that are supported by Node.js.
|
||||
* @api private
|
||||
*/
|
||||
exports.methods = METHODS.map((method) => method.toLowerCase());
|
||||
|
||||
/**
|
||||
* Return strong ETag for `body`.
|
||||
@@ -64,16 +72,11 @@ exports.normalizeType = function(type){
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.normalizeTypes = function(types){
|
||||
var ret = [];
|
||||
|
||||
for (var i = 0; i < types.length; ++i) {
|
||||
ret.push(exports.normalizeType(types[i]));
|
||||
}
|
||||
|
||||
return ret;
|
||||
exports.normalizeTypes = function(types) {
|
||||
return types.map(exports.normalizeType);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Parse accept params `str` returning an
|
||||
* object with `.value`, `.quality` and `.params`.
|
||||
@@ -84,16 +87,33 @@ exports.normalizeTypes = function(types){
|
||||
*/
|
||||
|
||||
function acceptParams (str) {
|
||||
var parts = str.split(/ *; */);
|
||||
var ret = { value: parts[0], quality: 1, params: {} }
|
||||
var length = str.length;
|
||||
var colonIndex = str.indexOf(';');
|
||||
var index = colonIndex === -1 ? length : colonIndex;
|
||||
var ret = { value: str.slice(0, index).trim(), quality: 1, params: {} };
|
||||
|
||||
for (var i = 1; i < parts.length; ++i) {
|
||||
var pms = parts[i].split(/ *= */);
|
||||
if ('q' === pms[0]) {
|
||||
ret.quality = parseFloat(pms[1]);
|
||||
} else {
|
||||
ret.params[pms[0]] = pms[1];
|
||||
while (index < length) {
|
||||
var splitIndex = str.indexOf('=', index);
|
||||
if (splitIndex === -1) break;
|
||||
|
||||
var colonIndex = str.indexOf(';', index);
|
||||
var endIndex = colonIndex === -1 ? length : colonIndex;
|
||||
|
||||
if (splitIndex > endIndex) {
|
||||
index = str.lastIndexOf(';', splitIndex - 1) + 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
var key = str.slice(index, splitIndex).trim();
|
||||
var value = str.slice(splitIndex + 1, endIndex).trim();
|
||||
|
||||
if (key === 'q') {
|
||||
ret.quality = parseFloat(value);
|
||||
} else {
|
||||
ret.params[key] = value;
|
||||
}
|
||||
|
||||
index = endIndex + 1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
*/
|
||||
|
||||
var debug = require('debug')('express:view');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
var path = require('node:path');
|
||||
var fs = require('node:fs');
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
|
||||
80
package.json
80
package.json
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "express",
|
||||
"description": "Fast, unopinionated, minimalist web framework",
|
||||
"version": "5.0.0",
|
||||
"version": "5.2.1",
|
||||
"author": "TJ Holowaychuk <tj@vision-media.ca>",
|
||||
"contributors": [
|
||||
"Aaron Heckmann <aaron.heckmann+github@gmail.com>",
|
||||
@@ -14,7 +14,11 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": "expressjs/express",
|
||||
"homepage": "http://expressjs.com/",
|
||||
"homepage": "https://expressjs.com/",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/express"
|
||||
},
|
||||
"keywords": [
|
||||
"express",
|
||||
"framework",
|
||||
@@ -29,54 +33,50 @@
|
||||
],
|
||||
"dependencies": {
|
||||
"accepts": "^2.0.0",
|
||||
"body-parser": "^2.0.1",
|
||||
"body-parser": "^2.2.1",
|
||||
"content-disposition": "^1.0.0",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.6.0",
|
||||
"content-type": "^1.0.5",
|
||||
"cookie": "^0.7.1",
|
||||
"cookie-signature": "^1.2.1",
|
||||
"debug": "4.3.6",
|
||||
"depd": "2.0.0",
|
||||
"encodeurl": "~2.0.0",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "^2.0.0",
|
||||
"fresh": "2.0.0",
|
||||
"http-errors": "2.0.0",
|
||||
"debug": "^4.4.0",
|
||||
"depd": "^2.0.0",
|
||||
"encodeurl": "^2.0.0",
|
||||
"escape-html": "^1.0.3",
|
||||
"etag": "^1.8.1",
|
||||
"finalhandler": "^2.1.0",
|
||||
"fresh": "^2.0.0",
|
||||
"http-errors": "^2.0.0",
|
||||
"merge-descriptors": "^2.0.0",
|
||||
"methods": "~1.1.2",
|
||||
"mime-types": "^3.0.0",
|
||||
"on-finished": "2.4.1",
|
||||
"once": "1.4.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"proxy-addr": "~2.0.7",
|
||||
"qs": "6.13.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"router": "^2.0.0",
|
||||
"safe-buffer": "5.2.1",
|
||||
"on-finished": "^2.4.1",
|
||||
"once": "^1.4.0",
|
||||
"parseurl": "^1.3.3",
|
||||
"proxy-addr": "^2.0.7",
|
||||
"qs": "^6.14.2",
|
||||
"range-parser": "^1.2.1",
|
||||
"router": "^2.2.0",
|
||||
"send": "^1.1.0",
|
||||
"serve-static": "^2.1.0",
|
||||
"setprototypeof": "1.2.0",
|
||||
"statuses": "2.0.1",
|
||||
"type-is": "^2.0.0",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
"serve-static": "^2.2.0",
|
||||
"statuses": "^2.0.1",
|
||||
"type-is": "^2.0.1",
|
||||
"vary": "^1.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"after": "0.8.2",
|
||||
"connect-redis": "3.4.2",
|
||||
"cookie-parser": "1.4.6",
|
||||
"cookie-session": "2.0.0",
|
||||
"ejs": "3.1.9",
|
||||
"connect-redis": "^8.0.1",
|
||||
"cookie-parser": "1.4.7",
|
||||
"cookie-session": "2.1.1",
|
||||
"ejs": "^3.1.10",
|
||||
"eslint": "8.47.0",
|
||||
"express-session": "1.17.2",
|
||||
"express-session": "^1.18.1",
|
||||
"hbs": "4.2.0",
|
||||
"marked": "0.7.0",
|
||||
"marked": "^15.0.3",
|
||||
"method-override": "3.0.0",
|
||||
"mocha": "10.2.0",
|
||||
"morgan": "1.10.0",
|
||||
"nyc": "15.1.0",
|
||||
"mocha": "^10.7.3",
|
||||
"morgan": "1.10.1",
|
||||
"nyc": "^17.1.0",
|
||||
"pbkdf2-password": "1.2.1",
|
||||
"supertest": "6.3.0",
|
||||
"supertest": "^6.3.0",
|
||||
"vhost": "~3.0.2"
|
||||
},
|
||||
"engines": {
|
||||
@@ -84,14 +84,14 @@
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"History.md",
|
||||
"Readme.md",
|
||||
"index.js",
|
||||
"lib/"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"test": "mocha --require test/support/env --reporter spec --bail --check-leaks test/ test/acceptance/",
|
||||
"lint:fix": "eslint . --fix",
|
||||
"test": "mocha --require test/support/env --reporter spec --check-leaks test/ test/acceptance/",
|
||||
"test-ci": "nyc --exclude examples --exclude test --exclude benchmarks --reporter=lcovonly --reporter=text npm test",
|
||||
"test-cov": "nyc --exclude examples --exclude test --exclude benchmarks --reporter=html --reporter=text npm test",
|
||||
"test-tap": "mocha --require test/support/env --reporter tap --check-leaks test/ test/acceptance/"
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, Route = express.Route
|
||||
, methods = require('methods')
|
||||
, methods = require('../lib/utils').methods
|
||||
|
||||
describe('Route', function(){
|
||||
it('should work without handlers', function(done) {
|
||||
|
||||
154
test/Router.js
154
test/Router.js
@@ -3,11 +3,11 @@
|
||||
var after = require('after');
|
||||
var express = require('../')
|
||||
, Router = express.Router
|
||||
, methods = require('methods')
|
||||
, assert = require('assert');
|
||||
, methods = require('../lib/utils').methods
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('Router', function(){
|
||||
it('should return a function with router methods', function() {
|
||||
describe('Router', function () {
|
||||
it('should return a function with router methods', function () {
|
||||
var router = new Router();
|
||||
assert(typeof router === 'function')
|
||||
|
||||
@@ -16,32 +16,32 @@ describe('Router', function(){
|
||||
assert(typeof router.use === 'function')
|
||||
});
|
||||
|
||||
it('should support .use of other routers', function(done){
|
||||
it('should support .use of other routers', function (done) {
|
||||
var router = new Router();
|
||||
var another = new Router();
|
||||
|
||||
another.get('/bar', function(req, res){
|
||||
another.get('/bar', function (req, res) {
|
||||
res.end();
|
||||
});
|
||||
router.use('/foo', another);
|
||||
|
||||
router.handle({ url: '/foo/bar', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/foo/bar', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should support dynamic routes', function(done){
|
||||
it('should support dynamic routes', function (done) {
|
||||
var router = new Router();
|
||||
var another = new Router();
|
||||
|
||||
another.get('/:bar', function(req, res){
|
||||
another.get('/:bar', function (req, res) {
|
||||
assert.strictEqual(req.params.bar, 'route')
|
||||
res.end();
|
||||
});
|
||||
router.use('/:foo', another);
|
||||
|
||||
router.handle({ url: '/test/route', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/test/route', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should handle blank URL', function(done){
|
||||
it('should handle blank URL', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.use(function (req, res) {
|
||||
@@ -88,10 +88,10 @@ describe('Router', function(){
|
||||
})
|
||||
})
|
||||
|
||||
it('should not stack overflow with many registered routes', function(done){
|
||||
it('should not stack overflow with many registered routes', function (done) {
|
||||
this.timeout(5000) // long-running test
|
||||
|
||||
var handler = function(req, res){ res.end(new Error('wrong handler')) };
|
||||
var handler = function (req, res) { res.end(new Error('wrong handler')) };
|
||||
var router = new Router();
|
||||
|
||||
for (var i = 0; i < 6000; i++) {
|
||||
@@ -102,7 +102,7 @@ describe('Router', function(){
|
||||
res.end();
|
||||
});
|
||||
|
||||
router.handle({ url: '/', method: 'GET' }, { end: done }, function(){});
|
||||
router.handle({ url: '/', method: 'GET' }, { end: done }, function () { });
|
||||
});
|
||||
|
||||
it('should not stack overflow with a large sync route stack', function (done) {
|
||||
@@ -159,69 +159,69 @@ describe('Router', function(){
|
||||
})
|
||||
})
|
||||
|
||||
describe('.handle', function(){
|
||||
it('should dispatch', function(done){
|
||||
describe('.handle', function () {
|
||||
it('should dispatch', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.route('/foo').get(function(req, res){
|
||||
router.route('/foo').get(function (req, res) {
|
||||
res.send('foo');
|
||||
});
|
||||
|
||||
var res = {
|
||||
send: function(val) {
|
||||
send: function (val) {
|
||||
assert.strictEqual(val, 'foo')
|
||||
done();
|
||||
}
|
||||
}
|
||||
router.handle({ url: '/foo', method: 'GET' }, res, function(){});
|
||||
router.handle({ url: '/foo', method: 'GET' }, res, function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('.multiple callbacks', function(){
|
||||
it('should throw if a callback is null', function(){
|
||||
describe('.multiple callbacks', function () {
|
||||
it('should throw if a callback is null', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(null);
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw if a callback is undefined', function(){
|
||||
it('should throw if a callback is undefined', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(undefined);
|
||||
})
|
||||
})
|
||||
|
||||
it('should throw if a callback is not a function', function(){
|
||||
it('should throw if a callback is not a function', function () {
|
||||
assert.throws(function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all('not a function');
|
||||
})
|
||||
})
|
||||
|
||||
it('should not throw if all callbacks are functions', function(){
|
||||
it('should not throw if all callbacks are functions', function () {
|
||||
var router = new Router();
|
||||
router.route('/foo').all(function(){}).all(function(){});
|
||||
router.route('/foo').all(function () { }).all(function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('error', function(){
|
||||
it('should skip non error middleware', function(done){
|
||||
describe('error', function () {
|
||||
it('should skip non error middleware', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.get('/foo', function(req, res, next){
|
||||
router.get('/foo', function (req, res, next) {
|
||||
next(new Error('foo'));
|
||||
});
|
||||
|
||||
router.get('/bar', function(req, res, next){
|
||||
router.get('/bar', function (req, res, next) {
|
||||
next(new Error('bar'));
|
||||
});
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
assert(false);
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'foo');
|
||||
done();
|
||||
});
|
||||
@@ -229,59 +229,59 @@ describe('Router', function(){
|
||||
router.handle({ url: '/foo', method: 'GET' }, {}, done);
|
||||
});
|
||||
|
||||
it('should handle throwing inside routes with params', function(done) {
|
||||
it('should handle throwing inside routes with params', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.get('/foo/:id', function () {
|
||||
throw new Error('foo');
|
||||
});
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
assert(false);
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'foo');
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/foo/2', method: 'GET' }, {}, function() {});
|
||||
router.handle({ url: '/foo/2', method: 'GET' }, {}, function () { });
|
||||
});
|
||||
|
||||
it('should handle throwing in handler after async param', function(done) {
|
||||
it('should handle throwing in handler after async param', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('user', function(req, res, next, val){
|
||||
process.nextTick(function(){
|
||||
router.param('user', function (req, res, next, val) {
|
||||
process.nextTick(function () {
|
||||
req.user = val;
|
||||
next();
|
||||
});
|
||||
});
|
||||
|
||||
router.use('/:user', function(req, res, next){
|
||||
router.use('/:user', function (req, res, next) {
|
||||
throw new Error('oh no!');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'oh no!');
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/bob', method: 'GET' }, {}, function() {});
|
||||
router.handle({ url: '/bob', method: 'GET' }, {}, function () { });
|
||||
});
|
||||
|
||||
it('should handle throwing inside error handlers', function(done) {
|
||||
it('should handle throwing inside error handlers', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.use(function(req, res, next){
|
||||
router.use(function (req, res, next) {
|
||||
throw new Error('boom!');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
throw new Error('oops');
|
||||
});
|
||||
|
||||
router.use(function(err, req, res, next){
|
||||
router.use(function (err, req, res, next) {
|
||||
assert.equal(err.message, 'oops');
|
||||
done();
|
||||
});
|
||||
@@ -412,17 +412,17 @@ describe('Router', function(){
|
||||
});
|
||||
})
|
||||
|
||||
describe('.all', function() {
|
||||
it('should support using .all to capture all http verbs', function(done){
|
||||
describe('.all', function () {
|
||||
it('should support using .all to capture all http verbs', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
var count = 0;
|
||||
router.all('/foo', function(){ count++; });
|
||||
router.all('/foo', function () { count++; });
|
||||
|
||||
var url = '/foo?bar=baz';
|
||||
|
||||
methods.forEach(function testMethod(method) {
|
||||
router.handle({ url: url, method: method }, {}, function() {});
|
||||
router.handle({ url: url, method: method }, {}, function () { });
|
||||
});
|
||||
|
||||
assert.equal(count, methods.length);
|
||||
@@ -430,7 +430,7 @@ describe('Router', function(){
|
||||
})
|
||||
})
|
||||
|
||||
describe('.use', function() {
|
||||
describe('.use', function () {
|
||||
it('should require middleware', function () {
|
||||
var router = new Router()
|
||||
assert.throws(function () { router.use('/') }, /argument handler is required/)
|
||||
@@ -460,7 +460,7 @@ describe('Router', function(){
|
||||
var cb = after(4, done)
|
||||
var router = new Router()
|
||||
|
||||
function no () {
|
||||
function no() {
|
||||
throw new Error('should not be called')
|
||||
}
|
||||
|
||||
@@ -474,30 +474,30 @@ describe('Router', function(){
|
||||
router.handle({ url: '*', method: 'GET' }, { end: cb }, no)
|
||||
})
|
||||
|
||||
it('should accept array of middleware', function(done){
|
||||
it('should accept array of middleware', function (done) {
|
||||
var count = 0;
|
||||
var router = new Router();
|
||||
|
||||
function fn1(req, res, next){
|
||||
function fn1(req, res, next) {
|
||||
assert.equal(++count, 1);
|
||||
next();
|
||||
}
|
||||
|
||||
function fn2(req, res, next){
|
||||
function fn2(req, res, next) {
|
||||
assert.equal(++count, 2);
|
||||
next();
|
||||
}
|
||||
|
||||
router.use([fn1, fn2], function(req, res){
|
||||
router.use([fn1, fn2], function (req, res) {
|
||||
assert.equal(++count, 3);
|
||||
done();
|
||||
});
|
||||
|
||||
router.handle({ url: '/foo', method: 'GET' }, {}, function(){});
|
||||
router.handle({ url: '/foo', method: 'GET' }, {}, function () { });
|
||||
})
|
||||
})
|
||||
|
||||
describe('.param', function() {
|
||||
describe('.param', function () {
|
||||
it('should require function', function () {
|
||||
var router = new Router();
|
||||
assert.throws(router.param.bind(router, 'id'), /argument fn is required/);
|
||||
@@ -508,15 +508,15 @@ describe('Router', function(){
|
||||
assert.throws(router.param.bind(router, 'id', 42), /argument fn must be a function/);
|
||||
});
|
||||
|
||||
it('should call param function when routing VERBS', function(done) {
|
||||
it('should call param function when routing VERBS', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('id', function(req, res, next, id) {
|
||||
router.param('id', function (req, res, next, id) {
|
||||
assert.equal(id, '123');
|
||||
next();
|
||||
});
|
||||
|
||||
router.get('/foo/:id/bar', function(req, res, next) {
|
||||
router.get('/foo/:id/bar', function (req, res, next) {
|
||||
assert.equal(req.params.id, '123');
|
||||
next();
|
||||
});
|
||||
@@ -524,15 +524,15 @@ describe('Router', function(){
|
||||
router.handle({ url: '/foo/123/bar', method: 'get' }, {}, done);
|
||||
});
|
||||
|
||||
it('should call param function when routing middleware', function(done) {
|
||||
it('should call param function when routing middleware', function (done) {
|
||||
var router = new Router();
|
||||
|
||||
router.param('id', function(req, res, next, id) {
|
||||
router.param('id', function (req, res, next, id) {
|
||||
assert.equal(id, '123');
|
||||
next();
|
||||
});
|
||||
|
||||
router.use('/foo/:id/bar', function(req, res, next) {
|
||||
router.use('/foo/:id/bar', function (req, res, next) {
|
||||
assert.equal(req.params.id, '123');
|
||||
assert.equal(req.url, '/baz');
|
||||
next();
|
||||
@@ -541,17 +541,17 @@ describe('Router', function(){
|
||||
router.handle({ url: '/foo/123/bar/baz', method: 'get' }, {}, done);
|
||||
});
|
||||
|
||||
it('should only call once per request', function(done) {
|
||||
it('should only call once per request', function (done) {
|
||||
var count = 0;
|
||||
var req = { url: '/foo/bob/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
var sub = new Router();
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('user', function(req, res, next, user) {
|
||||
router.param('user', function (req, res, next, user) {
|
||||
count++;
|
||||
req.user = user;
|
||||
next();
|
||||
@@ -560,7 +560,7 @@ describe('Router', function(){
|
||||
router.use('/foo/:user/', new Router());
|
||||
router.use('/foo/:user/', sub);
|
||||
|
||||
router.handle(req, {}, function(err) {
|
||||
router.handle(req, {}, function (err) {
|
||||
if (err) return done(err);
|
||||
assert.equal(count, 1);
|
||||
assert.equal(req.user, 'bob');
|
||||
@@ -568,17 +568,17 @@ describe('Router', function(){
|
||||
});
|
||||
});
|
||||
|
||||
it('should call when values differ', function(done) {
|
||||
it('should call when values differ', function (done) {
|
||||
var count = 0;
|
||||
var req = { url: '/foo/bob/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
var sub = new Router();
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('user', function(req, res, next, user) {
|
||||
router.param('user', function (req, res, next, user) {
|
||||
count++;
|
||||
req.user = user;
|
||||
next();
|
||||
@@ -587,7 +587,7 @@ describe('Router', function(){
|
||||
router.use('/foo/:user/', new Router());
|
||||
router.use('/:user/bob/', sub);
|
||||
|
||||
router.handle(req, {}, function(err) {
|
||||
router.handle(req, {}, function (err) {
|
||||
if (err) return done(err);
|
||||
assert.equal(count, 2);
|
||||
assert.equal(req.user, 'foo');
|
||||
@@ -596,8 +596,8 @@ describe('Router', function(){
|
||||
});
|
||||
});
|
||||
|
||||
describe('parallel requests', function() {
|
||||
it('should not mix requests', function(done) {
|
||||
describe('parallel requests', function () {
|
||||
it('should not mix requests', function (done) {
|
||||
var req1 = { url: '/foo/50/bar', method: 'get' };
|
||||
var req2 = { url: '/foo/10/bar', method: 'get' };
|
||||
var router = new Router();
|
||||
@@ -605,11 +605,11 @@ describe('Router', function(){
|
||||
var cb = after(2, done)
|
||||
|
||||
|
||||
sub.get('/bar', function(req, res, next) {
|
||||
sub.get('/bar', function (req, res, next) {
|
||||
next();
|
||||
});
|
||||
|
||||
router.param('ms', function(req, res, next, ms) {
|
||||
router.param('ms', function (req, res, next, ms) {
|
||||
ms = parseInt(ms, 10);
|
||||
req.ms = ms;
|
||||
setTimeout(next, ms);
|
||||
@@ -618,14 +618,14 @@ describe('Router', function(){
|
||||
router.use('/foo/:ms/', new Router());
|
||||
router.use('/foo/:ms/', sub);
|
||||
|
||||
router.handle(req1, {}, function(err) {
|
||||
router.handle(req1, {}, function (err) {
|
||||
assert.ifError(err);
|
||||
assert.equal(req1.ms, 50);
|
||||
assert.equal(req1.originalUrl, '/foo/50/bar');
|
||||
cb()
|
||||
});
|
||||
|
||||
router.handle(req2, {}, function(err) {
|
||||
router.handle(req2, {}, function (err) {
|
||||
assert.ifError(err);
|
||||
assert.equal(req2.ms, 10);
|
||||
assert.equal(req2.originalUrl, '/foo/10/bar');
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, fs = require('fs');
|
||||
var path = require('path')
|
||||
, fs = require('node:fs');
|
||||
var path = require('node:path')
|
||||
|
||||
function render(path, options, fn) {
|
||||
fs.readFile(path, 'utf8', function(err, str){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
|
||||
describe('HEAD', function(){
|
||||
it('should default to GET', function(done){
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var express = require('../')
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
|
||||
describe('app.listen()', function(){
|
||||
it('should wrap with an HTTP server', function(done){
|
||||
@@ -24,4 +24,32 @@ describe('app.listen()', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
it('accepts port + hostname + backlog + callback', function (done) {
|
||||
const app = express();
|
||||
const server = app.listen(0, '127.0.0.1', 5, function () {
|
||||
const { address, port } = server.address();
|
||||
assert.strictEqual(address, '127.0.0.1');
|
||||
assert(Number.isInteger(port) && port > 0);
|
||||
// backlog isn’t directly inspectable, but if no error was thrown
|
||||
// we know it was accepted.
|
||||
server.close(done);
|
||||
});
|
||||
});
|
||||
it('accepts just a callback (no args)', function (done) {
|
||||
const app = express();
|
||||
// same as app.listen(0, done)
|
||||
const server = app.listen();
|
||||
server.close(done);
|
||||
});
|
||||
it('server.address() gives a { address, port, family } object', function (done) {
|
||||
const app = express();
|
||||
const server = app.listen(0, () => {
|
||||
const addr = server.address();
|
||||
assert(addr && typeof addr === 'object');
|
||||
assert.strictEqual(typeof addr.address, 'string');
|
||||
assert(Number.isInteger(addr.port) && addr.port > 0);
|
||||
assert(typeof addr.family === 'string');
|
||||
server.close(done);
|
||||
});
|
||||
});
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
|
||||
describe('app', function(){
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var tmpl = require('./support/tmpl');
|
||||
|
||||
describe('app', function(){
|
||||
@@ -331,6 +331,24 @@ describe('app', function(){
|
||||
})
|
||||
})
|
||||
|
||||
it('should accept null or undefined options', function (done) {
|
||||
var app = createApp()
|
||||
|
||||
app.set('views', path.join(__dirname, 'fixtures'))
|
||||
app.locals.user = { name: 'tobi' }
|
||||
|
||||
app.render('user.tmpl', null, function (err, str) {
|
||||
if (err) return done(err);
|
||||
assert.strictEqual(str, '<p>tobi</p>')
|
||||
|
||||
app.render('user.tmpl', undefined, function (err2, str2) {
|
||||
if (err2) return done(err2);
|
||||
assert.strictEqual(str2, '<p>tobi</p>')
|
||||
done()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('caching', function(){
|
||||
it('should cache with cache option', function(done){
|
||||
var app = express();
|
||||
|
||||
@@ -10,7 +10,7 @@ describe('app', function(){
|
||||
var app = express();
|
||||
|
||||
app.request.querystring = function(){
|
||||
return require('url').parse(this.url).query;
|
||||
return require('node:url').parse(this.url).query;
|
||||
};
|
||||
|
||||
app.use(function(req, res){
|
||||
|
||||
@@ -3,8 +3,6 @@
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
|
||||
var describePromises = global.Promise ? describe : describe.skip
|
||||
|
||||
describe('app.route', function(){
|
||||
it('should return a new route', function(done){
|
||||
var app = express();
|
||||
@@ -64,7 +62,7 @@ describe('app.route', function(){
|
||||
.expect(404, done);
|
||||
});
|
||||
|
||||
describePromises('promise support', function () {
|
||||
describe('promise support', function () {
|
||||
it('should pass rejected promise value', function (done) {
|
||||
var app = express()
|
||||
var route = app.route('/foo')
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, request = require('supertest');
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..');
|
||||
var request = require('supertest');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert');
|
||||
var assert = require('node:assert');
|
||||
var express = require('..');
|
||||
|
||||
describe('config', function () {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
describe('express.json()', function () {
|
||||
it('should parse JSON', function (done) {
|
||||
request(createApp())
|
||||
@@ -503,13 +500,13 @@ describe('express.json()', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
describe('async local storage', function () {
|
||||
before(function () {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -543,7 +540,7 @@ describe('express.json()', function () {
|
||||
this.app = app
|
||||
})
|
||||
|
||||
it('should presist store', function (done) {
|
||||
it('should persist store', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/json')
|
||||
@@ -565,7 +562,7 @@ describe('express.json()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflated', function (done) {
|
||||
it('should persist store when inflated', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/json')
|
||||
@@ -576,7 +573,7 @@ describe('express.json()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflate error', function (done) {
|
||||
it('should persist store when inflate error', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/json')
|
||||
@@ -586,7 +583,7 @@ describe('express.json()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when parse error', function (done) {
|
||||
it('should persist store when parse error', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/json')
|
||||
@@ -596,7 +593,7 @@ describe('express.json()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when limit exceeded', function (done) {
|
||||
it('should persist store when limit exceeded', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/json')
|
||||
@@ -756,11 +753,3 @@ function shouldContainInBody (str) {
|
||||
'expected \'' + res.text + '\' to contain \'' + str + '\'')
|
||||
}
|
||||
}
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
describe('express.raw()', function () {
|
||||
before(function () {
|
||||
@@ -328,13 +325,13 @@ describe('express.raw()', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
describe('async local storage', function () {
|
||||
before(function () {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -372,7 +369,7 @@ describe('express.raw()', function () {
|
||||
this.app = app
|
||||
})
|
||||
|
||||
it('should presist store', function (done) {
|
||||
it('should persist store', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/octet-stream')
|
||||
@@ -383,7 +380,7 @@ describe('express.raw()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when unmatched content-type', function (done) {
|
||||
it('should persist store when unmatched content-type', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/fizzbuzz')
|
||||
@@ -393,7 +390,7 @@ describe('express.raw()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflated', function (done) {
|
||||
it('should persist store when inflated', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/octet-stream')
|
||||
@@ -404,7 +401,7 @@ describe('express.raw()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflate error', function (done) {
|
||||
it('should persist store when inflate error', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/octet-stream')
|
||||
@@ -414,7 +411,7 @@ describe('express.raw()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when limit exceeded', function (done) {
|
||||
it('should persist store when limit exceeded', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/octet-stream')
|
||||
@@ -514,11 +511,3 @@ function createApp (options) {
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var request = require('supertest')
|
||||
var utils = require('./support/utils')
|
||||
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
const { Buffer } = require('node:buffer');
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
describe('express.text()', function () {
|
||||
before(function () {
|
||||
this.app = createApp()
|
||||
@@ -361,13 +357,13 @@ describe('express.text()', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
describe('async local storage', function () {
|
||||
before(function () {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -401,7 +397,7 @@ describe('express.text()', function () {
|
||||
this.app = app
|
||||
})
|
||||
|
||||
it('should presist store', function (done) {
|
||||
it('should persist store', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'text/plain')
|
||||
@@ -412,7 +408,7 @@ describe('express.text()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when unmatched content-type', function (done) {
|
||||
it('should persist store when unmatched content-type', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/fizzbuzz')
|
||||
@@ -422,7 +418,7 @@ describe('express.text()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflated', function (done) {
|
||||
it('should persist store when inflated', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'text/plain')
|
||||
@@ -433,7 +429,7 @@ describe('express.text()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflate error', function (done) {
|
||||
it('should persist store when inflate error', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'text/plain')
|
||||
@@ -443,7 +439,7 @@ describe('express.text()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when limit exceeded', function (done) {
|
||||
it('should persist store when limit exceeded', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'text/plain')
|
||||
@@ -568,11 +564,3 @@ function createApp (options) {
|
||||
|
||||
return app
|
||||
}
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,12 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
describe('express.urlencoded()', function () {
|
||||
before(function () {
|
||||
this.app = createApp()
|
||||
@@ -606,13 +603,13 @@ describe('express.urlencoded()', function () {
|
||||
})
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
describe('async local storage', function () {
|
||||
before(function () {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -646,7 +643,7 @@ describe('express.urlencoded()', function () {
|
||||
this.app = app
|
||||
})
|
||||
|
||||
it('should presist store', function (done) {
|
||||
it('should persist store', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -657,7 +654,7 @@ describe('express.urlencoded()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when unmatched content-type', function (done) {
|
||||
it('should persist store when unmatched content-type', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/fizzbuzz')
|
||||
@@ -667,7 +664,7 @@ describe('express.urlencoded()', function () {
|
||||
.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflated', function (done) {
|
||||
it('should persist store when inflated', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -678,7 +675,7 @@ describe('express.urlencoded()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when inflate error', function (done) {
|
||||
it('should persist store when inflate error', function (done) {
|
||||
var test = request(this.app).post('/')
|
||||
test.set('Content-Encoding', 'gzip')
|
||||
test.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -688,7 +685,7 @@ describe('express.urlencoded()', function () {
|
||||
test.end(done)
|
||||
})
|
||||
|
||||
it('should presist store when limit exceeded', function (done) {
|
||||
it('should persist store when limit exceeded', function (done) {
|
||||
request(this.app)
|
||||
.post('/')
|
||||
.set('Content-Type', 'application/x-www-form-urlencoded')
|
||||
@@ -829,11 +826,3 @@ function expectKeyCount (count) {
|
||||
assert.strictEqual(Object.keys(JSON.parse(res.text)).length, count)
|
||||
}
|
||||
}
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../');
|
||||
var request = require('supertest');
|
||||
|
||||
|
||||
@@ -45,6 +45,19 @@ describe('req', function(){
|
||||
.set('Accept-Charset', 'foo, bar')
|
||||
.expect('no', done);
|
||||
})
|
||||
|
||||
it('should return the best matching charset from multiple inputs', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res, next){
|
||||
res.end(req.acceptsCharsets('utf-8', 'iso-8859-1'));
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.set('Accept-Charset', 'iso-8859-1, utf-8')
|
||||
.expect('iso-8859-1', done);
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('req', function(){
|
||||
describe('.get(field)', function(){
|
||||
|
||||
@@ -39,7 +39,7 @@ describe('req', function(){
|
||||
app.enable('trust proxy');
|
||||
|
||||
app.use(function(req, res){
|
||||
req.connection.encrypted = true;
|
||||
req.socket.encrypted = true;
|
||||
res.end(req.protocol);
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('../')
|
||||
, request = require('supertest');
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var assert = require('node:assert')
|
||||
var express = require('..')
|
||||
var request = require('supertest')
|
||||
|
||||
@@ -108,7 +108,7 @@ function shouldHaveHeaderValues (key, values) {
|
||||
return function (res) {
|
||||
var headers = res.headers[key.toLowerCase()]
|
||||
assert.ok(headers, 'should have header "' + key + '"')
|
||||
assert.strictEqual(headers.length, values.length, 'should have ' + values.length + ' occurances of "' + key + '"')
|
||||
assert.strictEqual(headers.length, values.length, 'should have ' + values.length + ' occurrences of "' + key + '"')
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
assert.strictEqual(headers[i], values[i])
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest');
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, cookieParser = require('cookie-parser')
|
||||
var merge = require('utils-merge');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.cookie(name, object)', function(){
|
||||
@@ -130,7 +129,7 @@ describe('res', function(){
|
||||
var app = express();
|
||||
|
||||
var options = { maxAge: 1000 };
|
||||
var optionsCopy = merge({}, options);
|
||||
var optionsCopy = { ...options };
|
||||
|
||||
app.use(function(req, res){
|
||||
res.cookie('name', 'tobi', options)
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var request = require('supertest');
|
||||
var utils = require('./support/utils')
|
||||
|
||||
var FIXTURES_PATH = path.join(__dirname, 'fixtures')
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
describe('res', function(){
|
||||
describe('.download(path)', function(){
|
||||
it('should transfer as an attachment', function(done){
|
||||
@@ -91,14 +88,14 @@ describe('res', function(){
|
||||
.expect(200, cb);
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
it('should presist store', function (done) {
|
||||
describe('async local storage', function () {
|
||||
it('should persist store', function (done) {
|
||||
var app = express()
|
||||
var cb = after(2, done)
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -120,12 +117,12 @@ describe('res', function(){
|
||||
.expect(200, 'tobi', cb)
|
||||
})
|
||||
|
||||
it('should presist store on error', function (done) {
|
||||
it('should persist store on error', function (done) {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -488,11 +485,3 @@ describe('res', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
var after = require('after')
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
var app1 = express();
|
||||
|
||||
@@ -237,7 +237,7 @@ function test(app) {
|
||||
})
|
||||
|
||||
describe('when no match is made', function(){
|
||||
it('should should respond with 406 not acceptable', function(done){
|
||||
it('should respond with 406 not acceptable', function(done){
|
||||
request(app)
|
||||
.get('/')
|
||||
.set('Accept', 'foo/bar')
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.json(object)', function(){
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert');
|
||||
, assert = require('node:assert');
|
||||
var utils = require('./support/utils');
|
||||
|
||||
describe('res', function(){
|
||||
@@ -327,18 +327,4 @@ describe('res', function(){
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
it('should not override previous Content-Types', function(done){
|
||||
var app = express();
|
||||
|
||||
app.get('/', function(req, res){
|
||||
res.type('application/vnd.example+json');
|
||||
res.jsonp({ hello: 'world' });
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('content-type', 'application/vnd.example+json; charset=utf-8')
|
||||
.expect(200, '{"hello":"world"}', done)
|
||||
})
|
||||
})
|
||||
|
||||
@@ -43,5 +43,23 @@ describe('res', function(){
|
||||
.expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last", <http://api.example.com/users?page=1>; rel="prev"')
|
||||
.expect(200, done);
|
||||
})
|
||||
|
||||
it('should set multiple links for single rel', function (done) {
|
||||
var app = express();
|
||||
|
||||
app.use(function (req, res) {
|
||||
res.links({
|
||||
next: 'http://api.example.com/users?page=2',
|
||||
last: ['http://api.example.com/users?page=5', 'http://api.example.com/users?page=1']
|
||||
});
|
||||
|
||||
res.end();
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Link', '<http://api.example.com/users?page=2>; rel="next", <http://api.example.com/users?page=5>; rel="last", <http://api.example.com/users?page=1>; rel="last"')
|
||||
.expect(200, done);
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
, assert = require('assert')
|
||||
, url = require('url');
|
||||
, assert = require('node:assert')
|
||||
, url = require('node:url');
|
||||
|
||||
describe('res', function(){
|
||||
describe('.location(url)', function(){
|
||||
@@ -46,19 +46,7 @@ describe('res', function(){
|
||||
.expect(200, done)
|
||||
})
|
||||
|
||||
it('should encode data uri1', function (done) {
|
||||
var app = express()
|
||||
app.use(function (req, res) {
|
||||
res.location('data:text/javascript,export default () => { }').end();
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Location', 'data:text/javascript,export%20default%20()%20=%3E%20%7B%20%7D')
|
||||
.expect(200, done)
|
||||
})
|
||||
|
||||
it('should encode data uri2', function (done) {
|
||||
it('should encode data uri', function (done) {
|
||||
var app = express()
|
||||
app.use(function (req, res) {
|
||||
res.location('data:text/javascript,export default () => { }').end();
|
||||
|
||||
@@ -91,7 +91,7 @@ describe('res', function(){
|
||||
.set('Accept', 'text/html')
|
||||
.expect('Content-Type', /html/)
|
||||
.expect('Location', 'http://google.com')
|
||||
.expect(302, '<p>Found. Redirecting to http://google.com</p>', done)
|
||||
.expect(302, '<!DOCTYPE html><head><title>Found</title></head><body><p>Found. Redirecting to http://google.com</p></body>', done)
|
||||
})
|
||||
|
||||
it('should escape the url', function(done){
|
||||
@@ -107,7 +107,7 @@ describe('res', function(){
|
||||
.set('Accept', 'text/html')
|
||||
.expect('Content-Type', /html/)
|
||||
.expect('Location', '%3Cla\'me%3E')
|
||||
.expect(302, '<p>Found. Redirecting to %3Cla'me%3E</p>', done)
|
||||
.expect(302, '<!DOCTYPE html><head><title>Found</title></head><body><p>Found. Redirecting to %3Cla'me%3E</p></body>', done)
|
||||
})
|
||||
|
||||
it('should not render evil javascript links in anchor href (prevent XSS)', function(done){
|
||||
@@ -125,7 +125,7 @@ describe('res', function(){
|
||||
.set('Accept', 'text/html')
|
||||
.expect('Content-Type', /html/)
|
||||
.expect('Location', encodedXss)
|
||||
.expect(302, '<p>Found. Redirecting to ' + encodedXss +'</p>', done);
|
||||
.expect(302, '<!DOCTYPE html><head><title>Found</title></head><body><p>Found. Redirecting to ' + encodedXss +'</p></body>', done);
|
||||
});
|
||||
|
||||
it('should include the redirect type', function(done){
|
||||
@@ -140,7 +140,7 @@ describe('res', function(){
|
||||
.set('Accept', 'text/html')
|
||||
.expect('Content-Type', /html/)
|
||||
.expect('Location', 'http://google.com')
|
||||
.expect(301, '<p>Moved Permanently. Redirecting to http://google.com</p>', done);
|
||||
.expect(301, '<!DOCTYPE html><head><title>Moved Permanently</title></head><body><p>Moved Permanently. Redirecting to http://google.com</p></body>', done);
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var express = require('..');
|
||||
var path = require('path')
|
||||
var path = require('node:path')
|
||||
var request = require('supertest');
|
||||
var tmpl = require('./support/tmpl');
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
const { Buffer } = require('node:buffer');
|
||||
var express = require('..');
|
||||
var methods = require('methods');
|
||||
var methods = require('../lib/utils').methods;
|
||||
var request = require('supertest');
|
||||
var utils = require('./support/utils');
|
||||
|
||||
@@ -178,6 +178,19 @@ describe('res', function(){
|
||||
.expect(200, 'hey', done);
|
||||
})
|
||||
|
||||
it('should accept Uint8Array', function(done){
|
||||
var app = express();
|
||||
app.use(function(req, res){
|
||||
const encodedHey = new TextEncoder().encode("hey");
|
||||
res.set("Content-Type", "text/plain").send(encodedHey);
|
||||
})
|
||||
|
||||
request(app)
|
||||
.get("/")
|
||||
.expect("Content-Type", "text/plain; charset=utf-8")
|
||||
.expect(200, "hey", done);
|
||||
})
|
||||
|
||||
it('should not override ETag', function (done) {
|
||||
var app = express()
|
||||
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
'use strict'
|
||||
|
||||
var after = require('after');
|
||||
var assert = require('assert')
|
||||
var asyncHooks = tryRequire('async_hooks')
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert')
|
||||
var AsyncLocalStorage = require('node:async_hooks').AsyncLocalStorage
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
var express = require('../')
|
||||
, request = require('supertest')
|
||||
var onFinished = require('on-finished');
|
||||
var path = require('path');
|
||||
var path = require('node:path');
|
||||
var fixtures = path.join(__dirname, 'fixtures');
|
||||
var utils = require('./support/utils');
|
||||
|
||||
var describeAsyncHooks = typeof asyncHooks.AsyncLocalStorage === 'function'
|
||||
? describe
|
||||
: describe.skip
|
||||
|
||||
describe('res', function(){
|
||||
describe('.sendFile(path)', function () {
|
||||
it('should error missing path', function (done) {
|
||||
@@ -82,6 +79,19 @@ describe('res', function(){
|
||||
});
|
||||
});
|
||||
|
||||
it('should disable the ETag function if requested', function (done) {
|
||||
var app = createApp(path.resolve(fixtures, 'name.txt')).disable('etag');
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect(handleHeaders)
|
||||
.expect(200, done);
|
||||
|
||||
function handleHeaders (res) {
|
||||
assert(res.headers.etag === undefined);
|
||||
}
|
||||
});
|
||||
|
||||
it('should 404 for directory', function (done) {
|
||||
var app = createApp(path.resolve(fixtures, 'blog'));
|
||||
|
||||
@@ -267,14 +277,14 @@ describe('res', function(){
|
||||
.expect(200, 'got 404 error', done)
|
||||
})
|
||||
|
||||
describeAsyncHooks('async local storage', function () {
|
||||
it('should presist store', function (done) {
|
||||
describe('async local storage', function () {
|
||||
it('should persist store', function (done) {
|
||||
var app = express()
|
||||
var cb = after(2, done)
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -295,12 +305,12 @@ describe('res', function(){
|
||||
.expect(200, 'tobi', cb)
|
||||
})
|
||||
|
||||
it('should presist store on error', function (done) {
|
||||
it('should persist store on error', function (done) {
|
||||
var app = express()
|
||||
var store = { foo: 'bar' }
|
||||
|
||||
app.use(function (req, res, next) {
|
||||
req.asyncLocalStorage = new asyncHooks.AsyncLocalStorage()
|
||||
req.asyncLocalStorage = new AsyncLocalStorage()
|
||||
req.asyncLocalStorage.run(store, next)
|
||||
})
|
||||
|
||||
@@ -901,11 +911,3 @@ function createApp(path, options, fn) {
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
function tryRequire (name) {
|
||||
try {
|
||||
return require(name)
|
||||
} catch (e) {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,5 +42,74 @@ describe('res', function(){
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/vnd.amazon.ebook', done);
|
||||
})
|
||||
|
||||
describe('edge cases', function(){
|
||||
it('should handle empty string gracefully', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.type('').end('test');
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/octet-stream')
|
||||
.end(done);
|
||||
})
|
||||
|
||||
it('should handle file extension with dots', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.type('.json').end('{"test": true}');
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/json; charset=utf-8')
|
||||
.end(done);
|
||||
})
|
||||
|
||||
it('should handle multiple file extensions', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.type('file.tar.gz').end('compressed');
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/gzip')
|
||||
.end(done);
|
||||
})
|
||||
|
||||
it('should handle uppercase extensions', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.type('FILE.JSON').end('{"test": true}');
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/json; charset=utf-8')
|
||||
.end(done);
|
||||
})
|
||||
|
||||
it('should handle extension with special characters', function(done){
|
||||
var app = express();
|
||||
|
||||
app.use(function(req, res){
|
||||
res.type('file@test.json').end('{"test": true}');
|
||||
});
|
||||
|
||||
request(app)
|
||||
.get('/')
|
||||
.expect('Content-Type', 'application/json; charset=utf-8')
|
||||
.end(done);
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
var fs = require('fs');
|
||||
var fs = require('node:fs');
|
||||
|
||||
var variableRegExp = /\$([0-9a-zA-Z\.]+)/g;
|
||||
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
* @private
|
||||
*/
|
||||
|
||||
var assert = require('assert');
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert');
|
||||
const { Buffer } = require('node:buffer');
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
@@ -77,10 +77,10 @@ function getMajorVersion(versionString) {
|
||||
}
|
||||
|
||||
function shouldSkipQuery(versionString) {
|
||||
// Skipping HTTP QUERY tests on Node 21, it is reported in http.METHODS on 21.7.2 but not supported
|
||||
// update this implementation to run on supported versions of 21 once they exist
|
||||
// Skipping HTTP QUERY tests below Node 22, QUERY wasn't fully supported by Node until 22
|
||||
// we could update this implementation to run on supported versions of 21 once they exist
|
||||
// upstream tracking https://github.com/nodejs/node/issues/51562
|
||||
// express tracking issue: https://github.com/expressjs/express/issues/5615
|
||||
return Number(getMajorVersion(versionString)) === 21
|
||||
return Number(getMajorVersion(versionString)) < 22
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
'use strict'
|
||||
|
||||
var assert = require('assert');
|
||||
var Buffer = require('safe-buffer').Buffer
|
||||
var assert = require('node:assert');
|
||||
const { Buffer } = require('node:buffer');
|
||||
var utils = require('../lib/utils');
|
||||
|
||||
describe('utils.etag(body, encoding)', function(){
|
||||
@@ -26,6 +26,25 @@ describe('utils.etag(body, encoding)', function(){
|
||||
})
|
||||
})
|
||||
|
||||
describe('utils.normalizeType acceptParams method', () => {
|
||||
it('should handle a type with a malformed parameter and break the loop in acceptParams', () => {
|
||||
const result = utils.normalizeType('text/plain;invalid');
|
||||
assert.deepEqual(result,{
|
||||
value: 'text/plain',
|
||||
quality: 1,
|
||||
params: {} // No parameters are added since "invalid" has no "="
|
||||
});
|
||||
});
|
||||
|
||||
it('should default to application/octet-stream when mime lookup fails', () => {
|
||||
const result = utils.normalizeType('unknown-extension-xyz');
|
||||
assert.deepEqual(result, {
|
||||
value: 'application/octet-stream',
|
||||
params: {}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('utils.setCharset(type, charset)', function () {
|
||||
it('should do anything without type', function () {
|
||||
assert.strictEqual(utils.setCharset(), undefined);
|
||||
@@ -69,3 +88,28 @@ describe('utils.wetag(body, encoding)', function(){
|
||||
'W/"0-2jmj7l5rSw0yVb/vlWAYkK/YBwk"')
|
||||
})
|
||||
})
|
||||
|
||||
describe('utils.compileETag()', function () {
|
||||
it('should return generateETag for true', function () {
|
||||
const fn = utils.compileETag(true);
|
||||
assert.strictEqual(fn('express!'), utils.wetag('express!'));
|
||||
});
|
||||
|
||||
it('should return undefined for false', function () {
|
||||
assert.strictEqual(utils.compileETag(false), undefined);
|
||||
});
|
||||
|
||||
it('should return generateETag for string values "strong" and "weak"', function () {
|
||||
assert.strictEqual(utils.compileETag('strong')("express"), utils.etag("express"));
|
||||
assert.strictEqual(utils.compileETag('weak')("express"), utils.wetag("express"));
|
||||
});
|
||||
|
||||
it('should throw for unknown string values', function () {
|
||||
assert.throws(() => utils.compileETag('foo'), TypeError);
|
||||
});
|
||||
|
||||
it('should throw for unsupported types like arrays and objects', function () {
|
||||
assert.throws(() => utils.compileETag([]), TypeError);
|
||||
assert.throws(() => utils.compileETag({}), TypeError);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user