diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
new file mode 100644
index 0000000000..b983583855
--- /dev/null
+++ b/.github/CODEOWNERS
@@ -0,0 +1,8 @@
+# Website development
+* @expressjs/docs-collaborators
+
+# Codeowners
+.github/CODEOWNERS @expressjs/docs-captains
+
+# Blog
+_posts @expressjs/express-tc
\ No newline at end of file
diff --git a/.github/dependabot.yml b/.github/dependabot.yml
new file mode 100644
index 0000000000..ec082eb3d7
--- /dev/null
+++ b/.github/dependabot.yml
@@ -0,0 +1,25 @@
+version: 2
+updates:
+ - package-ecosystem: github-actions
+ directory: /
+ schedule:
+ interval: monthly
+
+ - package-ecosystem: docker
+ directory: /
+ schedule:
+ interval: monthly
+
+ - package-ecosystem: bundler
+ directory: /
+ schedule:
+ interval: monthly
+
+ - package-ecosystem: npm
+ directory: /
+ schedule:
+ interval: monthly
+ open-pull-requests-limit: 10
+ ignore:
+ - dependency-name: "*"
+ update-types: ["version-update:semver-major"]
diff --git a/.github/scripts/get-contributing.sh b/.github/scripts/get-contributing.sh
new file mode 100755
index 0000000000..2b046e4d1a
--- /dev/null
+++ b/.github/scripts/get-contributing.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+
+# This script replaces the contents of a section with the contents from the annotated source address or local file paths inside the DEST file.
+
+# read contents of file into memory
+DEST="../../en/resources/contributing.md"
+
+# track the header level
+level=''
+# tracks src for curl calls
+src=''
+# tracks file paths for local file reads
+local=''
+ while IFS= read -r line; do
+ # REMOVE PREVIOUS CONTENT SECTION
+ # if src or local tags are not empty
+ if [[ -n "$src" || -n "$local" ]]; then
+ # if current line not a horitzontal rule hr
+ if [[ "$line" != "----"* ]]; then
+ # if line == level -- level is num of ##
+ if [[ "$line" == "$level"'#'* ||
+ # line not a header line
+ "$line" != '#'* ]]; then
+ # skip line and rewrite over old content
+ continue
+ fi
+ fi
+ fi
+
+ # PRINT TO PAGE SECTION
+ src=''
+ local=''
+ # if line is a header
+ if [[ "$line" == '#'* ]]; then
+ # if header has (#id-of-link) or {#id-on-page} patterns
+ if [[ $line =~ (\(\#.*\))\. || "$line" =~ \{\#.*\} ]]; then
+ # isolate the matching part of line
+ match=${BASH_REMATCH[0]}
+ # remove match - leaving rest
+ rest=${line//${match}}
+ # remove any # symbols from start
+ title_rest=${rest##*\#}
+ # slice rest of line to get only level
+ level="${rest:0:$((${#rest} - ${#title_rest}))}"
+ else
+ # any other headers -- these before SRC/LOCAL pages anchors
+ header=${line##*\#}
+ level="${line:0:$((${#line} - ${#header}))}"
+ fi
+ # if line is SRC anchor in read file
+ elif [[ "$line" == '
-
diff --git a/_includes/header/header-en.html b/_includes/header/header-en.html
deleted file mode 100644
index 68f49a1df9..0000000000
--- a/_includes/header/header-en.html
+++ /dev/null
@@ -1,178 +0,0 @@
-
{% include notice/notice-{{ page.lang }}.md %}
-{{ notice }} {{ notice_link_text}}.
+Diese Übersetzung zur Verfügung gestellt von StrongLoop / IBM.
- -Dieses Dokument kann im Vergleich zur englischen Dokumentation veraltet sein. Aktuelle Updates finden Sie in der englischen Dokumentation. diff --git a/_includes/notice/notice-en.md b/_includes/notice/notice-en.md deleted file mode 100755 index 85d0ac63e1..0000000000 --- a/_includes/notice/notice-en.md +++ /dev/null @@ -1 +0,0 @@ -This document might be outdated relative to the documentation in English. For the latest updates, please refer to the documentation in English. diff --git a/_includes/notice/notice-es.md b/_includes/notice/notice-es.md deleted file mode 100755 index d6db223672..0000000000 --- a/_includes/notice/notice-es.md +++ /dev/null @@ -1,3 +0,0 @@ -Esta traducción proporcionada por StrongLoop / IBM.
- -Este documento puede estar desfasado respecto a la documentación en inglés. Para ver las últimas actualizaciones, consulte la documentación en inglés. diff --git a/_includes/notice/notice-fr.md b/_includes/notice/notice-fr.md deleted file mode 100755 index c3b485eae3..0000000000 --- a/_includes/notice/notice-fr.md +++ /dev/null @@ -1,3 +0,0 @@ -Cette traduction fournie par StrongLoop / IBM.
- -Il se peut que ce document soit obsolète par rapport à la documentation en anglais. Pour connaître les mises à jour les plus récentes, reportez-vous à la documentation en anglais. diff --git a/_includes/notice/notice-it.md b/_includes/notice/notice-it.md deleted file mode 100755 index f18c2c7109..0000000000 --- a/_includes/notice/notice-it.md +++ /dev/null @@ -1,3 +0,0 @@ -Questa traduzione fornita da StrongLoop / IBM.
- -È possibile che questo documento non sia aggiornato poiché la documentazione è in inglese. Per gli ultimi aggiornamenti, fare riferimento alla documentazione in inglese. diff --git a/_includes/notice/notice-ja.md b/_includes/notice/notice-ja.md deleted file mode 100755 index ec7b72ead1..0000000000 --- a/_includes/notice/notice-ja.md +++ /dev/null @@ -1,3 +0,0 @@ -StrongLoop / IBMによって提供されるこの翻訳.
- -本書は、英語の資料と比較すると古くなっている可能性があります。最新の更新については、英語版の資料を参照してください。 diff --git a/_includes/notice/notice-ko.md b/_includes/notice/notice-ko.md deleted file mode 100755 index 7a2e866c8a..0000000000 --- a/_includes/notice/notice-ko.md +++ /dev/null @@ -1,3 +0,0 @@ -StrongLoop / IBM에 의해 제공이 번역.
- -이 문서는 영문판 문서에 비해 더 오래된 버전일 수도 있습니다. 최신 업데이트를 확인하려면 영문판 문서를 참조하십시오. diff --git a/_includes/notice/notice-pt-br.md b/_includes/notice/notice-pt-br.md deleted file mode 100755 index 2d5fc7c7ae..0000000000 --- a/_includes/notice/notice-pt-br.md +++ /dev/null @@ -1,3 +0,0 @@ -Esta tradução fornecida pelo StrongLoop / IBM.
- -Este documento pode estar desatualizado em relação à documentação em Inglês. Para obter as atualizações mais recentes, consulte a documentação em Inglês. diff --git a/_includes/notice/notice-ru.md b/_includes/notice/notice-ru.md deleted file mode 100755 index 9b690b4de8..0000000000 --- a/_includes/notice/notice-ru.md +++ /dev/null @@ -1,3 +0,0 @@ -Этот перевод обеспечивается StrongLoop / IBM.
- -Этот документ может быть устаревшим по отношению к документации на английском языке. Последние обновления содержатся в документации на английском языке. diff --git a/_includes/notice/notice-sk.md b/_includes/notice/notice-sk.md deleted file mode 100644 index 4d135d577a..0000000000 --- a/_includes/notice/notice-sk.md +++ /dev/null @@ -1 +0,0 @@ -Tento dokument môže byť v porovnaní s dokumentáciou v angličtine zastaralý. Aktuálne informácie nájdete v dokumentácii v angličtine. diff --git a/_includes/notice/notice-th.md b/_includes/notice/notice-th.md deleted file mode 100755 index eff97e8d5d..0000000000 --- a/_includes/notice/notice-th.md +++ /dev/null @@ -1 +0,0 @@ -ในเอกสารนี้อาจจะเก่าไปแล้วที่เกี่ยวเนื่องกับรุ่นของเอกสารในภาษาอังกฤษ สำหรับรุ่นล่าสุดโปรดอ้างอิงจาก เอกสารในภาษาอังกฤษ. diff --git a/_includes/notice/notice-tr.md b/_includes/notice/notice-tr.md deleted file mode 100644 index 51df1fe86a..0000000000 --- a/_includes/notice/notice-tr.md +++ /dev/null @@ -1 +0,0 @@ -Bu doküman ingilizce dokümana göre eski olabilir. Son güncellemeler için lütfen İngilizce Dokümanı. ziyaret edin diff --git a/_includes/notice/notice-uk.md b/_includes/notice/notice-uk.md deleted file mode 100755 index a008968378..0000000000 --- a/_includes/notice/notice-uk.md +++ /dev/null @@ -1 +0,0 @@ -Цей документ може бути застарілим, в порівнянні з оригінальною англійською версією документації. diff --git a/_includes/notice/notice-uz.md b/_includes/notice/notice-uz.md deleted file mode 100755 index 85d0ac63e1..0000000000 --- a/_includes/notice/notice-uz.md +++ /dev/null @@ -1 +0,0 @@ -This document might be outdated relative to the documentation in English. For the latest updates, please refer to the documentation in English. diff --git a/_includes/notice/notice-zh-cn.md b/_includes/notice/notice-zh-cn.md deleted file mode 100755 index a61ca1ac3f..0000000000 --- a/_includes/notice/notice-zh-cn.md +++ /dev/null @@ -1,3 +0,0 @@ -这个翻译StrongLoop / IBM提供.
- -相对于英文版的文档,本文档可能已过时。要了解最近的更新,请参阅英文版文档。 diff --git a/_includes/notice/notice-zh-tw.md b/_includes/notice/notice-zh-tw.md deleted file mode 100755 index 2c176fee06..0000000000 --- a/_includes/notice/notice-zh-tw.md +++ /dev/null @@ -1,3 +0,0 @@ -這個翻譯StrongLoop / IBM提供.
- -相對於英文版說明文件,本文件可能已不合時宜。如需最新的更新,請參閱英文版說明文件。 diff --git a/_includes/readmes/body-parser.md b/_includes/readmes/body-parser.md index 7d7fa882ce..7fe2e56935 100644 --- a/_includes/readmes/body-parser.md +++ b/_includes/readmes/body-parser.md @@ -1,9 +1,10 @@ # body-parser -[![NPM Version][npm-image]][npm-url] -[![NPM Downloads][downloads-image]][downloads-url] -[![Build Status][github-actions-ci-image]][github-actions-ci-url] +[![NPM Version][npm-version-image]][npm-url] +[![NPM Downloads][npm-downloads-image]][npm-url] +[![Build Status][ci-image]][ci-url] [![Test Coverage][coveralls-image]][coveralls-url] +[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer] Node.js body parsing middleware. @@ -50,14 +51,12 @@ $ npm install body-parser ## API ```js -var bodyParser = require('body-parser') +const bodyParser = require('body-parser') ``` The `bodyParser` object exposes various factories to create middlewares. All middlewares will populate the `req.body` property with the parsed body when -the `Content-Type` request header matches the `type` option, or an empty -object (`{}`) if there was no body to parse, the `Content-Type` was not matched, -or an error occurred. +the `Content-Type` request header matches the `type` option. The various errors returned by this module are described in the [errors section](#errors). @@ -66,8 +65,8 @@ The various errors returned by this module are described in the Returns middleware that only parses `json` and only looks at requests where the `Content-Type` header matches the `type` option. This parser accepts any -Unicode encoding of the body and supports automatic inflation of `gzip` and -`deflate` encodings. +Unicode encoding of the body and supports automatic inflation of `gzip`, +`br` (brotli) and `deflate` encodings. A new `body` object containing the parsed data is populated on the `request` object after the middleware (i.e. `req.body`). @@ -77,6 +76,11 @@ object after the middleware (i.e. `req.body`). The `json` function takes an optional `options` object that may contain any of the following keys: +##### defaultCharset + +Specify the default character set for the json content if the charset is not +specified in the `Content-Type` header of the request. Defaults to `utf-8`. + ##### inflate When set to `true`, then deflated (compressed) bodies will be inflated; when @@ -121,7 +125,8 @@ encoding of the request. The parsing can be aborted by throwing an error. Returns middleware that parses all bodies as a `Buffer` and only looks at requests where the `Content-Type` header matches the `type` option. This -parser supports automatic inflation of `gzip` and `deflate` encodings. +parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate` +encodings. A new `body` object containing the parsed data is populated on the `request` object after the middleware (i.e. `req.body`). This will be a `Buffer` object @@ -166,7 +171,8 @@ encoding of the request. The parsing can be aborted by throwing an error. Returns middleware that parses all bodies as a string and only looks at requests where the `Content-Type` header matches the `type` option. This -parser supports automatic inflation of `gzip` and `deflate` encodings. +parser supports automatic inflation of `gzip`, `br` (brotli) and `deflate` +encodings. A new `body` string containing the parsed data is populated on the `request` object after the middleware (i.e. `req.body`). This will be a string of the @@ -216,7 +222,7 @@ encoding of the request. The parsing can be aborted by throwing an error. Returns middleware that only parses `urlencoded` bodies and only looks at requests where the `Content-Type` header matches the `type` option. This parser accepts only UTF-8 encoding of the body and supports automatic -inflation of `gzip` and `deflate` encodings. +inflation of `gzip`, `br` (brotli) and `deflate` encodings. A new `body` object containing the parsed data is populated on the `request` object after the middleware (i.e. `req.body`). This object will contain @@ -230,16 +236,12 @@ any of the following keys: ##### extended -The `extended` option allows to choose between parsing the URL-encoded data -with the `querystring` library (when `false`) or the `qs` library (when -`true`). The "extended" syntax allows for rich objects and arrays to be -encoded into the URL-encoded format, allowing for a JSON-like experience -with URL-encoded. For more information, please -[see the qs library](https://www.npmjs.org/package/qs#readme). +The "extended" syntax allows for rich objects and arrays to be encoded into the +URL-encoded format, allowing for a JSON-like experience with URL-encoded. For +more information, please [see the qs +library](https://www.npmjs.org/package/qs#readme). -Defaults to `true`, but using the default has been deprecated. Please -research into the difference between `qs` and `querystring` and choose the -appropriate setting. +Defaults to `false`. ##### inflate @@ -277,6 +279,27 @@ The `verify` option, if supplied, is called as `verify(req, res, buf, encoding)` where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. +##### defaultCharset + +The default charset to parse as, if not specified in content-type. Must be +either `utf-8` or `iso-8859-1`. Defaults to `utf-8`. + +##### charsetSentinel + +Whether to let the value of the `utf8` parameter take precedence as the charset +selector. It requires the form to contain a parameter named `utf8` with a value +of `✓`. Defaults to `false`. + +##### interpretNumericEntities + +Whether to decode numeric entities such as `☺` when parsing an iso-8859-1 +form. Defaults to `false`. + + +##### depth + +The `depth` option is used to configure the maximum depth of the `qs` library when `extended` is `true`. This allows you to limit the amount of keys that are parsed and can be useful to prevent certain types of abuse. Defaults to `32`. It is recommended to keep this value as low as possible. + ## Errors The middlewares provided by this module create errors using the @@ -342,6 +365,14 @@ to this middleware. This module operates directly on bytes only and you cannot call `req.setEncoding` when using this module. The `status` property is set to `500` and the `type` property is set to `'stream.encoding.set'`. +### stream is not readable + +This error will occur when the request is no longer readable when this middleware +attempts to read it. This typically means something other than a middleware from +this module read the request body already and the middleware was also configured to +read the same request. The `status` property is set to `500` and the `type` +property is set to `'stream.not.readable'`. + ### too many parameters This error will occur when the content of the request exceeds the configured @@ -365,6 +396,10 @@ as well as in the `encoding` property. The `status` property is set to `415`, the `type` property is set to `'encoding.unsupported'`, and the `encoding` property is set to the encoding that is unsupported. +### The input exceeded the depth + +This error occurs when using `bodyParser.urlencoded` with the `extended` property set to `true` and the input exceeds the configured `depth` option. The `status` property is set to `400`. It is recommended to review the `depth` option and evaluate if it requires a higher value. When the `depth` option is set to `32` (default value), the error will not be thrown. + ## Examples ### Express/Connect top-level generic @@ -374,13 +409,13 @@ top-level middleware, which will parse the bodies of all incoming requests. This is the simplest setup. ```js -var express = require('express') -var bodyParser = require('body-parser') +const express = require('express') +const bodyParser = require('body-parser') -var app = express() +const app = express() // parse application/x-www-form-urlencoded -app.use(bodyParser.urlencoded({ extended: false })) +app.use(bodyParser.urlencoded()) // parse application/json app.use(bodyParser.json()) @@ -388,7 +423,7 @@ app.use(bodyParser.json()) app.use(function (req, res) { res.setHeader('Content-Type', 'text/plain') res.write('you posted:\n') - res.end(JSON.stringify(req.body, null, 2)) + res.end(String(JSON.stringify(req.body, null, 2))) }) ``` @@ -399,24 +434,26 @@ need them. In general, this is the most recommended way to use body-parser with Express. ```js -var express = require('express') -var bodyParser = require('body-parser') +const express = require('express') +const bodyParser = require('body-parser') -var app = express() +const app = express() // create application/json parser -var jsonParser = bodyParser.json() +const jsonParser = bodyParser.json() // create application/x-www-form-urlencoded parser -var urlencodedParser = bodyParser.urlencoded({ extended: false }) +const urlencodedParser = bodyParser.urlencoded() // POST /login gets urlencoded bodies app.post('/login', urlencodedParser, function (req, res) { + if (!req.body || !req.body.username) res.sendStatus(400) res.send('welcome, ' + req.body.username) }) // POST /api/users gets JSON bodies app.post('/api/users', jsonParser, function (req, res) { + if (!req.body) res.sendStatus(400) // create user in req.body }) ``` @@ -427,10 +464,10 @@ All the parsers accept a `type` option which allows you to change the `Content-Type` that the middleware will parse. ```js -var express = require('express') -var bodyParser = require('body-parser') +const express = require('express') +const bodyParser = require('body-parser') -var app = express() +const app = express() // parse various different custom JSON types as JSON app.use(bodyParser.json({ type: 'application/*+json' })) @@ -446,11 +483,14 @@ app.use(bodyParser.text({ type: 'text/html' })) [MIT](LICENSE) -[npm-image]: https://img.shields.io/npm/v/body-parser.svg -[npm-url]: https://npmjs.org/package/body-parser -[coveralls-image]: https://img.shields.io/coveralls/expressjs/body-parser/master.svg +[ci-image]: https://badgen.net/github/checks/expressjs/body-parser/master?label=ci +[ci-url]: https://github.com/expressjs/body-parser/actions/workflows/ci.yml +[coveralls-image]: https://badgen.net/coveralls/c/github/expressjs/body-parser/master [coveralls-url]: https://coveralls.io/r/expressjs/body-parser?branch=master -[downloads-image]: https://img.shields.io/npm/dm/body-parser.svg -[downloads-url]: https://npmjs.org/package/body-parser -[github-actions-ci-image]: https://img.shields.io/github/workflow/status/expressjs/body-parser/ci/master?label=ci -[github-actions-ci-url]: https://github.com/expressjs/body-parser?query=workflow%3Aci +[node-version-image]: https://badgen.net/npm/node/body-parser +[node-version-url]: https://nodejs.org/en/download +[npm-downloads-image]: https://badgen.net/npm/dm/body-parser +[npm-url]: https://npmjs.org/package/body-parser +[npm-version-image]: https://badgen.net/npm/v/body-parser +[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/body-parser/badge +[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/body-parser \ No newline at end of file diff --git a/_includes/readmes/compression.md b/_includes/readmes/compression.md index 680ece8776..df1bd78947 100644 --- a/_includes/readmes/compression.md +++ b/_includes/readmes/compression.md @@ -2,8 +2,10 @@ [![NPM Version][npm-image]][npm-url] [![NPM Downloads][downloads-image]][downloads-url] -[![Build Status][travis-image]][travis-url] -[![Test Coverage][coveralls-image]][coveralls-url] +[![Build Status][github-actions-ci-image]][github-actions-ci-url] +[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer] +[![Funding][funding-image]][funding-url] + Node.js compression middleware. @@ -11,6 +13,9 @@ The following compression codings are supported: - deflate - gzip + - br (brotli) + +**Note** Brotli is supported only since Node.js versions v11.7.0 and v10.16.0. ## Install @@ -24,8 +29,6 @@ $ npm install compression ## API - - ```js var compression = require('compression') ``` @@ -33,7 +36,7 @@ var compression = require('compression') ### compression([options]) Returns the compression middleware using the given `options`. The middleware -will attempt to compress response bodies for all request that traverse through +will attempt to compress response bodies for all requests that traverse through the middleware, based on the given `options`. This middleware will never compress responses that include a `Cache-Control` @@ -43,18 +46,22 @@ as compressing will transform the body. #### Options `compression()` accepts these properties in the options object. In addition to -those listed below, [zlib](http://nodejs.org/api/zlib.html) options may be -passed in to the options object. +those listed below, [zlib](https://nodejs.org/api/zlib.html) options may be +passed in to the options object or +[brotli](https://nodejs.org/api/zlib.html#zlib_class_brotlioptions) options. ##### chunkSize -The default value is `zlib.Z_DEFAULT_CHUNK`, or `16384`. +Type: `Number`
-
-# /etc/init/env.conf
- env NODE_ENV=production
-
-
-
-Weitere Informationen hierzu siehe [Upstart Intro, Cookbook and Best Practices](http://upstart.ubuntu.com/cookbook/#environment-variables).
+In einer Entwicklungsumgebung wird die Umgebungsvariable in der Regel in Ihrer interaktiven Shell festgelegt, indem Sie beispielsweise `export` oder Ihre Datei `.bash_profile` verwenden. But in general, you shouldn't do that on a production server; instead, use your OS's init system (systemd). Der nächste Abschnitt enthält weitere Details zur Verwendung des Init-Systems im Allgemeinen. Die Festlegung von NODE_ENV ist jedoch für das Leistungsverhalten so wichtig (und so einfach durchzuführen), dass hier besonders darauf eingegangen wird.
Verwenden Sie bei systemd die Anweisung `Environment` in Ihrer Einheitendatei. Beispiel:
-
-
+```sh
# /etc/systemd/system/myservice.service
Environment=NODE_ENV=production
-
-
-
-Weitere Informationen siehe [Umgebungsvariablen in systemd-Einheiten verwenden](https://coreos.com/os/docs/latest/using-environment-variables-in-systemd-units.html).
+```
-Wenn Sie StrongLoop Process Manager verwenden, können Sie auch die [Umgebungsvariable festlegen, wenn Sie StrongLoop Process Manager als Service installieren](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-Setenvironmentvariables).
+For more information, see [Using Environment Variables In systemd Units](https://www.flatcar.org/docs/latest/setup/systemd/environment-variables/).
### Automatischen Neustart Ihrer Anwendung sicherstellen
In der Produktionsumgebung sollte die Anwendung nie offline sein. Das bedeutet, dass Sie sicherstellen müssen, dass die Anwendung bei einem Absturz der Anwendung oder des Servers immer wieder neu gestartet wird. Auch wenn man hofft, das keines dieser Ereignisse jemals eintritt, muss man doch mit beiden Möglichkeiten rechnen und:
-* einen Prozessmanager verwenden, um die Anwendung (und Node) bei einem Absturz neu zu starten.
-* das Init-System Ihres Betriebssystems verwenden, um den Prozessmanager bei einem Absturz des Betriebssystems neu zu starten. Außerdem kann das Init-System auch ohne einen Prozessmanager verwendet werden.
+- einen Prozessmanager verwenden, um die Anwendung (und Node) bei einem Absturz neu zu starten.
+- das Init-System Ihres Betriebssystems verwenden, um den Prozessmanager bei einem Absturz des Betriebssystems neu zu starten. Außerdem kann das Init-System auch ohne einen Prozessmanager verwendet werden.
Node-Anwendungen stürzen ab, wenn eine nicht abgefangene Ausnahmebedingung auftritt. Als Erstes müssen Sie in einem solchen Fall sicherstellen, dass Ihre Anwendung ausreichend getestet wurde und in der Lage ist, alle Ausnahmebedingungen zu handhaben (weitere Informationen siehe [Ausnahmebedingungen ordnungsgemäß handhaben](#exceptions)). Die sicherste Maßnahme ist jedoch, einen Mechanismus zu implementieren, über den bei einem Absturz der Anwendung ein automatischer Neustart der Anwendung ausgeführt wird.
@@ -232,55 +194,35 @@ In Entwicklungumgebungen wird die Anwendung einfach über die Befehlszeile mit `
Neben einem Neustart der Anwendung nach einem Absturz bietet ein Prozessmanager noch weitere Möglichkeiten:
-* Einblicke in die Laufzeitleistung und die Ressourcennutzung
-* Dynamische Änderung der Einstellungen zur Verbesserung des Leistungsverhaltens
-* Steuerung des Clustering (StrongLoop PM und PM2)
-
-Die gängigsten Prozessmanager für Node sind:
-
-* [StrongLoop Process Manager](http://strong-pm.io/)
-* [PM2](https://github.com/Unitech/pm2)
-* [Forever](https://www.npmjs.com/package/forever)
-
-Einen Vergleich der Features und Funktionen dieser Prozessmanager finden Sie hier: [http://strong-pm.io/compare/](http://strong-pm.io/compare/). Eine ausführliche Einführung in diese drei Prozessmanager finden Sie hier: [Prozessmanager für Express-Anwendungen](/{{ page.lang }}/advanced/pm.html).
-
-Die Verwendung eines dieser Prozessmanager reicht aus, um Ihre Anwendung betriebsbereit zu halten, selbst wenn sie hin und wieder abstürzt.
+- Einblicke in die Laufzeitleistung und die Ressourcennutzung
+- Dynamische Änderung der Einstellungen zur Verbesserung des Leistungsverhaltens
+- Control clustering (pm2).
-StrongLoop PM verfügt jedoch über zahlreiche Features und Funktionen, die sich speziell auf Implementierungen in der Produktionsumgebung beziehen. Sie können diesen Prozessmanager und die zugehörigen StrongLoop-Tools für folgende Zwecke verwenden:
-
-* Lokales Erstellen und Packen Ihrer Anwendung mit anschließender sicherer Bereitstellung auf Ihrem Produktionssystem
-* Automatischer Neustart Ihrer Anwendung nach einem Absturz aus irgendeinem Grund
-* Verwaltung Ihrer Cluster über Fernzugriff
-* Anzeige von CPU-Profilen und Heapspeichermomentaufnahmen (Heap-Snapshots) zur Optimierung der Leistung und Diagnose von Speicherlecks
-* Anzeige von Leistungsmessdaten für Ihre Anwendung
-* Einfache Skalierung auf mehrere Hosts mit integrierter Steuerung für Nginx Load Balancer
-
-Wie unten beschrieben, erfolgt ein automatischer Neustart beim Systemwiederanlauf, wenn Sie StrongLoop Process Manager über Ihr Init-System als Betriebssystemservice installieren. Dadurch bleiben Ihre Anwendungsprozesse und Cluster dauerhaft betriebsbereit.
+Historically, it was popular to use a Node.js process manager like [PM2](https://github.com/Unitech/pm2). See their documentation if you wish to do this. However, we recommend using your init system for process management.
#### Init-System verwenden
-Als nächste Ebene der Zuverlässigkeit müssen Sie sicherstellen, dass Ihre Anwendung bei einem Serverneustart neu gestartet wird. Systeme können immer wieder aus verschiedenen Gründen abstürzen. Um sicherzustellen, dass Ihre Anwendung bei einem Serverabsturz neu gestartet wird, können Sie das in Ihr Betriebssystem integrierte Init-System verwenden. Die beiden wichtigsten Init-Systeme sind aktuell [systemd](https://wiki.debian.org/systemd) und [Upstart](http://upstart.ubuntu.com/).
+Als nächste Ebene der Zuverlässigkeit müssen Sie sicherstellen, dass Ihre Anwendung bei einem Serverneustart neu gestartet wird. Systeme können immer wieder aus verschiedenen Gründen abstürzen. Um sicherzustellen, dass Ihre Anwendung bei einem Serverabsturz neu gestartet wird, können Sie das in Ihr Betriebssystem integrierte Init-System verwenden. The main init system in use today is [systemd](https://wiki.debian.org/systemd).
Es gibt zwei Möglichkeiten, Init-Systeme mit Ihrer Express-Anwendung zu verwenden:
-* Ausführung Ihrer Anwendung in einem Prozessmanager und Installation des Prozessmanagers als Service mit dem Init-System. Der Prozessmanager wird neu gestartet, wenn Ihre Anwendung abstürzt. Das Init-System startet dann den Prozessmanager neu, sobald das Betriebssystem neu gestartet wird. Dies ist die empfohlene Vorgehensweise.
-* Ausführung Ihrer Anwendung (und von Node) direkt mit dem Init-System. Diese Vorgehensweise ist zwar etwas einfacher, Sie profitieren jedoch nicht von den zusätzlichen Vorteilen des Einsatzes eines Prozessmanagers.
+- Ausführung Ihrer Anwendung in einem Prozessmanager und Installation des Prozessmanagers als Service mit dem Init-System. Der Prozessmanager wird neu gestartet, wenn Ihre Anwendung abstürzt. Dies ist die empfohlene Vorgehensweise.
+- Ausführung Ihrer Anwendung (und von Node) direkt mit dem Init-System. Diese Vorgehensweise ist zwar etwas einfacher, Sie profitieren jedoch nicht von den zusätzlichen Vorteilen des Einsatzes eines Prozessmanagers.
##### systemd
"systemd" ist ein Linux-System und Service-Manager. Die meisten wichtigen Linux-Distributionen haben "systemd" als Init-Standardsystem übernommen.
-Eine "systemd"-Servicekonfigurationsdatei wird als *Einheitendatei* bezeichnet, die die Endung ".service" hat. Dies ist ein Beispiel für eine Einheitendatei zur direkten Verwaltung einer Node-Anwendung (ersetzen Sie den Text in Fettdruck durch Werte für Ihr System und Ihre Anwendung):
+Eine "systemd"-Servicekonfigurationsdatei wird als _Einheitendatei_ bezeichnet, die die Endung ".service" hat. Dies ist ein Beispiel für eine Einheitendatei zur direkten Verwaltung einer Node-Anwendung (ersetzen Sie den Text in Fettdruck durch Werte für Ihr System und Ihre Anwendung): Replace the values enclosed in `
-
+```sh
[Unit]
-Description=Awesome Express App
+Description=
[Service]
Type=simple
-ExecStart=/usr/local/bin/node /projects/myapp/index.js
-WorkingDirectory=/projects/myapp
+ExecStart=/usr/local/bin/node
+WorkingDirectory=
User=nobody
Group=nogroup
@@ -301,111 +243,15 @@ Restart=always
[Install]
WantedBy=multi-user.target
-
-
-Weitere Informationen zu "systemd" siehe [systemd-Referenz (Man-Page)](http://www.freedesktop.org/software/systemd/man/systemd.unit.html).
-##### StrongLoop Process Manager als "systemd"-Service
-
-Sie können StrongLoop Process Manager problemlos als "systemd"-Service installieren. Dadurch wird beim Serverneustart StrongLoop Process Manager automatisch neu gestartet. Dadurch wiederum werden alle Anwendungen neu gestartet, die von diesem Prozessmanager verwaltet werden.
-
-So installieren Sie StrongLoop Process Manager als "systemd"-Service:
-
-
-
-$ sudo sl-pm-install --systemd
-
-
-
-Starten Sie dann den Service mit:
-
-
-
-$ sudo /usr/bin/systemctl start strong-pm
-
-
-
-Weitere Informationen hierzu finden Sie im Thema [Produktionshost einrichten (in der StrongLoop-Dokumentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHEL7+,Ubuntu15.04or15.10).
-
-##### Upstart
-
-"Upstart" ist ein Systemtool, das auf vielen Linux-Distributionen verfügbar ist. Mit diesem Tool können Aufgaben (Tasks) und Services beim Systemstart gestartet, beim Herunterfahren gestoppt und auch überwacht werden. Sie können Ihre Express-Anwendung oder einen Prozessmanager als Service konfigurieren. "Upstart" startet diese dann bei einem Absturz automatisch neu.
-
-Ein "Upstart"-Service wird als Jobkonfigurationsdatei (auch als "Job" bezeichnet) definiert, deren Dateiname mit `.conf` endet. Das folgende Beispiel zeigt, wie ein Job namens "myapp" für eine Anwendung namens "myapp" erstellt wird, wobei sich die Hauptdatei im Verzeichnis `/projects/myapp/index.js` befindet.
-
-Erstellen Sie eine Datei namens `myapp.conf` unter `/etc/init/` mit dem folgenden Inhalt (ersetzen Sie den Text in Fettdruck durch Werte für Ihr System und Ihre Anwendung):
-
-
-
-# When to start the process
-start on runlevel [2345]
-
-# When to stop the process
-stop on runlevel [016]
-
-# Increase file descriptor limit to be able to handle more requests
-limit nofile 50000 50000
-
-# Use production mode
-env NODE_ENV=production
-
-# Run as www-data
-setuid www-data
-setgid www-data
-
-# Run from inside the app dir
-chdir /projects/myapp
-
-# The process to start
-exec /usr/local/bin/node /projects/myapp/index.js
-
-# Restart the process if it is down
-respawn
-
-# Limit restart attempt to 10 times within 10 seconds
-respawn limit 10 10
-
-
-
-Hinweis: Dieses Script erfordert Upstart 1.4 oder höher mit Unterstützung auf Ubuntu 12.04-14.10.
-
-Da der Job so konfiguriert ist, dass er beim Systemstart ausgeführt wird, wird Ihre Anwendung zusammen mit dem Betriebssystem gestartet und automatisch neu gestartet, wenn die Anwendung abstürzt oder das System heruntergefahren wird.
-
-Neben dem automatischen Neustart der Anwendung können Sie mit Upstart die folgenden Befehle verwenden:
-
-* `start myapp` – Anwendung starten
-* `restart myapp` – Anwendung neu starten
-* `stop myapp` – Anwendung stoppen
-
-Weitere Informationen zu "Upstart" siehe [Upstart Intro, Cookbook and Best Practises](http://upstart.ubuntu.com/cookbook).
-
-##### StrongLoop Process Manager als "Upstart"-Service
-
-Sie können StrongLoop Process Manager problemlos als "Upstart"-Service installieren. Dadurch wird beim Serverneustart StrongLoop Process Manager automatisch neu gestartet. Dadurch wiederum werden alle Anwendungen neu gestartet, die von diesem Prozessmanager verwaltet werden.
-
-So installieren Sie StrongLoop Process Manager als "Upstart 1.4"-Service:
-
-
-
-$ sudo sl-pm-install
-
-
-
-Fühen Sie dann den Service aus mit:
-
-
-
-$ sudo /sbin/initctl start strong-pm
-
-
+```
-Hinweis: Auf Systemen, die Upstart 1.4 nicht unterstützen, sind die Befehle leicht unterschiedlich. Weitere Informationen hierzu siehe das
-Thema [Einrichtung eines Produktionshosts (in der StrongLoop-Dokumentation)](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-RHELLinux5and6,Ubuntu10.04-.10,11.04-.10).
+Weitere Informationen zu "systemd" siehe [systemd-Referenz (Man-Page)](http://www.freedesktop.org/software/systemd/man/systemd.unit.html).
### Anwendung in einem Cluster ausführen
-In einem Multi-Core-System können Sie die Leistung einer Node-Anwendung mehrmals erhöhen, indem Sie einen Cluster von Prozessen starten. Ein Cluster führt mehrere Instanzen der Anwendung aus, idealerweise eine Instanz auf jedem CPU-Core. Dadurch werden die Arbeitslasten und die Tasks auf die Instanzen verteilt.
+In einem Multi-Core-System können Sie die Leistung einer Node-Anwendung mehrmals erhöhen, indem Sie einen Cluster von Prozessen starten. Ein Cluster führt mehrere Instanzen der Anwendung aus, idealerweise eine Instanz auf jedem CPU-Core.
-
+
Wichtig. Da die Anwendungsinstanzen als separate Prozesse ausgeführt werden, nutzen sie nicht dieselbe Hauptspeicherkapazität gemeinsam. Das heißt, Objekte befinden sich für jede Instanz der Anwendung auf lokaler Ebene. Daher kann der Status im Anwendungscode nicht beibehalten werden. Sie können jedoch einen speicherinternen Datenspeicher wie [Redis](http://redis.io/) verwenden, um sitzungsrelevante Daten und Statusinformationen zu speichern. Diese Einschränkung trifft im Wesentlichen auf alle Formen der horizontalen Skalierung zu, unabhängig davon, ob es sich um Clustering mit mehreren Prozessen oder mehreren physischen Servern handelt.
@@ -413,45 +259,52 @@ Bei in Gruppen zusammengefassten Anwendungen (geclusterte Anwendungen) können V
#### Clustermodule von Node verwenden
-Das Clustering erfolgt über das [Clustermodul](https://nodejs.org/docs/latest/api/cluster.html) von Node. Dadurch wird ein Masterprozess eingeleitet, um Verarbeitungsprozesse zu starten und eingehende Verbindungen auf die Verarbeitungsprozesse zu verteilen. Anstatt dieses Modul jedoch direkt zu verwenden, ist es deutlich besser, eines der vielen angebotenen Tools einzusetzen, das diesen Vorgang automatisch für Sie ausführt, wie beispielsweise [node-pm](https://www.npmjs.com/package/node-pm) oder [cluster-service](https://www.npmjs.com/package/cluster-service).
+Clustering is made possible with Node's [cluster module](https://nodejs.org/api/cluster.html). Dadurch wird ein Masterprozess eingeleitet, um Verarbeitungsprozesse zu starten und eingehende Verbindungen auf die Verarbeitungsprozesse zu verteilen.
-#### StrongLoop Process Manager verwenden
+#### Using PM2
-Wenn Sie Ihre Anwendung auf StrongLoop Process Manager (PM) bereitstellen, können Sie die Vorteile des Clustering nutzen, *ohne* Ihren Anwendungscode ändern zu müssen.
+If you deploy your application with PM2, then you can take advantage of clustering _without_ modifying your application code. You should ensure your [application is stateless](https://pm2.keymetrics.io/docs/usage/specifics/#stateless-apps) first, meaning no local data is stored in the process (such as sessions, websocket connections and the like).
-Wenn StrongLoop Process Manager (PM) eine Anwendung ausführt, wird diese automatisch in einem Cluster ausgeführt. Die Anzahl der Verarbeitungsprozesse entspricht dabei der Anzahl der CPU-Cores im System. Sie können die Anzahl der Verarbeitungsprozesse manuell im Cluster ändern. Hierfür verwenden Sie das Befehlszeilentool "slc", ohne die Anwendung stoppen zu müssen.
+When running an application with PM2, you can enable **cluster mode** to run it in a cluster with a number of instances of your choosing, such as the matching the number of available CPUs on the machine. You can manually change the number of processes in the cluster using the `pm2` command line tool without stopping the app.
-Beispiel: Angenommen, Sie haben Ihre Anwendung auf prod.foo.com bereitgestellt, und StrongLoop PM ist auf Port 8701 (Standardport) empfangsbereit. Dann müssen Sie die Clustergröße mithilfe von "slc" auf "8" einstellen.
+To enable cluster mode, start your application like so:
-
-
-$ slc ctl -C http://prod.foo.com:8701 set-size my-app 8
-
-
+```bash
+# Start 4 worker processes
+$ pm2 start npm --name my-app -i 4 -- start
+# Auto-detect number of available CPUs and start that many worker processes
+$ pm2 start npm --name my-app -i max -- start
+```
-Weitere Informationen zum Clustering mit StrongLoop PM finden Sie im Thema [Clustering](https://docs.strongloop.com/display/SLC/Clustering) in der StrongLoop-Dokumentation.
+This can also be configured within a PM2 process file (`ecosystem.config.js` or similar) by setting `exec_mode` to `cluster` and `instances` to the number of workers to start.
+
+Once running, the application can be scaled like so:
+
+```bash
+# Add 3 more workers
+$ pm2 scale my-app +3
+# Scale to a specific number of workers
+$ pm2 scale my-app 2
+```
+
+For more information on clustering with PM2, see [Cluster Mode](https://pm2.keymetrics.io/docs/usage/cluster-mode/) in the PM2 documentation.
### Anforderungsergebnisse im Cache speichern
Eine weitere Strategie zur Verbesserung des Leistungsverhaltens in Produktionsumgebungen ist das Speichern von Anforderungergebnissen im Cache. Ihre Anwendung muss also diese Operation nicht wiederholt ausführen, um dieselbe Anforderung wiederholt zu bedienen.
-Mithilfe eines Caching-Servers wie [Varnish](https://www.varnish-cache.org/) oder [Nginx](https://www.nginx.com/resources/wiki/start/topics/examples/reverseproxycachingexample/) (siehe auch [Nginx Caching](https://serversforhackers.com/nginx-caching/)) lassen sich Geschwindigkeit und Leistung Ihrer Anwendung hervorragend verbessern.
+Use a caching server like [Varnish](https://www.varnish-cache.org/) or [Nginx](https://blog.nginx.org/blog/nginx-caching-guide) (see also [Nginx Caching](https://serversforhackers.com/nginx-caching/)) to greatly improve the speed and performance of your app.
### Load Balancer verwenden
-Unabhängig davon, wie gut eine Anwendung optimiert wurde, kann eine Einzelinstanz nur eine begrenzte Arbeitslast oder einen begrenzten Datenverkehr handhaben. Eine Möglichkeit, eine Anwendung zu skalieren, ist die Ausführung mehrerer Instanzen dieser Anwendung und die Verteilung des Datenverkehrs über eine Lastausgleichsfunktion (Load Balancer) vorzunehmen. Die Einrichtung eines solchen Load Balancer kann helfen, Leistung und Geschwindigkeit Ihrer Anwendung zu verbessern. Zudem lässt sich dadurch die Anwendung besser skalieren als mit einer Einzelinstanz.
-
-Ein Load Balancer ist in der Regel ein Reverse Proxy, der den Datenverkehr zu und von mehreren Anwendungsinstanzen und Servern koordiniert. Sie können ohne großen Aufwand einen Load Balancer für Ihre Anwendung einrichten. Verwenden Sie hierzu [Nginx](http://nginx.org/en/docs/http/load_balancing.html) oder [HAProxy](https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts).
-
-Bei einer solchen Lastverteilung müssen Sie sicherstellen, dass Anforderungen, die einer bestimmten Sitzungs-ID zugeordnet sind, mit dem Prozess verbunden sind, von dem sie ursprünglich stammen. Dies wird auch als *Sitzungsaffinität* oder *Affine Sitzungen* bezeichnet und kann durch den obigen Vorschlag, einen Datenspeicher wie Redis für Sitzungsdaten zu verwenden (je nach Anwendung), umgesetzt werden. Eine Beschreibung hierzu siehe [Mehrere Knoten verwenden](http://socket.io/docs/using-multiple-nodes/).
+Unabhängig davon, wie gut eine Anwendung optimiert wurde, kann eine Einzelinstanz nur eine begrenzte Arbeitslast oder einen begrenzten Datenverkehr handhaben. Eine Möglichkeit, eine Anwendung zu skalieren, ist die Ausführung mehrerer Instanzen dieser Anwendung und die Verteilung des Datenverkehrs über eine Lastausgleichsfunktion (Load Balancer) vorzunehmen. Die Einrichtung eines solchen Load Balancer kann helfen, Leistung und Geschwindigkeit Ihrer Anwendung zu verbessern.
-#### StrongLoop Process Manager mit einem Nginx Load Balancer verwenden
+Ein Load Balancer ist in der Regel ein Reverse Proxy, der den Datenverkehr zu und von mehreren Anwendungsinstanzen und Servern koordiniert. You can easily set up a load balancer for your app by using [Nginx](https://nginx.org/en/docs/http/load_balancing.html) or [HAProxy](https://www.digitalocean.com/community/tutorials/an-introduction-to-haproxy-and-load-balancing-concepts).
-[StrongLoop Process Manager](http://strong-pm.io/) lässt sich in einen Nginx-Controller integrieren und erleichtert dadurch das Konfigurieren von Produktionsumgebungen mit mehreren Hosts. Weitere Informationen finden Sie im Thema zum [Skalieren auf mehrere Server](https://docs.strongloop.com/display/SLC/Scaling+to+multiple+servers) (in der StrongLoop-Dokumentation).
-
+Bei einer solchen Lastverteilung müssen Sie sicherstellen, dass Anforderungen, die einer bestimmten Sitzungs-ID zugeordnet sind, mit dem Prozess verbunden sind, von dem sie ursprünglich stammen. Dies wird auch als _Sitzungsaffinität_ oder _Affine Sitzungen_ bezeichnet und kann durch den obigen Vorschlag, einen Datenspeicher wie Redis für Sitzungsdaten zu verwenden (je nach Anwendung), umgesetzt werden. Eine Beschreibung hierzu siehe [Mehrere Knoten verwenden](https://socket.io/docs/v4/using-multiple-nodes/).
### Reverse Proxy verwenden
-Ein Reverse Proxy befindet sich vor einer Webanwendung und führt Unterstützungsoperationen für die Anforderungen aus (außer das Weiterleiten von Anforderungen an die Anwendung). Er kann u. a. Fehlerseiten, Komprimierungen und Caching bearbeiten, Dateien bereitstellen und Lastverteilungen vornehmen.
+Ein Reverse Proxy befindet sich vor einer Webanwendung und führt Unterstützungsoperationen für die Anforderungen aus (außer das Weiterleiten von Anforderungen an die Anwendung). Fehlerseiten, Komprimierungen und Caching bearbeiten, Dateien bereitstellen und Lastverteilungen vornehmen.
-Durch die Übergabe von Tasks, die keine Kenntnis des Anwendungsstatus erfordern, an einen Reverse Proxy muss Express keine speziellen Anwendungstasks mehr ausführen. Aus diesem Grund wird empfohlen, in Produktionsumgebungen Express hinter einem Reverse Proxy wie [Nginx](https://www.nginx.com/) oder [HAProxy](http://www.haproxy.org/) auszuführen.
+Durch die Übergabe von Tasks, die keine Kenntnis des Anwendungsstatus erfordern, an einen Reverse Proxy muss Express keine speziellen Anwendungstasks mehr ausführen. For this reason, it is recommended to run Express behind a reverse proxy like [Nginx](https://www.nginx.org/) or [HAProxy](https://www.haproxy.org/) in production.
diff --git a/de/advanced/best-practice-security.md b/de/advanced/best-practice-security.md
old mode 100755
new mode 100644
index 7d6fd4cba5..8f4f23219d
--- a/de/advanced/best-practice-security.md
+++ b/de/advanced/best-practice-security.md
@@ -1,20 +1,46 @@
---
layout: page
title: Sicherheitsspezifische Best Practices für Express-Anwendungen in Produktionsumgebungen
+description: Discover crucial security best practices for Express apps in production, including using TLS, input validation, secure cookies, and preventing vulnerabilities.
menu: advanced
-lang: de
+redirect_from: " "
---
# Best Practices in Produktionsumgebungen: Sicherheit
## Überblick
-Der Begriff *"Produktion"* bezieht sich auf die Phase im Softwarelebenszyklus, in der eine Anwendung oder API für Endbenutzer oder Verbraucher allgemein verfügbar ist. Im Gegensatz dazu wird in der Phase *"Entwicklung"* noch aktiv Code geschrieben und getestet. Die Anwendung ist in dieser Phase noch nicht für externen Zugriff verfügbar. Die entsprechenden Systemumgebungen werden als *Produktionsumgebungen* und *Entwicklungsumgebungen* bezeichnet.
+Der Begriff _"Produktion"_ bezieht sich auf die Phase im Softwarelebenszyklus, in der eine Anwendung oder API für Endbenutzer oder Verbraucher allgemein verfügbar ist. Im Gegensatz dazu wird in der Phase _"Entwicklung"_ noch aktiv Code geschrieben und getestet. Die Anwendung ist in dieser Phase noch nicht für externen Zugriff verfügbar. Die entsprechenden Systemumgebungen werden als _Produktionsumgebungen_ und _Entwicklungsumgebungen_ bezeichnet.
Entwicklungs- und Produktionsumgebungen werden in der Regel unterschiedlich konfiguriert und weisen deutliche Unterschiede bei den Anforderungen auf. Was in der Entwicklung funktioniert, muss in der Produktion nicht unbedingt akzeptabel sein. Beispiel: In einer Entwicklungsumgebung ist eine ausführliche Protokollierung von Fehlern für Debuggingzwecke sinnvoll. Dieselbe Vorgehensweise kann in einer Produktionsumgebung jedoch zu einem Sicherheitsproblem führen. In einer Entwicklungsumgebung müssen Sie sich keine Gedanken zu Themen wie Skalierbarkeit, Zuverlässigkeit und Leistung machen, während dies in einer Produktionsumgebung kritische Faktoren sind.
+{% capture security-note %}
+
+If you believe you have discovered a security vulnerability in Express, please see
+[Security Policies and Procedures](/en/resources/contributing.html#security-policies-and-procedures).
+
+{% endcapture %}
+
+{% include admonitions/note.html content=security-note %}
+
In diesem Beitrag werden einige der Best Practices in Bezug auf das Thema Sicherheit für Express-Anwendungen behandelt, die in der Produktionsumgebung bereitgestellt werden.
+- [Production Best Practices: Security](#production-best-practices-security)
+ - [Overview](#overview)
+ - [Don't use deprecated or vulnerable versions of Express](#dont-use-deprecated-or-vulnerable-versions-of-express)
+ - Über [hsts](https://github.com/helmetjs/hsts) werden `Strict-Transport-Security`-Header festgelegt, über die sichere (HTTP over SSL/TLS) Verbindungen zum Server durchgesetzt werden.
+ - [Do not trust user input](#do-not-trust-user-input)
+ - [Prevent open redirects](#prevent-open-redirects)
+ - "Helmet" ist eine Ansammlung von neun kleineren Middlewarefunktionen, über die sicherheitsrelevante HTTP-Header festgelegt werden.
+ - [Reduce fingerprinting](#reduce-fingerprinting)
+ - Über [xssFilter](https://github.com/helmetjs/x-xss-protection) werden `X-XSS-Protection`-Header festgelegt, um XSS-Filter (Cross-site Scripting) in den meisten aktuellen Web-Browsern zu aktivieren.
+ - Über [noCache](https://github.com/helmetjs/nocache) werden `Cache-Control`- und Pragma-Header festgelegt, um clientseitiges Caching zu deaktivieren.
+ - Über [ieNoOpen](https://github.com/helmetjs/ienoopen) werden `X-Download-Options`-Header für IE8+ festgelegt.
+ - [Prevent brute-force attacks against authorization](#prevent-brute-force-attacks-against-authorization)
+ - [Ensure your dependencies are secure](#ensure-your-dependencies-are-secure)
+ - [Avoid other known vulnerabilities](#avoid-other-known-vulnerabilities)
+ - [Additional considerations](#additional-considerations)
+
## Verwenden Sie keine veralteten oder anfälligen Versionen von Express
Express 2.x und 3.x werden nicht mehr gepflegt. Sicherheits- und Leistungsprobleme in diesen Versionen werden nicht mehr behoben. Verwenden Sie diese Versionen nicht! Wenn Sie noch nicht auf Version 4 umgestellt haben, befolgen Sie die Anweisungen im [Migrationshandbuch](/{{ page.lang }}/guide/migrating-4.html).
@@ -25,57 +51,121 @@ Stellen Sie außerdem sicher, dass Sie keine anfälligen Express-Versionen verwe
Wenn über Ihre Anwendung vertrauliche Daten bearbeitet oder übertragen werden, sollten Sie [Transport Layer Security](https://en.wikipedia.org/wiki/Transport_Layer_Security) (TLS) verwenden, um die Verbindung und die Daten zu schützen. Diese Technologie verschlüsselt Daten, bevor sie vom Client zum Server gesendet werden. Dadurch lassen sich einige gängige (und einfache) Hackerattacken vermeiden. Auch wenn Ajax- und POST-Anforderungen nicht sofort offensichtlich und in Browsern "versteckt" zu sein scheinen, ist deren Netzverkehr anfällig für das [Ausspionieren von Paketen](https://en.wikipedia.org/wiki/Packet_analyzer) und [Man-in-the-Middle-Attacken](https://en.wikipedia.org/wiki/Man-in-the-middle_attack).
-Möglicherweise sind Sie mit SSL-Verschlüsselung (Secure Socket Layer) bereits vertraut. [TLS ist einfach der nächste Entwicklungsschritt bei SSL](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380515(v=vs.85).aspx). In anderen Worten: Wenn Sie bisher SSL verwendet haben, sollten Sie ein Upgrade auf TLS in Erwägung ziehen. Generell empfehlen wir für TLS den Nginx-Server. Eine gute Referenz zum Konfigurieren von TLS auf Nginx (und anderen Servern) ist [Empfohlene Serverkonfigurationen (Mozilla Wiki)](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_Server_Configurations).
+Möglicherweise sind Sie mit SSL-Verschlüsselung (Secure Socket Layer) bereits vertraut. [TLS ist einfach der nächste Entwicklungsschritt bei SSL](https://msdn.microsoft.com/en-us/library/windows/desktop/aa380515\(v=vs.85\).aspx). In anderen Worten: Wenn Sie bisher SSL verwendet haben, sollten Sie ein Upgrade auf TLS in Erwägung ziehen. Generell empfehlen wir für TLS den Nginx-Server. Eine gute Referenz zum Konfigurieren von TLS auf Nginx (und anderen Servern) ist [Empfohlene Serverkonfigurationen (Mozilla Wiki)](https://wiki.mozilla.org/Security/Server_Side_TLS#Recommended_Server_Configurations).
Ein handliches Tool zum Abrufen eines kostenloses TLS-Zertifikats ist außerdem [Let's Encrypt](https://letsencrypt.org/about/), eine kostenlose, automatisierte und offene Zertifizierungsstelle der [Internet Security Research Group (ISRG)](https://letsencrypt.org/isrg/).
+## Do not trust user input
+
+For web applications, one of the most critical security requirements is proper user input validation and handling. This comes in many forms and we will not cover all of them here.
+Ultimately, the responsibility for validating and correctly handling the types of user input your application accepts is yours.
+
+### Prevent open redirects
+
+An example of potentially dangerous user input is an _open redirect_, where an application accepts a URL as user input (often in the URL query, for example `?url=https://example.com`) and uses `res.redirect` to set the `location` header and
+return a 3xx status.
+
+An application must validate that it supports redirecting to the incoming URL to avoid sending users to malicious links such as phishing websites, among other risks.
+
+Here is an example of checking URLs before using `res.redirect` or `res.location`:
+
+```js
+app.use((req, res) => {
+ try {
+ if (new Url(req.query.url).host !== 'example.com') {
+ return res.status(400).end(`Unsupported redirect to host: ${req.query.url}`)
+ }
+ } catch (e) {
+ return res.status(400).end(`Invalid url: ${req.query.url}`)
+ }
+ res.redirect(req.query.url)
+})
+```
+
## "Helmet" verwenden
[Helmet](https://www.npmjs.com/package/helmet) kann beim Schutz Ihrer Anwendung gegen einige gängige Schwachstellen hilfreiche Dienste leisten, indem die HTTP-Header entsprechend konfiguriert werden.
-"Helmet" ist eine Ansammlung von neun kleineren Middlewarefunktionen, über die sicherheitsrelevante HTTP-Header festgelegt werden.
+Helmet is a middleware function that sets security-related HTTP response headers. Helmet sets the following headers by default:
+
+- `Content-Security-Policy`: A powerful allow-list of what can happen on your page which mitigates many attacks
+- `Cross-Origin-Opener-Policy`: Helps process-isolate your page
+- `Cross-Origin-Resource-Policy`: Blocks others from loading your resources cross-origin
+- `Origin-Agent-Cluster`: Changes process isolation to be origin-based
+- `Referrer-Policy`: Controls the [`Referer`](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Referer) header
+- `Strict-Transport-Security`: Tells browsers to prefer HTTPS
+- `X-Content-Type-Options`: Avoids [MIME sniffing](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types#mime_sniffing)
+- `X-DNS-Prefetch-Control`: Controls DNS prefetching
+- `X-Download-Options`: Forces downloads to be saved (Internet Explorer only)
+- `X-Frame-Options`: Legacy header that mitigates [Clickjacking](https://en.wikipedia.org/wiki/Clickjacking) attacks
+- `X-Permitted-Cross-Domain-Policies`: Controls cross-domain behavior for Adobe products, like Acrobat
+- `X-Powered-By`: Info about the web server. Removed because it could be used in simple attacks
+- `X-XSS-Protection`: Legacy header that tries to mitigate [XSS attacks](https://developer.mozilla.org/en-US/docs/Glossary/Cross-site_scripting), but makes things worse, so Helmet disables it
-* Über [csp](https://github.com/helmetjs/csp) wird der `Content-Security-Policy`-Header festgelegt, um Cross-Site Scripting-Attacken und anderen standortübergreifenden Injektionen vorzubeugen.
-* Über [hidePoweredBy](https://github.com/helmetjs/hide-powered-by) wird der `X-Powered-By`-Header entfernt.
-* Über [hsts](https://github.com/helmetjs/hsts) werden `Strict-Transport-Security`-Header festgelegt, über die sichere (HTTP over SSL/TLS) Verbindungen zum Server durchgesetzt werden.
-* Über [ieNoOpen](https://github.com/helmetjs/ienoopen) werden `X-Download-Options`-Header für IE8+ festgelegt.
-* Über [noCache](https://github.com/helmetjs/nocache) werden `Cache-Control`- und Pragma-Header festgelegt, um clientseitiges Caching zu deaktivieren.
-* Über [noSniff](https://github.com/helmetjs/dont-sniff-mimetype) werden `X-Content-Type-Options`-Header festgelegt, um bei Browsern MIME-Sniffing von Antworten weg vom deklarierten Inhaltstyp (declared content-type) vorzubeugen.
-* Über [frameguard](https://github.com/helmetjs/frameguard) wird der `X-Frame-Options`-Header festgelegt, um [Clickjacking](https://www.owasp.org/index.php/Clickjacking)-Schutz zu gewährleisten.
-* Über [xssFilter](https://github.com/helmetjs/x-xss-protection) werden `X-XSS-Protection`-Header festgelegt, um XSS-Filter (Cross-site Scripting) in den meisten aktuellen Web-Browsern zu aktivieren.
+Each header can be configured or disabled. To read more about it please go to [its documentation website][helmet].
Installieren Sie "Helmet" wie alle anderen Module:
-
-
-$ npm install --save helmet
-
-
+```bash
+$ npm install helmet
+```
So verwenden Sie "Helmet" in Ihrem Code:
-
-
-...
-var helmet = require('helmet');
-app.use(helmet());
-...
-
-
+```js
+// ...
+
+const helmet = require('helmet')
+app.use(helmet())
+
+// ...
+```
-### Deaktivieren Sie mindestens den X-Powered-By-Header
+## Reduce fingerprinting
-Wenn Sie "Helmet" nicht verwenden wollen, sollten Sie mindestens den `X-Powered-By`-Header deaktivieren. Angreifer können diesen Header (der standardmäßig aktiviert ist) zum Erkennen von Anwendungen mit Express verwenden und dann gezielte Attacken in die Wege leiten.
+It can help to provide an extra layer of security to reduce the ability of attackers to determine
+the software that a server uses, known as "fingerprinting." Though not a security issue itself,
+reducing the ability to fingerprint an application improves its overall security posture.
+Server software can be fingerprinted by quirks in how it responds to specific requests, for example in
+the HTTP response headers.
Ein bewährtes Verfahren ist also, diesen Header mit der Methode `app.disable()` zu deaktivieren:
-
-
-app.disable('x-powered-by');
-
-
+```js
+app.disable('x-powered-by')
+```
+
+{% capture powered-advisory %}
+
+Disabling the `X-Powered-By header` does not prevent
+a sophisticated attacker from determining that an app is running Express. It may
+discourage a casual exploit, but there are other ways to determine an app is running
+Express.
+
+{% endcapture %}
+
+{% include admonitions/note.html content=powered-advisory %}
+
+Express also sends its own formatted "404 Not Found" messages and formatter error
+response messages. These can be changed by
+[adding your own not found handler](/en/starter/faq.html#how-do-i-handle-404-responses)
+and
+[writing your own error handler](/en/guide/error-handling.html#writing-error-handlers):
-Wenn Sie `helmet.js` verwenden, kümmert sich das Tool darum.
+```js
+// last app.use calls right before app.listen():
+
+// custom 404
+app.use((req, res, next) => {
+ res.status(404).send("Sorry can't find that!")
+})
+
+// custom error handler
+app.use((err, req, res, next) => {
+ console.error(err.stack)
+ res.status(500).send('Something broke!')
+})
+```
## Cookies sicher verwenden
@@ -83,8 +173,8 @@ Um sicherzustellen, dass Cookies Ihre Anwendung nicht für Angriffsmöglichkeite
Es gibt zwei wesentliche Middleware-Cookie-Sitzungsmodule:
-* [express-session](https://www.npmjs.com/package/express-session), das in Express 3.x integrierte `express.session`-Middleware ersetzt.
-* [cookie-session](https://www.npmjs.com/package/cookie-session), das in Express 3.x integrierte `express.cookieSession`-Middleware ersetzt.
+- [express-session](https://www.npmjs.com/package/express-session), das in Express 3.x integrierte `express.session`-Middleware ersetzt.
+- [cookie-session](https://www.npmjs.com/package/cookie-session), das in Express 3.x integrierte `express.cookieSession`-Middleware ersetzt.
Der Hauptunterschied zwischen diesen beiden Modulen liegt darin, wie die Cookie-Sitzungsdaten gespeichert werden. Die [express-session](https://www.npmjs.com/package/express-session)-Middleware speichert Sitzungsdaten auf dem Server. Sie speichert nur die Sitzungs-ID im Cookie und nicht die Sitzungsdaten. Standardmäßig wird dabei der speicherinterne Speicher verwendet. Eine Verwendung der Middleware in der Produktionsumgebung ist nicht vorgesehen. In der Produktionsumgebung müssen Sie einen skalierbaren "Session-Store" einrichten. Siehe hierzu die Liste der [kompatiblen Session-Stores](https://github.com/expressjs/session#compatible-session-stores).
@@ -94,67 +184,98 @@ Im Gegensatz dazu implementiert die [cookie-session](https://www.npmjs.com/packa
Die Verwendung des standardmäßigen Namens des Sitzungscookies kann Ihre Anwendung anfällig für Attacken machen. Das mögliche Sicherheitsproblem ist vergleichbar mit `X-Powered-By`: ein potenzieller Angreifer kann diesen Header verwenden, um einen elektronischen Fingerabdruck des Servers zu erstellen und Attacken entsprechend zu platzieren.
-Dieses Problem lässt sich vermeiden, wenn Sie allgemeine Cookienamen verwenden; z. B. durch Verwendung der [express-session](https://www.npmjs.com/package/express-session)-Middleware:
+Über [noSniff](https://github.com/helmetjs/dont-sniff-mimetype) werden `X-Content-Type-Options`-Header festgelegt, um bei Browsern MIME-Sniffing von Antworten weg vom deklarierten Inhaltstyp (declared content-type) vorzubeugen.
-
-
-var session = require('express-session');
+```js
+const session = require('express-session')
app.set('trust proxy', 1) // trust first proxy
-app.use( session({
- secret : 's3Cur3',
- name : 'sessionId',
- })
-);
-
-
+app.use(session({
+ secret: 's3Cur3',
+ name: 'sessionId'
+}))
+```
### Cookie-Sicherheitsoptionen festlegen
Legen Sie die folgenden Cookieoptionen fest, um die Sicherheit zu erhöhen:
-* `secure` - Stellt sicher, dass der Browser das Cookie nur über HTTPS sendet.
-* `httpOnly` - Stellt sicher, dass das Cookie nur über HTTP(S) und nicht über das Client-JavaScript gesendet wird und dadurch Schutz gegen Cross-Site Scripting-Attacken besteht.
-* `domain` - Gibt die Domäne des Cookies an, die für den Vergleich mit der Domäne des Servers verwendet wird, in der die URL angefordert wird. Stimmen diese beiden überein, müssen Sie das Pfadattribut überprüfen.
-* `path` - Gibt den Pfad des Cookies an, der für den Vergleich mit dem Anforderungspfad verwendet wird. Wenn dieser Pfad und die Domäne übereinstimmen, können Sie das Cookie in der Anforderung senden.
-* `expires` - Wird verwendet, um das Ablaufdatum für persistente Cookies festzulegen.
+- `secure` - Stellt sicher, dass der Browser das Cookie nur über HTTPS sendet.
+- `httpOnly` - Stellt sicher, dass das Cookie nur über HTTP(S) und nicht über das Client-JavaScript gesendet wird und dadurch Schutz gegen Cross-Site Scripting-Attacken besteht.
+- `domain` - Gibt die Domäne des Cookies an, die für den Vergleich mit der Domäne des Servers verwendet wird, in der die URL angefordert wird. Stimmen diese beiden überein, müssen Sie das Pfadattribut überprüfen.
+- `path` - Gibt den Pfad des Cookies an, der für den Vergleich mit dem Anforderungspfad verwendet wird. Wenn dieser Pfad und die Domäne übereinstimmen, können Sie das Cookie in der Anforderung senden.
+- `expires` - Wird verwendet, um das Ablaufdatum für persistente Cookies festzulegen.
Dies ist ein Beispiel zur Verwendung der [cookie-session](https://www.npmjs.com/package/cookie-session)-Middleware:
-
-
-var session = require('cookie-session');
-var express = require('express');
-var app = express();
+```js
+const session = require('cookie-session')
+const express = require('express')
+const app = express()
-var expiryDate = new Date( Date.now() + 60 * 60 * 1000 ); // 1 hour
+const expiryDate = new Date(Date.now() + 60 * 60 * 1000) // 1 hour
app.use(session({
name: 'session',
keys: ['key1', 'key2'],
- cookie: { secure: true,
- httpOnly: true,
- domain: 'example.com',
- path: 'foo/bar',
- expires: expiryDate
- }
- })
-);
-
-
+ cookie: {
+ secure: true,
+ httpOnly: true,
+ domain: 'example.com',
+ path: 'foo/bar',
+ expires: expiryDate
+ }
+}))
+```
-## Weitere Überlegungen
+## Prevent brute-force attacks against authorization
+
+Make sure login endpoints are protected to make private data more secure.
+
+A simple and powerful technique is to block authorization attempts using two metrics:
+
+1. The number of consecutive failed attempts by the same user name and IP address.
+2. The number of failed attempts from an IP address over some long period of time. For example, block an IP address if it makes 100 failed attempts in one day.
+
+[rate-limiter-flexible](https://github.com/animir/node-rate-limiter-flexible) package provides tools to make this technique easy and fast. You can find [an example of brute-force protection in the documentation](https://github.com/animir/node-rate-limiter-flexible/wiki/Overall-example#login-endpoint-protection)
+
+## Ensure your dependencies are secure
+
+Using npm to manage your application's dependencies is powerful and convenient. But the packages that you use may contain critical security vulnerabilities that could also affect your application. The security of your app is only as strong as the "weakest link" in your dependencies.
-Dies sind einige weitere Empfehlungen aus der hervorragenden [Node.js Security Checklist](https://blog.risingstack.com/node-js-security-checklist/). In diesem Blogbeitrag finden Sie alle Details zu diesen Empfehlungen:
+Since npm@6, npm automatically reviews every install request. Also, you can use `npm audit` to analyze your dependency tree.
-* Implementieren Sie Rate-Limiting, um Brute-Force-Attacken gegen Authentifizierungen zu verhindern. Hierfür können Sie beispielsweise das [StrongLoop API Gateway](https://strongloop.com/node-js/api-gateway/) verwenden, um eine Rate-Limiting-Richtlinie durchzusetzen. Alternativ können Sie eine Middleware wie [express-limiter](https://www.npmjs.com/package/express-limiter) verwenden. Hierzu müssen Sie jedoch Ihren Code etwas modifizieren.
-* Verwenden Sie die [csurf](https://www.npmjs.com/package/csurf)-Middleware, um CSRF-Attacken (Cross-Site Request Forgery) vorzubeugen.
-* Filtern und bereinigen Sie immer Benutzereingaben, um sich gegen XS-Angriffe (Cross-Site Scripting) und Befehlsinjektionsattacken zu schützen.
-* Implementieren Sie Verteidungsmaßnahmen gegen SQL-Injection-Attacken, indem sie parametrisierte Abfragen oder vorbereitete Anweisungen einsetzen.
-* Nutzen Sie das Open-Source-Tool [sqlmap](http://sqlmap.org/), um SQL-Injection-Schwachstellen in Ihrer Anwendung zu erkennen.
-* Verwenden Sie die Tools [nmap](https://nmap.org/) und [sslyze](https://github.com/nabla-c0d3/sslyze), um die Konfiguration Ihrer SSL-Verschlüsselungen, -Schlüssel und Neuvereinbarungen sowie die Gültigkeit Ihres Zertifikats zu testen.
-* Verwenden Sie [safe-regex](https://www.npmjs.com/package/safe-regex), um sicherzustellen, dass Ihre regulären Ausdrücke nicht für [Denial-of-Service-Attacken](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS) anfällig sind.
+```bash
+$ npm audit
+```
-## Vermeiden Sie andere Schwachstellen
+If you want to stay more secure, consider [Snyk](https://snyk.io/).
+
+Snyk offers both a [command-line tool](https://www.npmjs.com/package/snyk) and a [Github integration](https://snyk.io/docs/github) that checks your application against [Snyk's open source vulnerability database](https://snyk.io/vuln/) for any known vulnerabilities in your dependencies. Install the CLI as follows:
+
+```bash
+$ npm install -g snyk
+$ cd your-app
+```
+
+Use this command to test your application for vulnerabilities:
+
+```bash
+$ snyk test
+```
+
+### Vermeiden Sie andere Schwachstellen
Achten Sie auf [Node Security Project](https://npmjs.com/advisories)-Empfehlungen, die Express oder andere Module, die Ihre Anwendung nutzt, beeinträchtigen können. Im Allgemeinen ist Node Security Project aber eine exzellente Ressource mit Wissen und Tools zur Sicherheit von Node.
-Letztendlich können Express-Anwendungen – wie viele andere Webanwendungen auch – anfällig für eine Vielzahl webbasierter Attacken sein. Machen Sie sich deshalb mit bekannten [webspezifischen Schwachstellen](https://www.owasp.org/index.php/Top_10_2013-Top_10) vertraut und treffen Sie die geeigneten Vorkehrungen, um diese zu vermeiden.
+Letztendlich können Express-Anwendungen – wie viele andere Webanwendungen auch – anfällig für eine Vielzahl webbasierter Attacken sein. Machen Sie sich deshalb mit bekannten [webspezifischen Schwachstellen](https://www.owasp.org/www-project-top-ten/) vertraut und treffen Sie die geeigneten Vorkehrungen, um diese zu vermeiden.
+
+## Weitere Überlegungen
+
+Dies sind einige weitere Empfehlungen aus der hervorragenden [Node.js Security Checklist](https://blog.risingstack.com/node-js-security-checklist/). In diesem Blogbeitrag finden Sie alle Details zu diesen Empfehlungen:
+
+- Filtern und bereinigen Sie immer Benutzereingaben, um sich gegen XS-Angriffe (Cross-Site Scripting) und Befehlsinjektionsattacken zu schützen.
+- Implementieren Sie Verteidungsmaßnahmen gegen SQL-Injection-Attacken, indem sie parametrisierte Abfragen oder vorbereitete Anweisungen einsetzen.
+- Nutzen Sie das Open-Source-Tool [sqlmap](http://sqlmap.org/), um SQL-Injection-Schwachstellen in Ihrer Anwendung zu erkennen.
+- Verwenden Sie die Tools [nmap](https://nmap.org/) und [sslyze](https://github.com/nabla-c0d3/sslyze), um die Konfiguration Ihrer SSL-Verschlüsselungen, -Schlüssel und Neuvereinbarungen sowie die Gültigkeit Ihres Zertifikats zu testen.
+- Verwenden Sie [safe-regex](https://www.npmjs.com/package/safe-regex), um sicherzustellen, dass Ihre regulären Ausdrücke nicht für [Denial-of-Service-Attacken](https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS) anfällig sind.
+
+[helmet]:
-
-var fs = require('fs'); // this engine requires the fs module
-app.engine('ntl', function (filePath, options, callback) { // define the template engine
- fs.readFile(filePath, function (err, content) {
- if (err) return callback(new Error(err));
+```js
+const fs = require('fs') // this engine requires the fs module
+app.engine('ntl', (filePath, options, callback) => { // define the template engine
+ fs.readFile(filePath, (err, content) => {
+ if (err) return callback(err)
// this is an extremely simple template engine
- var rendered = content.toString().replace('#title#', ''+ options.title +' ')
- .replace('#message#', ''+ options.message +'
');
- return callback(null, rendered);
- });
-});
-app.set('views', './views'); // specify the views directory
-app.set('view engine', 'ntl'); // register the template engine
-
-
+ const rendered = content.toString()
+ .replace('#title#', `
-
+```pug
#title#
#message#
-
-
+```
+
Erstellen Sie dann in Ihrer Anwendung die folgende Route.
-
-
-app.get('/', function (req, res) {
- res.render('index', { title: 'Hey', message: 'Hello there!'});
-});
-
-
-Wenn Sie eine Anforderung zur Homepage einleiten, wird `index.ntl` im HTML-Format ausgegeben.
+
+```js
+app.get('/', (req, res) => {
+ res.render('index', { title: 'Hey', message: 'Hello there!' })
+})
+```
+
+Wenn Sie eine Anforderung zur Homepage einleiten, wird `index.ntl` im HTML-Format ausgegeben.
\ No newline at end of file
diff --git a/de/advanced/healthcheck-graceful-shutdown.md b/de/advanced/healthcheck-graceful-shutdown.md
new file mode 100644
index 0000000000..c1da62bfca
--- /dev/null
+++ b/de/advanced/healthcheck-graceful-shutdown.md
@@ -0,0 +1,33 @@
+---
+layout: page
+title: Health Checks and Graceful Shutdown
+description: Learn how to implement health checks and graceful shutdown in Express apps to enhance reliability, manage deployments, and integrate with load balancers like Kubernetes.
+menu: advanced
+redirect_from: " "
+---
+
+# Health Checks and Graceful Shutdown
+
+## Graceful shutdown
+
+When you deploy a new version of your application, you must replace the previous version. The process manager you're using will first send a SIGTERM signal to the application to notify it that it will be killed. Once the application gets this signal, it should stop accepting new requests, finish all the ongoing requests, clean up the resources it used, including database connections and file locks then exit.
+
+### Beispiel
+
+```js
+const server = app.listen(port)
+
+process.on('SIGTERM', () => {
+ debug('SIGTERM signal received: closing HTTP server')
+ server.close(() => {
+ debug('HTTP server closed')
+ })
+})
+```
+
+## Health checks
+
+A load balancer uses health checks to determine if an application instance is healthy and can accept requests. For example, [Kubernetes has two health checks](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/):
+
+- `liveness`, that determines when to restart a container.
+- `readiness`, that determines when a container is ready to start accepting traffic. When a pod is not ready, it is removed from the service load balancers.
\ No newline at end of file
diff --git a/de/advanced/pm.md b/de/advanced/pm.md
deleted file mode 100755
index c59e40eb87..0000000000
--- a/de/advanced/pm.md
+++ /dev/null
@@ -1,282 +0,0 @@
----
-layout: page
-title: Prozessmanager für Express-Anwendungen
-menu: advanced
-lang: de
----
-
-# Prozessmanager für Express-Anwendungen
-
-Wenn Sie Express-Anwendungen für Produktionsumgebungen ausführen, ist der Einsatz eines *Prozessmanagers* hilfreich, um folgende Aufgaben (Tasks) auszuführen:
-
-- Automatischer Neustart der Anwendung nach einem Absturz
-- Einblicke in die Laufzeitleistung und die Ressourcennutzung
-- Dynamische Änderung der Einstellungen zur Verbesserung des Leistungsverhaltens
-- Steuerung des Clustering
-
-Ein Prozessmanager ist vergleichbar mit einem Anwendungsserver: er ist ein "Container" für Anwendungen, der die Bereitstellung erleichtert, eine hohe Verfügbarkeit sicherstellt und die Verwaltung der Anwendung zur Laufzeit ermöglicht.
-
-Die gängigsten Prozessmanager für Express- und andere Node.js-Anwendungen sind:
-
-- [StrongLoop Process Manager](#sl)
-- [PM2](#pm2)
-- [Forever](#forever)
-
-
-Der Einsatz eines dieser drei Tools kann sehr hilfreich sein. StrongLoop Process Manager ist jedoch das einzige Tool, dass eine umfassende Laufzeit- und Bereitstellungslösung bietet, die den gesamten Node.js-Anwendungslebenszyklus abdeckt. Für jeden Schritt vor und nach der Produktion steht über eine einheitliche Schnittstelle ein Tool zur Verfügung.
-
-Nachfolgend finden Sie einen Kurzbeschreibung zu jedem dieser Tools.
-Einen ausführlichen Vergleich der Tools finden Sie unter [http://strong-pm.io/compare/](http://strong-pm.io/compare/).
-
-## StrongLoop Process Manager
-
-StrongLoop Process Manager (StrongLoop PM) ist ein Prozessmanager für Node.js-Anwendungen in Produktionsumgebungen. StrongLoop PM verfügt über integrierte Funktionen für Lastverteilung, Überwachung und Bereitstellung auf mehreren Hosts sowie eine grafische Konsole. Mit StrongLoop PM lassen sich die folgenden Aufgaben (Tasks) ausführen:
-
-- Erstellen, Packen und Bereitstellen Ihrer Node.js-Anwendung auf einem lokalen oder fernen System
-- Anzeige von CPU-Profilen und Heapspeichermomentaufnahmen (Heap-Snapshots) zur Optimierung der Leistung und Diagnose von Speicherlecks
-- Herstellen der dauerhaften Betriebsbereitschaft von Prozessen und Clustern
-- Anzeige von Leistungsmessdaten für Ihre Anwendung
-- Einfache Verwaltung von Bereitstellungen auf mehreren Hosts inkl. Nginx-Integration
-- Vereinheitlichung mehrerer StrongLoop PMs auf einer über Arc verwalteten verteilten Microservices-Laufzeitumgebung
-
-StrongLoop PM kann über ein leistungsfähiges Befehlszeilen-Schnittstellentool namens `slc` oder das grafisch orientierte Tool Arc genutzt werden. Arc ist ein Open-Source-Tool, das von StrongLoop kompetent unterstützt wird.
-
-Weitere Informationen siehe [http://strong-pm.io/](http://strong-pm.io/).
-
-Vollständige Dokumentation
-
-- [Node-Anwendungen im Betrieb (in der StrongLoop-Dokumentation)](http://docs.strongloop.com/display/SLC)
-- [StrongLoop Process Manager verwenden](http://docs.strongloop.com/display/SLC/Using+Process+Manager)
-
-### Installation
-
-
-$ [sudo] npm install -g strongloop
-
-
-
-### Grundlegende Verwendung
-
-
-$ cd my-app
-$ slc start
-
-
-
-Anzeigen des Status von Process Manager und allen bereitgestellten Anwendungen:
-
-
-
-$ slc ctl
-Service ID: 1
-Service Name: my-app
-Environment variables:
- No environment variables defined
-Instances:
- Version Agent version Cluster size
- 4.1.13 1.5.14 4
-Processes:
- ID PID WID Listening Ports Tracking objects? CPU profiling?
- 1.1.57692 57692 0
- 1.1.57693 57693 1 0.0.0.0:3001
- 1.1.57694 57694 2 0.0.0.0:3001
- 1.1.57695 57695 3 0.0.0.0:3001
- 1.1.57696 57696 4 0.0.0.0:3001
-
-
-
-Auflisten aller verwalteten Anwendungen (Services):
-
-
-
-$ slc ctl ls
-Id Name Scale
- 1 my-app 1
-
-
-
-Stoppen einer Anwendung:
-
-
-
-$ slc ctl stop my-app
-
-
-
-Neustart einer Anwendung:
-
-
-
-$ slc ctl restart my-app
-
-
-
-Sie können auch einen "Soft Restart" durchführen, damit die Verarbeitungsprozesse eine Karenzzeit zum Schließen bestehender Verbindungen erhalten. Dann kann die aktuelle Anwendung neu gestartet werden:
-
-
-
-$ slc ctl soft-restart my-app
-
-
-
-Entfernen einer Anwendung aus dem Verwaltungsprozess:
-
-
-
-$ slc ctl remove my-app
-
-
-
-## PM2
-
-PM2 ist ein Prozessmanager für Node.js-Anwendungen in Produktionsumgebungen, der über eine integrierte Lastausgleichsfunktion verfügt. Mit PM2 lässt sich die dauerhafte Betriebsbereitschaft von Anwendungen sicherstellen. So können die Anwendungen ohne Ausfallzeiten erneut geladen werden, wodurch die Ausführung allgemeiner Systemverwaltungsaufgaben erleichtert wird. Über PM2 können auch Protokollierung, Überwachung und Clustering von Anwendungen vorgenommen werden.
-
-Weitere Informationen siehe [https://github.com/Unitech/pm2](https://github.com/Unitech/pm2).
-
-### Installation
-
-
-
-$ [sudo] npm install pm2 -g
-
-
-
-### Grundlegende Verwendung
-
-Wenn Sie eine Anwendung mit dem Befehl `pm2` starten, müssen Sie den Pfad zur Anwendung angeben. Wenn Sie eine Anwendung jedoch stoppen, neu starten oder löschen, können Sie auch nur den Namen oder die ID der Anwendung angeben.
-
-
-
-$ pm2 start npm --name my-app -- start
-[PM2] restartProcessId process id 0
-┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬─────────────┬──────────┐
-│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │
-├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼─────────────┼──────────┤
-│ my-app │ 0 │ fork │ 64029 │ online │ 1 │ 0s │ 17.816 MB │ disabled │
-└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴─────────────┴──────────┘
- Use the `pm2 show ` command to get more details about an app.
-
-
-
-Wenn Sie eine Anwendung mit dem Befehl `pm2` starten, wird die Anwendung sofort in den Hintergrund gestellt. Sie können diese im Hintergrund laufende Anwendung über die Befehlszeile mit verschiedenen `pm2`-Befehlen steuern.
-
-nach dem Starten einer Anwendung mit dem Befehl `pm2` wird diese in der PM2-Prozessliste mit einer ID registriert. Sie können also Anwendungen mit demselben Namen aus verschiedenen Verzeichnissen auf dem System über deren ID verwalten.
-
-Beachten Sie Folgendes: Wenn mehrere Anwendungen mit demselben Namen ausgeführt werden, gelten die `pm2`-Befehle für alle Anwendungen. Verwenden Sie daher für das Verwalten einzelner Anwendungen IDs anstelle von Namen.
-
-Erstellen einer Liste aller aktiven Prozesse:
-
-
-
-$ pm2 list
-
-
-
-Stoppen einer Anwendung:
-
-
-
-$ pm2 stop 0
-
-
-
-Neustart einer Anwendung:
-
-
-
-$ pm2 restart 0
-
-
-
-Anzeige detaillierter Informationen zu einer Anwendung:
-
-
-
-$ pm2 show 0
-
-
-
-Entfernen einer Anwendung aus dem PM2-Register:
-
-
-
-$ pm2 delete 0
-
-
-
-
-## Forever
-
-Forever ist ein einfaches Befehlszeilen-Schnittstellentool, mit dem sichergestellt wird, dass ein Script kontinuierlich ausgeführt wird. Die einfache Benutzerschnittstelle von Forever eignet sich ideal für einfachere Bereitstellungen von Node.js-Anwendungen und Scripts.
-
-Weitere Informationen siehe [https://github.com/foreverjs/forever](https://github.com/foreverjs/forever).
-
-### Installation
-
-
-
-$ [sudo] npm install forever -g
-
-
-
-### Grundlegende Verwendung
-
-Verwenden Sie zum Starten eines Scripts den Befehl `forever start` und geben Sie den Pfad zum Script an:
-
-
-
-$ forever start script.js
-
-
-
-Dieser Befehl führt das Script im Dämonmodus (im Hintergrund) aus.
-
-Wenn Sie das Script so ausführen wollen, dass es an das Terminal angehängt wird, müssen Sie `start` weglassen:
-
-
-
-$ forever script.js
-
-
-
-Es ist sinnvoll, Ausgaben des Forever-Tools und des Scripts mit den Protokollierungsoptionen `-l`, `-o` und `-e` zu protokollieren (wie in diesem Beispiel gezeigt):
-
-
-
-$ forever start -l forever.log -o out.log -e err.log script.js
-
-
-
-Anzeigen der Liste mit Scripts, die über Forever gestartet wurden:
-
-
-
-$ forever list
-
-
-
-Stoppen eines Scripts, das über Forever gestartet wurde. Verwenden Sie hierzu den Befehl `forever stop` und geben Sie den Prozessindex an (der über den Befehl `forever list` erstellt wird).
-
-
-
-$ forever stop 1
-
-
-
-Geben Sie alternativ den Pfad zur Datei an:
-
-
-
-$ forever stop script.js
-
-
-
-Stoppen aller Scripts, die über Forever gestartet wurden:
-
-
-
-$ forever stopall
-
-
-
-Forever verfügt über eine Vielzahl von Optionen sowie eine programmgesteuerte API.
diff --git a/de/advanced/security-updates.md b/de/advanced/security-updates.md
old mode 100755
new mode 100644
index d63be11648..e882a9af54
--- a/de/advanced/security-updates.md
+++ b/de/advanced/security-updates.md
@@ -1,44 +1,87 @@
---
layout: page
title: Express-Sicherheitsupdates
+description: Review the latest security updates and patches for Express.js, including detailed vulnerability lists for different versions to help maintain a secure application.
menu: advanced
-lang: de
+redirect_from: " "
---
# Sicherheitsupdates
Typ | Wert | |
---|---|---|
Boolesch | --Wenn `true` angegeben wird, wird die IP-Adresse des Clients als der äußerst rechte Eintrag im Header `X-Forwarded-*` interpretiert. + | Wenn `true` angegeben wird, wird die IP-Adresse des Clients als der äußerst rechte Eintrag im Header `X-Forwarded-*` interpretiert.
+
Wenn `false` angegeben wird, wird die Anwendung als direkte Verbindung zum Internet gesehen. Die IP-Adresse des Clients wird dann von `req.connection.remoteAddress` abgeleitet. Dies ist die Standardeinstellung.
+
+
+When setting to `true`, it is important to ensure that the last reverse proxy trusted is removing/overwriting all of the following HTTP headers: `X-Forwarded-For`, `X-Forwarded-Host`, and `X-Forwarded-Proto`, otherwise it may be possible for the client to provide any value.
+
|
IP-Adressen | +IP addresses |
-Eine einzelne IP-Adresse, ein Teilnetz oder ein Array von IP-Adressen und Teilnetzen, denen vertraut werden kann. Die folgende Liste zeigt die vorkonfigurierten Teilnetznamen:
-* loopback - `127.0.0.1/8`, `::1/128`
-* linklocal - `169.254.0.0/16`, `fe80::/10`
-* uniquelocal - `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `fc00::/7`.
+An IP address, subnet, or an array of IP addresses and subnets to trust as being a reverse proxy. The following list shows the pre-configured subnet names:
+
+- loopback - `127.0.0.1/8`, `::1/128`
+- linklocal - `169.254.0.0/16`, `fe80::/10`
+- uniquelocal - `10.0.0.0/8`, `172.16.0.0/12`, `192.168.0.0/16`, `fc00::/7`
Sie können IP-Adressen wie folgt festlegen:
-
-
+app.set('trust proxy', ['loopback', 'linklocal', 'uniquelocal']) // specify multiple subnets as an array
+```
+
+Sobald die Werte angegeben wurden, werden die betreffenden IP-Adressen und Teilnetze aus dem Adressfeststellungsprozess ausgeschlossen. Die nicht vertrauenswürdige IP-Adresse, die am nächsten zum Anwendungsserver liegt, wird als IP-Adresse des Clients festgelegt. This works by checking if `req.socket.remoteAddress` is trusted. If so, then each address in `X-Forwarded-For` is checked from right to left until the first non-trusted address.
-Sobald die Werte angegeben wurden, werden die betreffenden IP-Adressen und Teilnetze aus dem Adressfeststellungsprozess ausgeschlossen. Die nicht vertrauenswürdige IP-Adresse, die am nächsten zum Anwendungsserver liegt, wird als IP-Adresse des Clients festgelegt.
|
Zahl |
-Dem `n`-ten Hop vom Proxy-Server soll als Client vertraut werden.
+Use the address that is at most `n` number of hops away from the Express application. `req.socket.remoteAddress` is the first hop, and the rest are looked for in the `X-Forwarded-For` header from right to left. A value of `0` means that the first untrusted address would be `req.socket.remoteAddress`, i.e. there is no reverse proxy.
+
+
+When using this setting, it is important to ensure there are not multiple, different-length paths to the Express application such that the client can be less than the configured number of hops away, otherwise it may be possible for the client to provide any value.
+
|
|
Funktion | +Function |
-Individuell angepasste, vertrauenswürdige Implementierung. Dies sollten Sie nur verwenden, wenn Sie genau wissen, was Sie tun.
-
+Custom trust implementation.
+
+```js
+app.set('trust proxy', (ip) => {
+ if (ip === '127.0.0.1' || ip === '123.123.123.123') return true // trusted IPs
+ else return false
+})
+```
+
|
-
+### Installation
+
+```bash
$ npm install cassandra-driver
-
-
+```
-**Beispiel**
+### Beispiel
-
-
-var cassandra = require('cassandra-driver');
-var client = new cassandra.Client({ contactPoints: ['localhost']});
+```js
+const cassandra = require('cassandra-driver')
+const client = new cassandra.Client({ contactPoints: ['localhost'] })
+
+client.execute('select key from system.local', (err, result) => {
+ if (err) throw err
+ console.log(result.rows[0])
+})
+```
-client.execute('select key from system.local', function(err, result) {
- if (err) throw err;
- console.log(result.rows[0]);
-});
-
-
+## Couchbase
-
+**Module**: [couchnode](https://github.com/couchbase/couchnode)
+
+### Installation
+
+```bash
+$ npm install couchbase
+```
+
+### Beispiel
+
+```js
+const couchbase = require('couchbase')
+const bucket = (new couchbase.Cluster('http://localhost:8091')).openBucket('bucketName')
+
+// add a document to a bucket
+bucket.insert('document-key', { name: 'Matt', shoeSize: 13 }, (err, result) => {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log(result)
+ }
+})
+
+// get all documents with shoe size 13
+const n1ql = 'SELECT d.* FROM `bucketName` d WHERE shoeSize = $1'
+const query = N1qlQuery.fromString(n1ql)
+bucket.query(query, [13], (err, result) => {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log(result)
+ }
+})
+```
## CouchDB
**Modul**: [nano](https://github.com/dscape/nano)
**Installation**
-
-
+### Installation
+
+```bash
$ npm install nano
-
-
+```
-**Beispiel**
+### Beispiel
-
-
-var nano = require('nano')('http://localhost:5984');
-nano.db.create('books');
-var books = nano.db.use('books');
+```js
+const nano = require('nano')('http://localhost:5984')
+nano.db.create('books')
+const books = nano.db.use('books')
-//Insert a book document in the books database
-books.insert({name: 'The Art of war'}, null, function(err, body) {
- if (!err){
- console.log(body);
+// Insert a book document in the books database
+books.insert({ name: 'The Art of war' }, null, (err, body) => {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log(body)
}
-});
+})
-//Get a list of all books
-books.list(function(err, body){
- console.log(body.rows);
-});
-
-
-
-
+// Get a list of all books
+books.list((err, body) => {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log(body.rows)
+ }
+})
+```
## LevelDB
**Modul**: [levelup](https://github.com/rvagg/node-levelup)
**Installation**
-
-
-$ npm install level levelup leveldown
-
-
+### Installation
-**Beispiel**
+```bash
+$ npm install level levelup leveldown
+```
-
-
-var levelup = require('levelup');
-var db = levelup('./mydb');
+### Beispiel
-db.put('name', 'LevelUP', function (err) {
+```js
+const levelup = require('levelup')
+const db = levelup('./mydb')
- if (err) return console.log('Ooops!', err);
- db.get('name', function (err, value) {
- if (err) return console.log('Ooops!', err);
- console.log('name=' + value);
- });
+db.put('name', 'LevelUP', (err) => {
+ if (err) return console.log('Ooops!', err)
-});
-
-
+ db.get('name', (err, value) => {
+ if (err) return console.log('Ooops!', err)
-
+ console.log(`name=${value}`)
+ })
+})
+```
## MySQL
**Modul**: [mysql](https://github.com/felixge/node-mysql/)
**Installation**
-
-
+### Installation
+
+```bash
$ npm install mysql
-
-
+```
-**Beispiel**
+### Beispiel
-
-
-var mysql = require('mysql');
-var connection = mysql.createConnection({
- host : 'localhost',
- user : 'dbuser',
- password : 's3kreee7'
-});
+```js
+const mysql = require('mysql')
+const connection = mysql.createConnection({
+ host: 'localhost',
+ user: 'dbuser',
+ password: 's3kreee7',
+ database: 'my_db'
+})
-connection.connect();
+connection.connect()
-connection.query('SELECT 1 + 1 AS solution', function(err, rows, fields) {
- if (err) throw err;
- console.log('The solution is: ', rows[0].solution);
-});
+connection.query('SELECT 1 + 1 AS solution', (err, rows, fields) => {
+ if (err) throw err
-connection.end();
-
-
+ console.log('The solution is: ', rows[0].solution)
+})
-
+connection.end()
+```
## MongoDB
**Modul**: [mongodb](https://github.com/mongodb/node-mongodb-native)
**Installation**
-
-
+### Installation
+
+```bash
$ npm install mongodb
-
-
+```
-**Beispiel**
+### Example (v2.\*)
-
-
-var MongoClient = require('mongodb').MongoClient;
+```js
+const MongoClient = require('mongodb').MongoClient
-MongoClient.connect('mongodb://localhost:27017/animals', function(err, db) {
- if (err) {
- throw err;
- }
- db.collection('mammals').find().toArray(function(err, result) {
- if (err) {
- throw err;
- }
- console.log(result);
- });
-});
-
-
+MongoClient.connect('mongodb://localhost:27017/animals', (err, db) => {
+ if (err) throw err
-Wenn Sie nach einem Objektmodelltreiber für MongoDB suchen, schauen Sie unter [Mongoose](https://github.com/LearnBoost/mongoose) nach.
+ db.collection('mammals').find().toArray((err, result) => {
+ if (err) throw err
+
+ console.log(result)
+ })
+})
+```
+
+### Example (v3.\*)
-
+```js
+const MongoClient = require('mongodb').MongoClient
+
+MongoClient.connect('mongodb://localhost:27017/animals', (err, client) => {
+ if (err) throw err
+
+ const db = client.db('animals')
+
+ db.collection('mammals').find().toArray((err, result) => {
+ if (err) throw err
+
+ console.log(result)
+ })
+})
+```
+
+Wenn Sie nach einem Objektmodelltreiber für MongoDB suchen, schauen Sie unter [Mongoose](https://github.com/LearnBoost/mongoose) nach.
## Neo4j
-**Modul**: [apoc](https://github.com/hacksparrow/apoc)
-**Installation**
+**Module**: [neo4j-driver](https://github.com/neo4j/neo4j-javascript-driver)
-
-
-$ npm install apoc
-
-
+### Installation
-**Beispiel**
+```bash
+$ npm install neo4j-driver
+```
-
-
-var apoc = require('apoc');
+### Beispiel
-apoc.query('match (n) return n').exec().then(
- function (response) {
- console.log(response);
- },
- function (fail) {
- console.log(fail);
- }
-);
-
-
+```js
+const neo4j = require('neo4j-driver')
+const driver = neo4j.driver('neo4j://localhost:7687', neo4j.auth.basic('neo4j', 'letmein'))
-
+const session = driver.session()
+
+session.readTransaction((tx) => {
+ return tx.run('MATCH (n) RETURN count(n) AS count')
+ .then((res) => {
+ console.log(res.records[0].get('count'))
+ })
+ .catch((error) => {
+ console.log(error)
+ })
+})
+```
## Oracle
@@ -229,7 +270,7 @@ apoc.query('match (n) return n').exec().then(
Anmerkung: [Siehe Installations-Voraussetzungen](https://github.com/oracle/node-oracledb#-installation).
-```sh
+```bash
$ npm install oracledb
```
@@ -267,137 +308,182 @@ async function getEmployee (empId) {
getEmployee(101)
```
-
-
## PostgreSQL
**Modul**: [pg-promise](https://github.com/vitaly-t/pg-promise)
**Installation**
-
-
-$ npm install pg-promise
-
-
-
-**Beispiel**
+### Installation
-
-
-var pgp = require("pg-promise")(/*options*/);
-var db = pgp("postgres://username:password@host:port/database");
+```bash
+$ npm install pg-promise
+```
-db.one("SELECT $1 AS value", 123)
- .then(function (data) {
- console.log("DATA:", data.value);
- })
- .catch(function (error) {
- console.log("ERROR:", error);
- });
-
-
+### Beispiel
-
+```js
+const pgp = require('pg-promise')(/* options */)
+const db = pgp('postgres://username:password@host:port/database')
+
+db.one('SELECT $1 AS value', 123)
+ .then((data) => {
+ console.log('DATA:', data.value)
+ })
+ .catch((error) => {
+ console.log('ERROR:', error)
+ })
+```
## Redis
**Modul**: [redis](https://github.com/mranney/node_redis)
**Installation**
-
-
+### Installation
+
+```bash
$ npm install redis
-
-
+```
+
+### Beispiel
-**Beispiel**
+```js
+const redis = require('redis')
+const client = redis.createClient()
+
+client.on('error', (err) => {
+ console.log(`Error ${err}`)
+})
-
-
-var client = require('redis').createClient();
+client.set('string key', 'string val', redis.print)
+client.hset('hash key', 'hashtest 1', 'some value', redis.print)
+client.hset(['hash key', 'hashtest 2', 'some other value'], redis.print)
-client.on('error', function (err) {
- console.log('Error ' + err);
-});
+client.hkeys('hash key', (err, replies) => {
+ console.log(`${replies.length} replies:`)
-client.set('string key', 'string val', redis.print);
-client.hset('hash key', 'hashtest 1', 'some value', redis.print);
-client.hset(['hash key', 'hashtest 2', 'some other value'], redis.print);
+ replies.forEach((reply, i) => {
+ console.log(` ${i}: ${reply}`)
+ })
+
+ client.quit()
+})
+```
-client.hkeys('hash key', function (err, replies) {
+## SQL Server
- console.log(replies.length + ' replies:');
- replies.forEach(function (reply, i) {
- console.log(' ' + i + ': ' + reply);
- });
+**Module**: [tedious](https://github.com/tediousjs/tedious)
- client.quit();
+### Installation
-});
-
-
+```bash
+$ npm install tedious
+```
-
+### Beispiel
+
+```js
+const Connection = require('tedious').Connection
+const Request = require('tedious').Request
+
+const config = {
+ server: 'localhost',
+ authentication: {
+ type: 'default',
+ options: {
+ userName: 'your_username', // update me
+ password: 'your_password' // update me
+ }
+ }
+}
+
+const connection = new Connection(config)
+
+connection.on('connect', (err) => {
+ if (err) {
+ console.log(err)
+ } else {
+ executeStatement()
+ }
+})
+
+function executeStatement () {
+ request = new Request("select 123, 'hello world'", (err, rowCount) => {
+ if (err) {
+ console.log(err)
+ } else {
+ console.log(`${rowCount} rows`)
+ }
+ connection.close()
+ })
+
+ request.on('row', (columns) => {
+ columns.forEach((column) => {
+ if (column.value === null) {
+ console.log('NULL')
+ } else {
+ console.log(column.value)
+ }
+ })
+ })
+
+ connection.execSql(request)
+}
+```
## SQLite
**Modul**: [sqlite3](https://github.com/mapbox/node-sqlite3)
**Installation**
-
-
-$ npm install sqlite3
-
-
+### Installation
-**Beispiel**
+```bash
+$ npm install sqlite3
+```
-
-
-var sqlite3 = require('sqlite3').verbose();
-var db = new sqlite3.Database(':memory:');
+### Beispiel
-db.serialize(function() {
+```js
+const sqlite3 = require('sqlite3').verbose()
+const db = new sqlite3.Database(':memory:')
- db.run('CREATE TABLE lorem (info TEXT)');
- var stmt = db.prepare('INSERT INTO lorem VALUES (?)');
+db.serialize(() => {
+ db.run('CREATE TABLE lorem (info TEXT)')
+ const stmt = db.prepare('INSERT INTO lorem VALUES (?)')
- for (var i = 0; i < 10; i++) {
- stmt.run('Ipsum ' + i);
+ for (let i = 0; i < 10; i++) {
+ stmt.run(`Ipsum ${i}`)
}
- stmt.finalize();
+ stmt.finalize()
- db.each('SELECT rowid AS id, info FROM lorem', function(err, row) {
- console.log(row.id + ': ' + row.info);
- });
-});
+ db.each('SELECT rowid AS id, info FROM lorem', (err, row) => {
+ console.log(`${row.id}: ${row.info}`)
+ })
+})
-db.close();
-
-
-
-
+db.close()
+```
## ElasticSearch
**Modul**: [elasticsearch](https://github.com/elastic/elasticsearch-js)
**Installation**
-
-
+### Installation
+
+```bash
$ npm install elasticsearch
-
-
+```
-**Beispiel**
+### Beispiel
-
-
-var elasticsearch = require('elasticsearch');
-var client = elasticsearch.Client({
+```js
+const elasticsearch = require('elasticsearch')
+const client = elasticsearch.Client({
host: 'localhost:9200'
-});
+})
client.search({
index: 'books',
@@ -410,10 +496,9 @@ client.search({
}
}
}
-}).then(function(response) {
- var hits = response.hits.hits;
-}, function(error) {
- console.trace(error.message);
-});
-
-
+}).then((response) => {
+ const hits = response.hits.hits
+}, (error) => {
+ console.trace(error.message)
+})
+```
diff --git a/de/guide/debugging.md b/de/guide/debugging.md
old mode 100755
new mode 100644
index d88cfad7ab..0661aaf8b3
--- a/de/guide/debugging.md
+++ b/de/guide/debugging.md
@@ -1,39 +1,28 @@
---
layout: page
title: Debugging bei Express
+description: Learn how to enable and use debugging logs in Express.js applications by setting the DEBUG environment variable for enhanced troubleshooting.
menu: guide
-lang: de
+redirect_from: " "
---
# Debugging bei Express
-Express verwendet das Modul [debug](https://www.npmjs.com/package/debug) intern, um Informationen zu Weiterleitungsübereinstimmungen, verwendete Middlewarefunktionen, Anwendungsmodi und den Verlauf des Anforderung/Antwort-Zyklus zu protokollieren.
-
-
-
+```bash
$ DEBUG=express:* node index.js
-
-
+```
Verwenden Sie unter Windows den entsprechenden Befehl.
-
-
-> set DEBUG=express:* & node index.js
-
-
+```bash
+> $env:DEBUG = "express:*"; node index.js
+```
Die Ausführung dieses Befehls für die durch [express generator](/{{ page.lang }}/starter/generator.html) generierte Standardanwendung resultiert in folgender Ausgabe:
-
-
+```bash
$ DEBUG=express:* node ./bin/www
express:router:route new / +0ms
express:router:layer new / +1ms
@@ -69,19 +58,17 @@ $ DEBUG=express:* node ./bin/www
express:router:layer new / +1ms
express:router use /users router +0ms
express:router:layer new /users +0ms
- express:router use / <anonymous> +0ms
+ express:router use / <anonymous> +0ms
express:router:layer new / +0ms
- express:router use / <anonymous> +0ms
+ express:router use / <anonymous> +0ms
express:router:layer new / +0ms
- express:router use / <anonymous> +0ms
+ express:router use / <anonymous> +0ms
express:router:layer new / +0ms
-
-
+```
Bei einer Anforderung an die Anwendung sind die Protokolle im Express-Code angegeben:
-
-
+```bash
express:router dispatching GET / +4h
express:router query : / +2ms
express:router expressInit : / +0ms
@@ -97,29 +84,46 @@ Bei einer Anforderung an die Anwendung sind die Protokolle im Express-Code angeg
express:view lookup "index.pug" +338ms
express:view stat "/projects/example/views/index.pug" +0ms
express:view render "/projects/example/views/index.pug" +1ms
-
-
+```
Wenn Sie nur die Protokolle von der Routerimplementierung sehen wollen, legen Sie den Wert für `DEBUG` auf `express:router` fest. Gleichermaßen gilt: Wenn Sie nur die Protokolle von der Anwendungsimplementierung sehen wollen, legen Sie den Wert für `DEBUG` auf `express:application` fest, usw.
## Von `express` generierte Anwendungen
-Eine über den Befehl `express` generierte Anwendung verwendet ebenfalls das Modul `debug`. Der Debug-Namespace wird auf den Namen der Anwendung erweitert.
+An application generated by the `express` command uses the `debug` module and its debug namespace is scoped to the name of the application.
Beispiel: Wenn Sie die Anwendung mit `$ express sample-app` generiert haben, können Sie die Debuganweisungen mit dem folgenden Befehl aktivieren:
-
-
+```bash
$ DEBUG=sample-app:* node ./bin/www
-
-
+```
Sie können mehrere Debug-Namespaces in einer durch Kommas getrennten Namensliste angeben:
-
-
+```bash
$ DEBUG=http,mail,express:* node index.js
-
-
+```
+
+## Advanced options
+
+When running through Node.js, you can set a few environment variables that will change the behavior of the debug logging:
+
+| Name | Purpose |
+| ------------------- | ----------------------------------------------------------------- |
+| `DEBUG` | Enables/disables specific debugging namespaces. |
+| `DEBUG_COLORS` | Whether or not to use colors in the debug output. |
+| `DEBUG_DEPTH` | Object inspection depth. |
+| `DEBUG_FD` | File descriptor to write debug output to. |
+| `DEBUG_SHOW_HIDDEN` | Shows hidden properties on inspected objects. |
+
+{% capture debug-text %}
+
+The environment variables beginning with `DEBUG_` end up being
+converted into an Options object that gets used with `%o`/`%O` formatters.
+See the Node.js documentation for
+[`util.inspect()`](https://nodejs.org/api/util.html#util_util_inspect_object_options)
+for the complete list.
+
+{% endcapture %}
-Weitere Informationen zu `debug` finden Sie unter [debug](https://www.npmjs.com/package/debug).
+{% include admonitions/note.html content=debug-text %}
diff --git a/de/guide/error-handling.md b/de/guide/error-handling.md
old mode 100755
new mode 100644
index 186081978f..1ffb0f9738
--- a/de/guide/error-handling.md
+++ b/de/guide/error-handling.md
@@ -1,119 +1,143 @@
---
layout: page
title: Fehlerbehandlung in Express
+description: Understand how Express.js handles errors in synchronous and asynchronous code, and learn to implement custom error handling middleware for your applications.
menu: guide
-lang: de
+redirect_from: " "
---
# Fehlerbehandlung
-Middlewarefunktionen für die Fehlerbehandlung werden in derselben Weise definiert wie andere Middlewarefunktionen, nur, dass Fehlerbehandlungsfunktionen vier anstatt drei Argumente aufweisen:
-`(err, req, res, next)`. Beispiel:
+_Error Handling_ refers to how Express catches and processes errors that
+occur both synchronously and asynchronously. Express comes with a default error
+handler so you don't need to write your own to get started.
-
-
-app.use(function(err, req, res, next) {
- console.error(err.stack);
- res.status(500).send('Something broke!');
-});
-
-
-
-Middleware für die Fehlerbehandlung wird ganz zuletzt nach allen anderen `app.use()`- und Weiterleitungsaufrufen definiert. Beispiel:
-
-
-
-var bodyParser = require('body-parser');
-var methodOverride = require('method-override');
-
-app.use(bodyParser());
-app.use(methodOverride());
-app.use(function(err, req, res, next) {
- // logic
-});
-
-
+## Catching Errors
-Antworten von der Middlewarefunktion können das von Ihnen gewünschte Format aufweisen wie beispielsweise eine Fehlerseite im HTML-Format, eine einfache Nachricht oder eine JSON-Zeichenfolge.
+It's important to ensure that Express catches all errors that occur while
+running route handlers and middleware.
-Für organisatorische Zwecke (und Frameworks der höheren Ebene) können Sie mehrere Middlewarefunktionen für die Fehlerbehandlung definieren, wie Sie dies bei regulären Middlewarefunktionen auch tun würden. Wenn Sie beispielsweise eine Fehlerbehandlungsroutine (Error-Handler) für Anforderungen über `XHR` und andere Anforderungen definieren wollen, können Sie die folgenden Befehle verwenden:
+Errors that occur in synchronous code inside route handlers and middleware
+require no extra work. If synchronous code throws an error, then Express will
+catch and process it. Beispiel:
-
-
-var bodyParser = require('body-parser');
-var methodOverride = require('method-override');
+```js
+app.get('/', (req, res) => {
+ throw new Error('BROKEN') // Express will catch this on its own.
+})
+```
-app.use(bodyParser());
-app.use(methodOverride());
-app.use(logErrors);
-app.use(clientErrorHandler);
-app.use(errorHandler);
-
-
+Middlewarefunktionen für die Fehlerbehandlung werden in derselben Weise definiert wie andere Middlewarefunktionen, nur, dass Fehlerbehandlungsfunktionen vier anstatt drei Argumente aufweisen:
+`(err, req, res, next)`. Beispiel:
-In diesem Beispiel kann die generische `logErrors`-Funktion Anforderungs- und Fehlerinformationen in `stderr` schreiben:
+```js
+app.get('/', (req, res, next) => {
+ fs.readFile('/file-does-not-exist', (err, data) => {
+ if (err) {
+ next(err) // Pass errors to Express.
+ } else {
+ res.send(data)
+ }
+ })
+})
+```
-
-
-function logErrors(err, req, res, next) {
- console.error(err.stack);
- next(err);
-}
-
-
+Middleware für die Fehlerbehandlung wird ganz zuletzt nach allen anderen `app.use()`- und Weiterleitungsaufrufen definiert.
+Beispiel:
-In diesem Beispiel wird `clientErrorHandler` wie folgt definiert. In diesem Fall wird der Fehler explizit an den nächsten Error-Handler übergeben:
+```js
+app.get('/user/:id', async (req, res, next) => {
+ const user = await getUserById(req.params.id)
+ res.send(user)
+})
+```
-
-
-function clientErrorHandler(err, req, res, next) {
- if (req.xhr) {
- res.status(500).send({ error: 'Something failed!' });
- } else {
- next(err);
- }
-}
-
-
+If `getUserById` throws an error or rejects, `next` will be called with either
+the thrown error or the rejected value. If no rejected value is provided, `next`
+will be called with a default Error object provided by the Express router.
-Die `errorHandler`-Funktion "catch-all" kann wie folgt implementiert werden:
+Wenn Sie Übergaben an die Funktion `next()` vornehmen (außer die Zeichenfolge `'route'`), sieht Express die aktuelle Anforderung als Fehler an und überspringt alle verbleibenden fehlerfreien Behandlungsroutinen und Middlewarefunktionen.
-
-
-function errorHandler(err, req, res, next) {
- res.status(500);
- res.render('error', { error: err });
-}
-
-
+If the callback in a sequence provides no data, only errors, you can simplify
+this code as follows:
-Wenn Sie Übergaben an die Funktion `next()` vornehmen (außer die Zeichenfolge `'route'`), sieht Express die aktuelle Anforderung als Fehler an und überspringt alle verbleibenden fehlerfreien Behandlungsroutinen und Middlewarefunktionen. Wenn Sie den Fehler bearbeiten wollen, müssen Sie (wie im nächsten Abschnitt beschrieben) eine Fehlerbehandlungsweiterleitung erstellen.
+```js
+app.get('/', [
+ function (req, res, next) {
+ fs.writeFile('/inaccessible-path', 'data', next)
+ },
+ function (req, res) {
+ res.send('OK')
+ }
+])
+```
-Bei einem Routenhandler mit mehreren Callback-Funktionen können Sie den Parameter `route` verwenden, um den nächsten Routenhandler zu überspringen. Beispiel:
+In the above example, `next` is provided as the callback for `fs.writeFile`,
+which is called with or without errors. If there is no error, the second
+handler is executed, otherwise Express catches and processes the error.
-
-
-app.get('/a_route_behind_paywall',
- function checkIfPaidSubscriber(req, res, next) {
- if(!req.user.hasPaid) {
+Bei einem Routenhandler mit mehreren Callback-Funktionen können Sie den Parameter `route` verwenden, um den nächsten Routenhandler zu überspringen. Beispiel:
- // continue handling this request
- next('route');
+```js
+app.get('/', (req, res, next) => {
+ setTimeout(() => {
+ try {
+ throw new Error('BROKEN')
+ } catch (err) {
+ next(err)
}
- }, function getPaidContent(req, res, next) {
- PaidContent.find(function(err, doc) {
- if(err) return next(err);
- res.json(doc);
- });
- });
-
-
+ }, 100)
+})
+```
-In diesem Beispiel wird der Handler `getPaidContent` übersprungen. Alle verbleibenden Handler in `app` für `/a_route_behind_paywall` werden jedoch weiter ausgeführt.
+The above example uses a `try...catch` block to catch errors in the
+asynchronous code and pass them to Express. If the `try...catch`
+block were omitted, Express would not catch the error since it is not part of the synchronous
+handler code.
-
-
-function errorHandler(err, req, res, next) {
+```js
+function errorHandler (err, req, res, next) {
if (res.headersSent) {
- return next(err);
+ return next(err)
}
- res.status(500);
- res.render('error', { error: err });
+ res.status(500)
+ res.render('error', { error: err })
}
-
-
+```
+
+Note that the default error handler can get triggered if you call `next()` with an error
+in your code more than once, even if custom error handling middleware is in place.
+
+Other error handling middleware can be found at [Express middleware](/{{ page.lang }}/resources/middleware.html).
+
+## Writing error handlers
+
+Define error-handling middleware functions in the same way as other middleware functions,
+except error-handling functions have four arguments instead of three:
+`(err, req, res, next)`. Beispiel:
+
+```js
+app.use((err, req, res, next) => {
+ console.error(err.stack)
+ res.status(500).send('Something broke!')
+})
+```
+
+You define error-handling middleware last, after other `app.use()` and routes calls; for example:
+
+```js
+const bodyParser = require('body-parser')
+const methodOverride = require('method-override')
+
+app.use(bodyParser.urlencoded({
+ extended: true
+}))
+app.use(bodyParser.json())
+app.use(methodOverride())
+app.use((err, req, res, next) => {
+ // logic
+})
+```
+
+Antworten von der Middlewarefunktion können das von Ihnen gewünschte Format aufweisen wie beispielsweise eine Fehlerseite im HTML-Format, eine einfache Nachricht oder eine JSON-Zeichenfolge.
+
+Für organisatorische Zwecke (und Frameworks der höheren Ebene) können Sie mehrere Middlewarefunktionen für die Fehlerbehandlung definieren, wie Sie dies bei regulären Middlewarefunktionen auch tun würden. Wenn Sie beispielsweise eine Fehlerbehandlungsroutine (Error-Handler) für Anforderungen über `XHR` und andere Anforderungen definieren wollen, können Sie die folgenden Befehle verwenden:
+
+```js
+const bodyParser = require('body-parser')
+const methodOverride = require('method-override')
+
+app.use(bodyParser.urlencoded({
+ extended: true
+}))
+app.use(bodyParser.json())
+app.use(methodOverride())
+app.use(logErrors)
+app.use(clientErrorHandler)
+app.use(errorHandler)
+```
+
+In diesem Beispiel kann die generische `logErrors`-Funktion Anforderungs- und Fehlerinformationen in `stderr` schreiben:
+
+```js
+function logErrors (err, req, res, next) {
+ console.error(err.stack)
+ next(err)
+}
+```
+
+In diesem Beispiel wird `clientErrorHandler` wie folgt definiert. In diesem Fall wird der Fehler explizit an den nächsten Error-Handler übergeben:
+
+Notice that when _not_ calling "next" in an error-handling function, you are responsible for writing (and ending) the response. Otherwise, those requests will "hang" and will not be eligible for garbage collection.
+
+```js
+function clientErrorHandler (err, req, res, next) {
+ if (req.xhr) {
+ res.status(500).send({ error: 'Something failed!' })
+ } else {
+ next(err)
+ }
+}
+```
+
+Die `errorHandler`-Funktion "catch-all" kann wie folgt implementiert werden:
+
+```js
+function errorHandler (err, req, res, next) {
+ res.status(500)
+ res.render('error', { error: err })
+}
+```
+
+If you have a route handler with multiple callback functions, you can use the `route` parameter to skip to the next route handler. Beispiel:
+
+```js
+app.get('/a_route_behind_paywall',
+ (req, res, next) => {
+ if (!req.user.hasPaid) {
+ // continue handling this request
+ next('route')
+ } else {
+ next()
+ }
+ }, (req, res, next) => {
+ PaidContent.find((err, doc) => {
+ if (err) return next(err)
+ res.json(doc)
+ })
+ })
+```
+
+In diesem Beispiel wird der Handler `getPaidContent` übersprungen. Alle verbleibenden Handler in `app` für `/a_route_behind_paywall` werden jedoch weiter ausgeführt.
+
+Express 3 | Express 4 |
---|---|
Express 3 | Express 4 |
express.bodyParser |
body-parser + multer | serve-index |
express.static |
serve-static |
app.use
akzeptiert Parameter.
-
-app.use('/book/:id', function(req, res, next) {
- console.log('ID:', req.params.id);
- next();
-});
-
-
app.route()
-
+```js
app.route('/book')
- .get(function(req, res) {
- res.send('Get a random book');
+ .get((req, res) => {
+ res.send('Get a random book')
})
- .post(function(req, res) {
- res.send('Add a book');
+ .post((req, res) => {
+ res.send('Add a book')
})
- .put(function(req, res) {
- res.send('Update the book');
- });
-
-
+ .put((req, res) => {
+ res.send('Update the book')
+ })
+```
express.Router
-
-var express = require('express');
-var router = express.Router();
+```js
+var express = require('express')
+var router = express.Router()
// middleware specific to this router
-router.use(function timeLog(req, res, next) {
- console.log('Time: ', Date.now());
- next();
-});
+router.use((req, res, next) => {
+ console.log('Time: ', Date.now())
+ next()
+})
// define the home page route
-router.get('/', function(req, res) {
- res.send('Birds home page');
-});
+router.get('/', (req, res) => {
+ res.send('Birds home page')
+})
// define the about route
-router.get('/about', function(req, res) {
- res.send('About birds');
-});
+router.get('/about', (req, res) => {
+ res.send('About birds')
+})
-module.exports = router;
-
-
+module.exports = router
+```
Laden Sie dann das Routermodul in die Anwendung:
-
-
-var birds = require('./birds');
-...
-app.use('/birds', birds);
-
-
+```js
+var birds = require('./birds')
+
+// ...
+
+app.use('/birds', birds)
+```
Die Anwendung kann nun Anforderungen an die Pfade `/birds` und `/birds/about` bearbeiten und ruft die Middleware `timeLog` auf, die speziell für diese Weiterleitung bestimmt ist.
@@ -180,7 +179,7 @@ Weitere Änderungen
In der folgenden Tabelle sind andere kleinere, aber trotzdem wichtige Änderungen in Express 4 aufgeführt:
Objekt | Beschreibung | -Die Funktion `app.configure()` wurde entfernt. Verwenden Sie die Funktion `process.env.NODE_ENV` oder `app.get('env')`, um die Umgebung zu erkennen und die Anwendung entsprechend zu konfigurieren. +Die Funktion `app.configure()` wurde entfernt. Verwenden Sie die Funktion `process.env.NODE_ENV` oder `app.get('env')`, um die Umgebung zu erkennen und die Anwendung entsprechend zu konfigurieren. |
---|---|
-
-var express = require('express');
-var routes = require('./routes');
-var user = require('./routes/user');
-var http = require('http');
-var path = require('path');
+```js
+var express = require('express')
+var routes = require('./routes')
+var user = require('./routes/user')
+var http = require('http')
+var path = require('path')
-var app = express();
+var app = express()
// all environments
-app.set('port', process.env.PORT || 3000);
-app.set('views', path.join(__dirname, 'views'));
-app.set('view engine', 'pug');
-app.use(express.favicon());
-app.use(express.logger('dev'));
-app.use(express.methodOverride());
-app.use(express.session({ secret: 'your secret here' }));
-app.use(express.bodyParser());
-app.use(app.router);
-app.use(express.static(path.join(__dirname, 'public')));
+app.set('port', process.env.PORT || 3000)
+app.set('views', path.join(__dirname, 'views'))
+app.set('view engine', 'pug')
+app.use(express.favicon())
+app.use(express.logger('dev'))
+app.use(express.methodOverride())
+app.use(express.session({ secret: 'your secret here' }))
+app.use(express.bodyParser())
+app.use(app.router)
+app.use(express.static(path.join(__dirname, 'public')))
// development only
-if ('development' == app.get('env')) {
- app.use(express.errorHandler());
+if (app.get('env') === 'development') {
+ app.use(express.errorHandler())
}
-app.get('/', routes.index);
-app.get('/users', user.list);
+app.get('/', routes.index)
+app.get('/users', user.list)
-http.createServer(app).listen(app.get('port'), function(){
- console.log('Express server listening on port ' + app.get('port'));
-});
-
-
+http.createServer(app).listen(app.get('port'), () => {
+ console.log('Express server listening on port ' + app.get('port'))
+})
+```
package.json
-
+```json
{
"name": "application-name",
"version": "0.0.1",
@@ -354,8 +351,7 @@ Die zugehörige `package.json`-Datei der Version 3 sieht in etwa wie folgt aus:
"pug": "*"
}
}
-
-
+```
-
+```bash
$ npm install serve-favicon morgan method-override express-session body-parser multer errorhandler express@latest pug@latest --save
-
-
+```
Nehmen Sie an `app.js` die folgenden Änderungen vor:
1. Die integrierten Express-Middlewarefunktionen `express.favicon`,
- `express.logger`, `express.methodOverride`,
- `express.session`, `express.bodyParser` und
- `express.errorHandler` sind im Objekt `express` nicht mehr verfügbar. Sie müssen deren Alternativen manuell installieren und in die Anwendung laden.
+ `express.logger`, `express.methodOverride`,
+ `express.session`, `express.bodyParser` und
+ `express.errorHandler` sind im Objekt `express` nicht mehr verfügbar. Sie müssen deren Alternativen manuell installieren und in die Anwendung laden.
-2. Sie müssen die Funktion `app.router` nicht mehr laden. Sie ist kein gültiges Express 4-Anwendungsobjekt. Entfernen Sie also den Code `app.use(app.router);`.
+2. Sie müssen die Funktion `app.router` nicht mehr laden.
+ Sie ist kein gültiges Express 4-Anwendungsobjekt. Entfernen Sie also den Code `app.use(app.router);`.
3. Stellen Sie sicher, dass die Middlewarefunktionen in der richtigen Reihenfolge geladen werden – laden Sie `errorHandler` nach dem Laden der Anwendungsweiterleitungen.
@@ -386,8 +381,7 @@ Nehmen Sie an `app.js` die folgenden Änderungen vor:
Durch Ausführung des Befehls `npm` wird `package.json` wie folgt aktualisiert:
-
-
+```json
{
"name": "application-name",
"version": "0.0.1",
@@ -400,87 +394,84 @@ Durch Ausführung des Befehls `npm` wird `package.json` wie folgt aktualisiert:
"errorhandler": "^1.1.1",
"express": "^4.8.0",
"express-session": "^1.7.2",
- "pug": "^2.0.0-beta6",
+ "pug": "^2.0.0",
"method-override": "^2.1.2",
"morgan": "^1.2.2",
"multer": "^0.1.3",
"serve-favicon": "^2.0.1"
}
}
-
-
+```
app.js
-
-var http = require('http');
-var express = require('express');
-var routes = require('./routes');
-var user = require('./routes/user');
-var path = require('path');
+```js
+var http = require('http')
+var express = require('express')
+var routes = require('./routes')
+var user = require('./routes/user')
+var path = require('path')
-var favicon = require('serve-favicon');
-var logger = require('morgan');
-var methodOverride = require('method-override');
-var session = require('express-session');
-var bodyParser = require('body-parser');
-var multer = require('multer');
-var errorHandler = require('errorhandler');
+var favicon = require('serve-favicon')
+var logger = require('morgan')
+var methodOverride = require('method-override')
+var session = require('express-session')
+var bodyParser = require('body-parser')
+var multer = require('multer')
+var errorHandler = require('errorhandler')
-var app = express();
+var app = express()
// all environments
-app.set('port', process.env.PORT || 3000);
-app.set('views', path.join(__dirname, 'views'));
-app.set('view engine', 'pug');
-app.use(favicon(__dirname + '/public/favicon.ico'));
-app.use(logger('dev'));
-app.use(methodOverride());
-app.use(session({ resave: true,
- saveUninitialized: true,
- secret: 'uwotm8' }));
-app.use(bodyParser.json());
-app.use(bodyParser.urlencoded({ extended: true }));
-app.use(multer());
-app.use(express.static(path.join(__dirname, 'public')));
-
-app.get('/', routes.index);
-app.get('/users', user.list);
+app.set('port', process.env.PORT || 3000)
+app.set('views', path.join(__dirname, 'views'))
+app.set('view engine', 'pug')
+app.use(favicon(path.join(__dirname, '/public/favicon.ico')))
+app.use(logger('dev'))
+app.use(methodOverride())
+app.use(session({
+ resave: true,
+ saveUninitialized: true,
+ secret: 'uwotm8'
+}))
+app.use(bodyParser.json())
+app.use(bodyParser.urlencoded({ extended: true }))
+app.use(multer())
+app.use(express.static(path.join(__dirname, 'public')))
+
+app.get('/', routes.index)
+app.get('/users', user.list)
// error handling middleware should be loaded after the loading the routes
-if ('development' == app.get('env')) {
- app.use(errorHandler());
+if (app.get('env') === 'development') {
+ app.use(errorHandler())
}
-var server = http.createServer(app);
-server.listen(app.get('port'), function(){
- console.log('Express server listening on port ' + app.get('port'));
-});
-
-
-
-
-app.listen(app.get('port'), function(){
- console.log('Express server listening on port ' + app.get('port'));
-});
-
-
+var server = http.createServer(app)
+server.listen(app.get('port'), () => {
+ console.log('Express server listening on port ' + app.get('port'))
+})
+```
+
+
-
+```bash
$ node .
-
-
+```
Laden Sie [http://localhost:3000](http://localhost:3000) und sehen Sie, wie die Homepage von Express 4 wiedergegeben wird.
@@ -492,23 +483,20 @@ Das Befehlszeilentool zum Generieren einer Express-Anwendung ist nach wie vor `e
Wenn der Express 3 App Generator bereits auf Ihrem System installiert ist, müssen Sie diesen deinstallieren:
-
-
+```bash
$ npm uninstall -g express
-
-
+```
+
Abhängig davon, wie Ihre Datei- und Verzeichnissberechtigungen konfiguriert sind, müssen Sie diesen Befehl möglicherweise mit `sudo` ausführen.
+
Installieren Sie nun den neuen Generator:
-
-
+```bash
$ npm install -g express-generator
-
-
+```
Abhängig davon, wie Ihre Datei- und Verzeichnissberechtigungen konfiguriert sind, müssen Sie diesen Befehl möglicherweise mit `sudo` ausführen.
-
Nun wird der Befehl `express` auf Ihrem System auf den Express 4 App Generator aktualisiert.
-
+```bash
$ express app4
-
-
+```
Wenn Sie sich den Inhalt der Datei `app4/app.js` ansehen, werden Sie feststellen, dass alle Middlewarefunktionen (außer `express.static`), die für die Anwendung erforderlich sind, als unabhängige Module geladen werden und die Middleware `router` nicht mehr explizit in die Anwendung geladen wird.
@@ -536,11 +523,9 @@ Sie werden auch feststellen, dass die Datei `app.js` nun ein Node.js-Modul ist
Starten Sie nach der Installation der Abhängigkeiten die Anwendung mit dem folgenden Befehl:
-
-
+```bash
$ npm start
-
-
+```
Wenn Sie sich das npm-Startscript in der Datei `package.json` näher ansehen, werden Sie feststellen, dass der eigentliche Befehl, der die Anwendung startet, `node ./bin/www` heißt. Dieser Befehl lautete in Express 3 `node app.js`.
@@ -550,23 +535,19 @@ Weder das Verzeichnis `bin` noch die erweiterungslose Datei `www` ist für das E
Um das Verzeichnis `www` zu löschen und alles im "Express 3-Stil" zu belassen, löschen Sie die Zeile mit dem Eintrag `module.exports = app;` am Ende der Datei `app.js`. Fügen Sie dann stattdessen den folgenden Code an derselben Position ein:
-
-
-app.set('port', process.env.PORT || 3000);
+```js
+app.set('port', process.env.PORT || 3000)
-var server = app.listen(app.get('port'), function() {
- debug('Express server listening on port ' + server.address().port);
-});
-
-
+var server = app.listen(app.get('port'), () => {
+ debug('Express server listening on port ' + server.address().port)
+})
+```
Stellen Sie sicher, dass Sie das Modul `debug` am Anfang der Datei `app.js` laden. Verwenden Sie dazu den folgenden Code:
-
-
-var debug = require('debug')('app4');
-
-
+```js
+var debug = require('debug')('app4')
+```
Ändern Sie als Nächstes `"start": "node ./bin/www"` in der Datei `package.json` in `"start": "node app.js"`.
diff --git a/de/guide/migrating-5.md b/de/guide/migrating-5.md
old mode 100755
new mode 100644
index 837fdea897..af9d495fd5
--- a/de/guide/migrating-5.md
+++ b/de/guide/migrating-5.md
@@ -1,31 +1,44 @@
---
layout: page
title: Migration auf Express 5
+description: A comprehensive guide to migrating your Express.js applications from version 4 to 5, detailing breaking changes, deprecated methods, and new improvements.
menu: guide
-lang: de
+redirect_from: " "
---
# Wechsel zu Express 5
-
-$ npm install express@5.0.0-alpha.2 --save
-
-
+```sh
+npm install "express@5"
+```
Sie können Ihre automatisierten Tests ausführen, um zu sehen, was fehlschlägt, und Probleme gemäß den folgenden Updates beheben. Nachdem Sie alle Testfehler behoben haben, führen Sie Ihre Anwendung aus, um zu sehen, welche Fehler noch auftreten. Sie werden sofort feststellen, ob die Anwendung Methoden oder Eigenschaften verwendet, die nicht unterstützt werden.
-res.send(status)
, nicht mehr, wobei _`status`_ für eine Zahl steht. Verwenden Sie stattdessen die Funktion `res.sendStatus(statusCode)`, mit der der Statuscode für den HTTP-Antwort-Header festgelegt und die Textversion des Codes gesendet wird: "Not Found" (Nicht gefunden), "Internal Server Error" (Interner Serverfehler) usw.
+Wenn Sie eine Zahl senden und hierfür die Funktion `res.send()` verwenden müssen, müssen Sie die Zahl in Anführungszeichen setzen, um diese in eine Zeichenfolge zu konvertieren. Dadurch interpretiert Express diese Zahl nicht als Versuch, die nicht mehr unterstützte alte Signatur zu verwenden.
+
+{% include admonitions/note.html content=codemod-deprecated-signatures %}
-Express 5 unterstützt die Signatur res.send(status)
, nicht mehr, wobei *`status`* für eine Zahl steht. Verwenden Sie stattdessen die Funktion `res.sendStatus(statusCode)`, mit der der Statuscode für den HTTP-Antwort-Header festgelegt und die Textversion des Codes gesendet wird: "Not Found" (Nicht gefunden), "Internal Server Error" (Interner Serverfehler) usw. Wenn Sie eine Zahl senden und hierfür die Funktion `res.send()` verwenden müssen, müssen Sie die Zahl in Anführungszeichen setzen, um diese in eine Zeichenfolge zu konvertieren. Dadurch interpretiert Express diese Zahl nicht als Versuch, die nicht mehr unterstützte alte Signatur zu verwenden.
+```js
+// v4
+app.get('/user', (req, res) => {
+ res.send(200)
+})
-
-
-var express = require('express');
-var app = express();
+```js
+const express = require('express')
+const app = express()
// respond with "hello world" when a GET request is made to the homepage
-app.get('/', function(req, res) {
- res.send('hello world');
-});
-
-
+app.get('/', (req, res) => {
+ res.send('hello world')
+})
+```
-
+```js
// GET method route
-app.get('/', function (req, res) {
- res.send('GET request to the homepage');
-});
+app.get('/', (req, res) => {
+ res.send('GET request to the homepage')
+})
// POST method route
-app.post('/', function (req, res) {
- res.send('POST request to the homepage');
-});
-
-
-
-Express unterstützt die folgenden Weiterleitungsmethoden, die den HTTP-Methoden entsprechen: `get`, `post`, `put`, `head`, `delete`, `options`, `trace`, `copy`, `lock`, `mkcol`, `move`, `purge`, `propfind`, `proppatch`, `unlock`, `report`, `mkactivity`, `checkout`, `merge`, `m-search`, `notify`, `subscribe`, `unsubscribe`, `patch`, `search` und `connect`.
+app.post('/', (req, res) => {
+ res.send('POST request to the homepage')
+})
+```
-
-
-app.all('/secret', function (req, res, next) {
- console.log('Accessing the secret section ...');
- next(); // pass control to the next handler
-});
-
-
+```js
+app.all('/secret', (req, res, next) => {
+ console.log('Accessing the secret section ...')
+ next() // pass control to the next handler
+})
+```
-
-app.get('/', function (req, res) {
- res.send('root');
-});
-
-
+```js
+app.get('/', (req, res) => {
+ res.send('root')
+})
+```
Dieser Weiterleitungspfad gleicht Anforderungen mit `/about` ab.
-
-
-app.get('/about', function (req, res) {
- res.send('about');
-});
-
-
+```js
+app.get('/about', (req, res) => {
+ res.send('about')
+})
+```
Dieser Weiterleitungspfad gleicht Anforderungen mit `/random.text` ab.
-
-
-app.get('/random.text', function (req, res) {
- res.send('random.text');
-});
-
-
+```js
+app.get('/random.text', (req, res) => {
+ res.send('random.text')
+})
+```
-Dies sind einige Beispiele für Weiterleitungspfade auf Basis von Zeichenfolgemustern.
+### Route paths based on string patterns
+
+{% capture caution-string-patterns %} The string patterns in Express 5 no longer work. Please refer to the [migration guide](/{{ page.lang }}/guide/migrating-5.html#path-syntax) for more information.{% endcapture %}
+
+{% include admonitions/caution.html content=caution-string-patterns %}
Dieser Weiterleitungspfad gleicht `acd` und `abcd` ab.
-
-
-app.get('/ab?cd', function(req, res) {
- res.send('ab?cd');
-});
-
-
-
-Dieser Weiterleitungspfad gleicht `abcd`, `abbcd`, `abbbcd` usw. ab.
-
-
-
-app.get('/ab+cd', function(req, res) {
- res.send('ab+cd');
-});
-
-
-
-Dieser Weiterleitungspfad gleicht `abcd`, `abxcd`, `abRABDOMcd`, `ab123cd` usw. ab.
-
-
-
-app.get('/ab*cd', function(req, res) {
- res.send('ab*cd');
-});
-
-
+```js
+app.get('/ab?cd', (req, res) => {
+ res.send('ab?cd')
+})
+```
+
+Dies sind einige Beispiele für Weiterleitungspfade auf Basis von Zeichenfolgemustern.
+
+```js
+app.get('/ab+cd', (req, res) => {
+ res.send('ab+cd')
+})
+```
+
+Dies sind einige Beispiele für Weiterleitungspfade auf Basis von Zeichenfolgen.
+
+```js
+app.get('/ab*cd', (req, res) => {
+ res.send('ab*cd')
+})
+```
Dieser Weiterleitungspfad gleicht `/abe` und `/abcde` ab.
-
-
-app.get('/ab(cd)?e', function(req, res) {
- res.send('ab(cd)?e');
-});
-
-
+```js
+app.get('/ab(cd)?e', (req, res) => {
+ res.send('ab(cd)?e')
+})
+```
+
+### Route paths based on regular expressions
-
-
-app.get(/a/, function(req, res) {
- res.send('/a/');
-});
-
-
+To have more control over the exact string that can be matched by a route parameter, you can append a regular expression in parentheses (`()`):
-Dieser Weiterleitungspfad gleicht `butterfly` und `dragonfly`, jedoch nicht `butterflyman`, `dragonfly man` usw. ab.
+```
+Route path: /user/:userId(\d+)
+Request URL: http://localhost:3000/user/42
+req.params: {"userId": "42"}
+```
-
-
-app.get(/.*fly$/, function(req, res) {
- res.send('/.*fly$/');
-});
-
-
+{% capture escape-advisory %}
+
+Because the regular expression is usually part of a literal string, be sure to escape any `\` characters with an additional backslash, for example `\\d+`.
+
+{% endcapture %}
+
+{% include admonitions/warning.html content=escape-advisory %}
+
+{% capture warning-version %}
+
+In Express 4.x, the `*` character in regular expressions is not interpreted in the usual way. As a workaround, use `{0,}` instead of `*`. This will likely be fixed in Express 5.
+
+{% endcapture %}
+
+{% include admonitions/warning.html content=warning-version %}
-
-app.get('/example/a', function (req, res) {
- res.send('Hello from A!');
-});
-
-
+```js
+app.get('/example/a', (req, res) => {
+ res.send('Hello from A!')
+})
+```
Mehrere Callback-Funktionen können eine Weiterleitung verarbeiten (achten Sie darauf, dass Sie das Objekt `next` angeben). Beispiel:
-
-
-app.get('/example/b', function (req, res, next) {
- console.log('the response will be sent by the next function ...');
- next();
-}, function (req, res) {
- res.send('Hello from B!');
-});
-
-
+```js
+app.get('/example/b', (req, res, next) => {
+ console.log('the response will be sent by the next function ...')
+ next()
+}, (req, res) => {
+ res.send('Hello from B!')
+})
+```
Ein Array von Callback-Funktionen kann eine Weiterleitung verarbeiten. Beispiel:
-
-
-var cb0 = function (req, res, next) {
- console.log('CB0');
- next();
+```js
+const cb0 = function (req, res, next) {
+ console.log('CB0')
+ next()
}
-var cb1 = function (req, res, next) {
- console.log('CB1');
- next();
+const cb1 = function (req, res, next) {
+ console.log('CB1')
+ next()
}
-var cb2 = function (req, res) {
- res.send('Hello from C!');
+const cb2 = function (req, res) {
+ res.send('Hello from C!')
}
-app.get('/example/c', [cb0, cb1, cb2]);
-
-
+app.get('/example/c', [cb0, cb1, cb2])
+```
Eine Kombination aus unabhängigen Funktionen und Funktionsarrays kann eine Weiterleitung verarbeiten. Beispiel:
-
-
-var cb0 = function (req, res, next) {
- console.log('CB0');
- next();
+```js
+const cb0 = function (req, res, next) {
+ console.log('CB0')
+ next()
}
-var cb1 = function (req, res, next) {
- console.log('CB1');
- next();
+const cb1 = function (req, res, next) {
+ console.log('CB1')
+ next()
}
-app.get('/example/d', [cb0, cb1], function (req, res, next) {
- console.log('the response will be sent by the next function ...');
- next();
-}, function (req, res) {
- res.send('Hello from D!');
-});
-
-
+app.get('/example/d', [cb0, cb1], (req, res, next) => {
+ console.log('the response will be sent by the next function ...')
+ next()
+}, (req, res) => {
+ res.send('Hello from D!')
+})
+```
-
+```js
app.route('/book')
- .get(function(req, res) {
- res.send('Get a random book');
+ .get((req, res) => {
+ res.send('Get a random book')
})
- .post(function(req, res) {
- res.send('Add a book');
+ .post((req, res) => {
+ res.send('Add a book')
})
- .put(function(req, res) {
- res.send('Update the book');
- });
-
-
+ .put((req, res) => {
+ res.send('Update the book')
+ })
+```
-
-var express = require('express');
-var router = express.Router();
+```js
+const express = require('express')
+const router = express.Router()
// middleware that is specific to this router
-router.use(function timeLog(req, res, next) {
- console.log('Time: ', Date.now());
- next();
-});
+const timeLog = (req, res, next) => {
+ console.log('Time: ', Date.now())
+ next()
+}
+router.use(timeLog)
+
// define the home page route
-router.get('/', function(req, res) {
- res.send('Birds home page');
-});
+router.get('/', (req, res) => {
+ res.send('Birds home page')
+})
// define the about route
-router.get('/about', function(req, res) {
- res.send('About birds');
-});
+router.get('/about', (req, res) => {
+ res.send('About birds')
+})
-module.exports = router;
-
-
+module.exports = router
+```
Laden Sie dann das Routermodul in die Anwendung:
-
-
-var birds = require('./birds');
-...
-app.use('/birds', birds);
-
-
+```js
+const birds = require('./birds')
+
+// ...
+
+app.use('/birds', birds)
+```
Die Anwendung kann nun Anforderungen an die Pfade `/birds` und `/birds/about` bearbeiten und ruft die Middlewarefunktion `timeLog` auf, die speziell für diese Weiterleitung bestimmt ist.
+
+But if the parent route `/birds` has path parameters, it will not be accessible by default from the sub-routes. To make it accessible, you will need to pass the `mergeParams` option to the Router constructor [reference](/{{ page.lang }}/5x/api.html#app.use).
+
+```js
+const router = express.Router({ mergeParams: true })
+```
diff --git a/de/guide/using-middleware.md b/de/guide/using-middleware.md
old mode 100755
new mode 100644
index a1eddb6b0a..0d1baea51c
--- a/de/guide/using-middleware.md
+++ b/de/guide/using-middleware.md
@@ -1,183 +1,229 @@
---
layout: page
title: Express-Middleware verwenden
+description: Learn how to use middleware in Express.js applications, including application-level and router-level middleware, error handling, and integrating third-party middleware.
menu: guide
-lang: de
+redirect_from: " "
---
# Middleware verwenden
Express ist ein Weiterleitungs- und Middleware-Web-Framework, das selbst nur minimale Funktionalität aufweist: Eine Express-Anwendung besteht im Wesentlichen aus einer Reihe von Middlewarefunktionsaufrufen.
-*Middlewarefunktionen* sind Funktionen, die Zugriff auf das [Anforderungsobjekt](/{{ page.lang }}/4x/api.html#req) (`req`), das [Antwortobjekt](/{{ page.lang }}/4x/api.html#res) (`res`) und die nächste Middlewarefunktion im Anforderung/Antwort-Zyklus der Anwendung haben. Die nächste Middlewarefunktion wird im Allgemeinen durch die Variable `next` bezeichnet.
+_Middleware_ functions are functions that have access to the [request object](/{{ page.lang }}/5x/api.html#req) (`req`), the [response object](/{{ page.lang }}/5x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. Die nächste Middlewarefunktion wird im Allgemeinen durch die Variable `next` bezeichnet.
Über Middlewarefunktionen lassen sich die folgenden Tasks ausführen:
-* Ausführen von Code
-* Vornehmen von Änderungen an der Anforderung und an Antwortobjekten
-* Beenden des Anforderung/Antwort-Zyklus
-* Aufrufen der nächsten Middlewarefunktion im Stack
+- Ausführen von Code
+- Vornehmen von Änderungen an der Anforderung und an Antwortobjekten
+- End the request-response cycle.
+- Aufrufen der nächsten Middlewarefunktion im Stack
Wenn über die aktuelle Middlewarefunktion der Anforderung/Antwort-Zyklus nicht beendet werden kann, muss `next()` aufgerufen werden, um die Steuerung an die nächste Middlewarefunktion zu übergeben. Andernfalls geht die Anforderung in den Status "Blockiert" über.
Eine Express-Anwendung kann die folgenden Middlewaretypen verwenden:
- - [Middleware auf Anwendungsebene](#middleware.application)
- - [Middleware auf Routerebene](#middleware.router)
- - [Middleware für die Fehlerbehandlung](#middleware.error-handling)
- - [Integrierte Middleware](#middleware.built-in)
- - [Middleware anderer Anbieter](#middleware.third-party)
+- [Middleware auf Anwendungsebene](#middleware.application)
+- [Middleware auf Routerebene](#middleware.router)
+- [Middleware für die Fehlerbehandlung](#middleware.error-handling)
+- [Integrierte Middleware](#middleware.built-in)
+- [Middleware anderer Anbieter](#middleware.third-party)
-Sie können Middleware auf Anwendungsebene und Routerebene mit einem optionalen Mountpfad laden. Sie können auch eine Reihe von Middlewarefunktionen zusammen laden. Dadurch wird ein Sub-Stack des Middlewaresystems am Mountpunkt erstellt.
+Sie können Middleware auf Anwendungsebene und Routerebene mit einem optionalen Mountpfad laden.
+Sie können auch eine Reihe von Middlewarefunktionen zusammen laden. Dadurch wird ein Sub-Stack des Middlewaresystems am Mountpunkt erstellt.
-
-var app = express();
+```js
+const express = require('express')
+const app = express()
-app.use(function (req, res, next) {
- console.log('Time:', Date.now());
- next();
-});
-
-
+app.use((req, res, next) => {
+ console.log('Time:', Date.now())
+ next()
+})
+```
Dieses Beispiel zeigt eine Middlewarefunktion mit dem Mountpfad `/user/:id`. Die Funktion wird für jede Art von HTTP-Anforderung auf dem Pfad `/user/:id` ausgeführt.
-
-
-app.use('/user/:id', function (req, res, next) {
- console.log('Request Type:', req.method);
- next();
-});
-
-
+```js
+app.use('/user/:id', (req, res, next) => {
+ console.log('Request Type:', req.method)
+ next()
+})
+```
Dieses Beispiel zeigt eine Weiterleitung und deren Handlerfunktion (Middlewaresystem). Die Funktion verarbeitet GET-Anforderungen zum Pfad `/user/:id`.
-
-
-app.get('/user/:id', function (req, res, next) {
- res.send('USER');
-});
-
-
-
-Dies ist ein Beispiel zum Laden einer Reihe von Middlewarefunktionen an einem Mountpunkt mit einem Mountpfad. Das Beispiel veranschaulicht einen Middleware-Stack, über den Anforderungsinformationen zu einer HTTP-Anforderung zum Pfad `/user/:id` ausgegeben werden.
-
-
-
-app.use('/user/:id', function(req, res, next) {
- console.log('Request URL:', req.originalUrl);
- next();
-}, function (req, res, next) {
- console.log('Request Type:', req.method);
- next();
-});
-
-
+```js
+app.get('/user/:id', (req, res, next) => {
+ res.send('USER')
+})
+```
+
+Dies ist ein Beispiel zum Laden einer Reihe von Middlewarefunktionen an einem Mountpunkt mit einem Mountpfad.
+Das Beispiel veranschaulicht einen Middleware-Stack, über den Anforderungsinformationen zu einer HTTP-Anforderung zum Pfad `/user/:id` ausgegeben werden.
+
+```js
+app.use('/user/:id', (req, res, next) => {
+ console.log('Request URL:', req.originalUrl)
+ next()
+}, (req, res, next) => {
+ console.log('Request Type:', req.method)
+ next()
+})
+```
Mit einem Routenhandler können Sie mehrere Weiterleitungen für einen Pfad definieren. Im folgenden Beispiel werden zwei Weiterleitungen für GET-Anforderungen zum Pfad `/user/:id` definiert. Die zweite Weiterleitung verursacht zwar keine Probleme, wird jedoch nie aufgerufen, da durch die erste Weiterleitung der Anforderung/Antwort-Zyklus beendet wird.
Dieses Beispiel zeigt einen Middleware-Sub-Stack, über den GET-Anforderungen zum Pfad `/user/:id` verarbeitet werden.
-
-
-app.get('/user/:id', function (req, res, next) {
- console.log('ID:', req.params.id);
- next();
-}, function (req, res, next) {
- res.send('User Info');
-});
+```js
+app.get('/user/:id', (req, res, next) => {
+ console.log('ID:', req.params.id)
+ next()
+}, (req, res, next) => {
+ res.send('User Info')
+})
// handler for the /user/:id path, which prints the user ID
-app.get('/user/:id', function (req, res, next) {
- res.end(req.params.id);
-});
-
-
+app.get('/user/:id', (req, res, next) => {
+ res.send(req.params.id)
+})
+```
-Wenn Sie den Rest der Middlewarefunktionen eines Weiterleitungs-Middleware-Stack überspringen wollen, rufen Sie `next('route')` auf, um die Steuerung an die nächste Weiterleitung zu übergeben. **HINWEIS**: `next('route')` funktioniert nur in Middlewarefunktionen, die über die Funktionen `app.METHOD()` oder `router.METHOD()` geladen wurden.
+Wenn Sie den Rest der Middlewarefunktionen eines Weiterleitungs-Middleware-Stack überspringen wollen, rufen Sie `next('route')` auf, um die Steuerung an die nächste Weiterleitung zu übergeben.
+
+{% capture next-function %}
+
+`next('route')` will work only in middleware functions that were loaded by using the `app.METHOD()` or `router.METHOD()` functions.
+
+{% endcapture %}
+
+{% include admonitions/note.html content=next-function %}
Dieses Beispiel zeigt einen Middleware-Sub-Stack, über den GET-Anforderungen zum Pfad `/user/:id` verarbeitet werden.
-
-
-app.get('/user/:id', function (req, res, next) {
+```js
+app.get('/user/:id', (req, res, next) => {
// if the user ID is 0, skip to the next route
- if (req.params.id == 0) next('route');
+ if (req.params.id === '0') next('route')
// otherwise pass the control to the next middleware function in this stack
- else next(); //
-}, function (req, res, next) {
- // render a regular page
- res.render('regular');
-});
+ else next()
+}, (req, res, next) => {
+ // send a regular response
+ res.send('regular')
+})
-// handler for the /user/:id path, which renders a special page
-app.get('/user/:id', function (req, res, next) {
- res.render('special');
-});
-
-
+// handler for the /user/:id path, which sends a special response
+app.get('/user/:id', (req, res, next) => {
+ res.send('special')
+})
+```
+
+Middleware can also be declared in an array for reusability.
+
+Dies ist ein Beispiel zur Verwendung der Middlewarefunktion `express.static` mit einem ausführlich dargestellten Optionsobjekt:
+
+```js
+function logOriginalUrl (req, res, next) {
+ console.log('Request URL:', req.originalUrl)
+ next()
+}
+
+function logMethod (req, res, next) {
+ console.log('Request Type:', req.method)
+ next()
+}
+
+const logStuff = [logOriginalUrl, logMethod]
+app.get('/user/:id', logStuff, (req, res, next) => {
+ res.send('User Info')
+})
+```
-
-var router = express.Router();
-
-
+```js
+const router = express.Router()
+```
+
Laden Sie Middleware auf Routerebene über die Funktionen `router.use()` und `router.METHOD()`.
+
Der folgende Beispielcode repliziert das Middlewaresystem, das oben für die Middleware auf Anwendungsebene gezeigt wird, durch Verwendung von Middleware auf Routerebene.
-
-
-var app = express();
-var router = express.Router();
+```js
+const express = require('express')
+const app = express()
+const router = express.Router()
// a middleware function with no mount path. This code is executed for every request to the router
-router.use(function (req, res, next) {
- console.log('Time:', Date.now());
- next();
-});
+router.use((req, res, next) => {
+ console.log('Time:', Date.now())
+ next()
+})
// a middleware sub-stack shows request info for any type of HTTP request to the /user/:id path
-router.use('/user/:id', function(req, res, next) {
- console.log('Request URL:', req.originalUrl);
- next();
-}, function (req, res, next) {
- console.log('Request Type:', req.method);
- next();
-});
+router.use('/user/:id', (req, res, next) => {
+ console.log('Request URL:', req.originalUrl)
+ next()
+}, (req, res, next) => {
+ console.log('Request Type:', req.method)
+ next()
+})
// a middleware sub-stack that handles GET requests to the /user/:id path
-router.get('/user/:id', function (req, res, next) {
+router.get('/user/:id', (req, res, next) => {
// if the user ID is 0, skip to the next router
- if (req.params.id == 0) next('route');
+ if (req.params.id === '0') next('route')
// otherwise pass control to the next middleware function in this stack
- else next(); //
-}, function (req, res, next) {
+ else next()
+}, (req, res, next) => {
// render a regular page
- res.render('regular');
-});
+ res.render('regular')
+})
// handler for the /user/:id path, which renders a special page
-router.get('/user/:id', function (req, res, next) {
- console.log(req.params.id);
- res.render('special');
-});
+router.get('/user/:id', (req, res, next) => {
+ console.log(req.params.id)
+ res.render('special')
+})
// mount the router on the app
-app.use('/', router);
-
-
+app.use('/', router)
+```
+
+To skip the rest of the router's middleware functions, call `next('router')`
+to pass control back out of the router instance.
+
+Dieses Beispiel zeigt einen Middleware-Sub-Stack, über den GET-Anforderungen zum Pfad `/user/:id` verarbeitet werden.
+
+```js
+const express = require('express')
+const app = express()
+const router = express.Router()
+
+// predicate the router with a check and bail out when needed
+router.use((req, res, next) => {
+ if (!req.headers['x-auth']) return next('router')
+ next()
+})
+
+router.get('/user/:id', (req, res) => {
+ res.send('hello, user!')
+})
+
+// use the router and 401 anything falling through
+app.use('/admin', router, (req, res) => {
+ res.sendStatus(401)
+})
+```
-
-app.use(function(err, req, res, next) {
- console.error(err.stack);
- res.status(500).send('Something broke!');
-});
-
-
+```js
+app.use((err, req, res, next) => {
+ console.error(err.stack)
+ res.status(500).send('Something broke!')
+})
+```
Details zu Middleware für die Fehlerbehandlung siehe [Fehlerbehandlung](/{{ page.lang }}/guide/error-handling.html).
@@ -202,56 +246,11 @@ Details zu Middleware für die Fehlerbehandlung siehe [Fehlerbehandlung](/{{ pag
Seit Version 4.x bestehen bei Express keine Abhängigkeiten zu [Connect](https://github.com/senchalabs/connect) mehr. Mit Ausnahme von `express.static` befinden sich nun alle Middlewarefunktionen, die bisher in Express enthalten waren, in separaten Modulen. Sehen Sie sich hierzu auch die [Liste der Middlewarefunktionen](https://github.com/senchalabs/connect#middleware) an.
-
-
-var options = {
- dotfiles: 'ignore',
- etag: false,
- extensions: ['htm', 'html'],
- index: false,
- maxAge: '1d',
- redirect: false,
- setHeaders: function (res, path, stat) {
- res.set('x-timestamp', Date.now());
- }
-}
-
-app.use(express.static('public', options));
-
-
-
-Es sind mehrere statische Verzeichnisse pro Anwendung möglich:
-
-
-
-app.use(express.static('public'));
-app.use(express.static('uploads'));
-app.use(express.static('files'));
-
-
+Die einzige integrierte Middlewarefunktion in Express ist `express.static`.
-Details zur Funktion `serve-static` und deren Optionen finden Sie in der Dokumentation zu [serve-static](https://github.com/expressjs/serve-static).
+- [express.static](/en/5x/api.html#express.static) serves static assets such as HTML files, images, and so on.
+- [express.json](/en/5x/api.html#express.json) parses incoming requests with JSON payloads. **NOTE: Available with Express 4.16.0+**
+- [express.urlencoded](/en/5x/api.html#express.urlencoded) parses incoming requests with URL-encoded payloads. **NOTE: Available with Express 4.16.0+**
-
+```bash
$ npm install cookie-parser
-
-
+```
-
-
-var express = require('express');
-var app = express();
-var cookieParser = require('cookie-parser');
+```js
+const express = require('express')
+const app = express()
+const cookieParser = require('cookie-parser')
// load the cookie-parsing middleware
-app.use(cookieParser());
-
-
+app.use(cookieParser())
+```
Eine nicht vollständige Liste zu den Middlewarefunktionen anderer Anbieter, die im Allgemeinen mit Express verwendet werden, finden Sie unter [Middleware anderer Anbieter](../resources/middleware.html).
diff --git a/de/guide/using-template-engines.md b/de/guide/using-template-engines.md
old mode 100755
new mode 100644
index 5850860b81..abce1f7ffd
--- a/de/guide/using-template-engines.md
+++ b/de/guide/using-template-engines.md
@@ -1,59 +1,61 @@
---
layout: page
title: Template-Engines in Express verwenden
+description: Discover how to integrate and use template engines like Pug, Handlebars, and EJS with Express.js to render dynamic HTML pages efficiently.
menu: guide
-lang: de
+redirect_from: " "
---
# Template-Engines in Express verwenden
-Bevor über Express Vorlagendateien ausgegeben werden können, müssen die folgenden Anwendungseinstellungen festgelegt werden:
+A _template engine_ enables you to use static template files in your application. At runtime, the template engine replaces
+variables in a template file with actual values, and transforms the template into an HTML file sent to the client.
+This approach makes it easier to design an HTML page.
-* `views`, das Verzeichnis, in dem sich die Vorlagendateien befinden. Beispiel: `app.set('views', './views')`
-* `view engine`, die zu verwendende Template-Engine. Beispiel: `app.set('view engine', 'pug')`
+The [Express application generator](/{{ page.lang }}/starter/generator.html) uses [Pug](https://pugjs.org/api/getting-started.html) as its default, but it also supports [Handlebars](https://www.npmjs.com/package/handlebars), and [EJS](https://www.npmjs.com/package/ejs), among others.
+
+To render template files, set the following [application setting properties](/{{ page.lang }}/4x/api.html#app.set), in the default `app.js` created by the generator:
+
+- `views`, das Verzeichnis, in dem sich die Vorlagendateien befinden. Beispiel: `app.set('views', './views')`
+ This defaults to the `views` directory in the application root directory.
+- `view engine`, die zu verwendende Template-Engine. Beispiel: `app.set('view engine', 'pug')`
Installieren Sie dann das entsprechende npm-Paket für die Template-Engine:
-
-
+```bash
$ npm install pug --save
-
-
+```
+
+
-
-app.set('view engine', 'pug');
-
-
+```js
+app.set('view engine', 'pug')
+```
Erstellen Sie eine Pug-Vorlagendatei namens `index.pug` im Verzeichnis `views` mit dem folgenden Inhalt:
-
-
+```pug
html
head
title= title
body
h1= message
-
-
+```
Dann erstellen Sie eine Weiterleitung, um die Datei `index.pug` auszugeben. Wenn die Eigenschaft `view engine` nicht festgelegt wurde, müssen Sie die Erweiterung der Datei `view` angeben. Andernfalls müssen Sie diese Erweiterung nicht angeben.
-
-
-app.get('/', function (req, res) {
- res.render('index', { title: 'Hey', message: 'Hello there!'});
-});
-
-
+```js
+app.get('/', (req, res) => {
+ res.render('index', { title: 'Hey', message: 'Hello there!' })
+})
+```
Wenn Sie eine Anforderung zur Homepage ausführen, wird die Datei `index.pug` im HTML-Format ausgegeben.
-Weitere Informationen zur Funktionsweise von Template-Engines in Express siehe ["Template-Engines für Express entwickeln"](/{{ page.lang }}/advanced/developing-template-engines.html).
+The view engine cache does not cache the contents of the template's output, only the underlying template itself. The view is still re-rendered with every request even when the cache is on.
diff --git a/de/guide/writing-middleware.md b/de/guide/writing-middleware.md
old mode 100755
new mode 100644
index 283fbeaac8..c4d5653244
--- a/de/guide/writing-middleware.md
+++ b/de/guide/writing-middleware.md
@@ -1,33 +1,35 @@
---
layout: page
title: Middleware für die Verwendung in Express-Anwendungen schreiben
+description: Learn how to write custom middleware functions for Express.js applications, including examples and best practices for enhancing request and response handling.
menu: guide
-lang: de
+redirect_from: " "
---
# Middleware für die Verwendung in Express-Anwendungen schreiben
-![]()
+
+
+Starting with Express 5, middleware functions that return a Promise will call `next(value)` when they reject or throw an error. `next` will be called with either the rejected value or the thrown Error.
-Dies ist ein Beispiel einer einfachen Express-Anwendung namens "Hello World", für die Sie zwei Middlewarefunktionen definieren:
+
Beispiel-
+app.get('/', (req, res) => {
+ res.send('Hello World!')
+})
-Entwicklung+app.listen(3000) +``` +Dies ist ein Beispiel einer einfachen Express-Anwendung namens "Hello World", für die Sie zwei Middlewarefunktionen definieren:Dies ist ein einfaches Beispiel einer Middlewarefunktion namens "myLogger". Diese Funktion gibt lediglich "LOGGED" aus, wenn eine Anforderung zur Anwendung über diese Funktion läuft. Die Middlewarefunktion ist der Variablen `myLogger` zugeordnet. -
-
+```js
+const myLogger = function (req, res, next) {
+ console.log('LOGGED')
+ next()
+}
+```
-Beachten Sie den Aufruf oben zu `next()`. Durch den Aufruf dieser Funktion wird die nächste Middlewarefunktion in der Anwendung aufgerufen. Die Funktion `next()` ist nicht Teil der Node.js- oder Express-API, sondern das dritte Argument, das an die Middlewarefunktion übergeben wird. Die Funktion `next()` kann jeden beliebigen Namen haben, per Konvention erhält sie jedoch immer den Namen "next". Um Unklarheiten zu vermeiden, sollten Sie immer diese Konvention verwenden.
+Beachten Sie den Aufruf oben zu `next()`. Durch den Aufruf dieser Funktion wird die nächste Middlewarefunktion in der Anwendung aufgerufen.
+Die Funktion `next()` ist nicht Teil der Node.js- oder Express-API, sondern das dritte Argument, das an die Middlewarefunktion übergeben wird. Die Funktion `next()` kann jeden beliebigen Namen haben, per Konvention erhält sie jedoch immer den Namen "next".
+Um Unklarheiten zu vermeiden, sollten Sie immer diese Konvention verwenden.
+Zum Laden der Middlewarefunktion rufen Sie `app.use()` auf und geben die Middlewarefunktion an.
+Beispiel: Durch den folgenden Code wird die Middlewarefunktion `myLogger` vor der Weiterleitung zum Stammverzeichnispfad (/) geladen.
-Zum Laden der Middlewarefunktion rufen Sie `app.use()` auf und geben die Middlewarefunktion an. Beispiel: Durch den folgenden Code wird die Middlewarefunktion `myLogger` vor der Weiterleitung zum Stammverzeichnispfad (/) geladen.
+```js
+const express = require('express')
+const app = express()
-
-
+app.listen(3000)
+```
Sobald die Anwendung eine Anforderung erhält, gibt sie die Nachricht "LOGGED" an das Terminal aus.
@@ -102,43 +109,112 @@ Wenn `myLogger` nach der Weiterleitung zum Stammverzeichnispfad geladen wird, er
Die Middlewarefunktion `myLogger` gibt einfach eine Nachricht aus und übergibt dann die Anforderung zur nächsten Middlewarefunktion im Stack durch Aufruf der Funktion `next()`.
+Middleware function requestTime+ Im nächsten Beispiel wird die Eigenschaft `requestTime` zum Anforderungsobjekt hinzugefügt. Diese Middlewarefunktion erhält den Namen "requestTime". -
-
+```js
+const requestTime = function (req, res, next) {
+ req.requestTime = Date.now()
+ next()
+}
+```
Die Anwendung verwendet nun die Middlewarefunktion `requestTime`. Außerdem verwendet die Callback-Funktion der Weiterleitung zum Stammverzeichnispfad die Eigenschaft, die die Middlewarefunktion zu `req` (dem Anforderungsobjekt) hinzufügt.
-
-
+app.listen(3000)
+```
Wenn Sie eine Anforderung zum Stammverzeichnis der Anwendung einleiten, zeigt die Anwendung nun die Zeitmarke Ihrer Anforderung im Browser an.
+Middleware function validateCookies+ +Finally, we'll create a middleware function that validates incoming cookies and sends a 400 response if cookies are invalid. + +Here's an example function that validates cookies with an external async service. + +```js +async function cookieValidator (cookies) { + try { + await externallyValidateCookie(cookies.testCookie) + } catch { + throw new Error('Invalid cookies') + } +} +``` + +Here, we use the [`cookie-parser`](/resources/middleware/cookie-parser.html) middleware to parse incoming cookies off the `req` object and pass them to our `cookieValidator` function. The `validateCookies` middleware returns a Promise that upon rejection will automatically trigger our error handler. + +```js +const express = require('express') +const cookieParser = require('cookie-parser') +const cookieValidator = require('./cookieValidator') + +const app = express() + +async function validateCookies (req, res, next) { + await cookieValidator(req.cookies) + next() +} + +app.use(cookieParser()) + +app.use(validateCookies) + +// error handler +app.use((err, req, res, next) => { + res.status(400).send(err.message) +}) + +app.listen(3000) +``` + +
+Note how `next()` is called after `await cookieValidator(req.cookies)`. This ensures that if `cookieValidator` resolves, the next middleware in the stack will get called. If you pass anything to the `next()` function (except the string `'route'` or `'router'`), Express regards the current request as being an error and will skip any remaining non-error handling routing and middleware functions.
+
+
Da Sie Zugriff auf das Anforderungsobjekt, das Antwortobjekt, die nächste Middlewarefunktion im Stack und die gesamte Node.js-API haben, sind die Möglichkeiten, die Sie mit Middlewarefunktionen haben, nahezu unendlich.
Weitere Informationen zur Verwendung von Middleware in Express siehe [ Express-Middleware verwenden](/{{ page.lang }}/guide/using-middleware.html).
+
+Configurable middleware+ +If you need your middleware to be configurable, export a function which accepts an options object or other parameters, which, then returns the middleware implementation based on the input parameters. + +File: `my-middleware.js` + +```js +module.exports = function (options) { + return function (req, res, next) { + // Implement the middleware function based on the options object + next() + } +} +``` + +The middleware can now be used as shown below. + +```js +const mw = require('./my-middleware.js') + +app.use(mw({ option1: '1', option2: '2' })) +``` + +Refer to [cookie-session](https://github.com/expressjs/cookie-session) and [compression](https://github.com/expressjs/compression) for examples of configurable middleware. diff --git a/de/index.md b/de/index.md index a52f08bb5b..ffacc291f9 100644 --- a/de/index.md +++ b/de/index.md @@ -1,50 +1,61 @@ --- layout: home -title: Express - Node.js-Framework von Webanwendungen +title: Express - Node.js Web Application Framework +description: "Express is a fast, unopinionated, minimalist web framework for Node.js, providing a robust set of features for web and mobile applications." menu: home -lang: de +redirect_from: " " --- +
+ Fast, unopinionated, minimalist web framework for Node.js$ npm install express --save
-
-
+
-
-
+
-
-
-
-
-
- WebanwendungenExpress ist ein einfaches und flexibles Node.js-Framework von Webanwendungen, das zahlreiche leistungsfähige Features und Funktionen für Webanwendungen und mobile Anwendungen bereitstellt. -
-
+app.get('/', (req, res) => {
+ res.send('Hello World!')
+})
- APIsMithilfe unzähliger HTTP-Dienstprogrammmethoden und Middlewarefunktionen gestaltet sich das Erstellen einer leistungsfähigen API schnell und einfach.
-
+app.listen(port, () => {
+ console.log(`Example app listening on port ${port}`)
+})
+```
-
LeistungExpress bietet eine Thin-Layer-Ebene mit grundlegenden Webanwendungsfunktionen, ohne die bekannten Node.js-Features zu überlagern.
+
+
+
-Erstellen Sie zunächst ein Verzeichnis namens `myapp`, wechseln Sie in das Verzeichnis und führen Sie `npm init` aus. Installieren Sie dann `express` als Abhängigkeit, wie im [Installationshandbuch](/{{ page.lang }}/starter/installing.html) beschrieben.
-
-Erstellen Sie im Verzeichnis `myapp` eine Datei namens `app.js` und fügen Sie den folgenden Code hinzu:
-
-
+
\ No newline at end of file
diff --git a/de/resources/contributing.md b/de/resources/contributing.md
new file mode 100644
index 0000000000..e37cee3122
--- /dev/null
+++ b/de/resources/contributing.md
@@ -0,0 +1,466 @@
+---
+layout: page
+title: Contributing to Express
+description: Find out how to contribute to Express.js, including guidelines for reporting issues, submitting pull requests, becoming a collaborator, and understanding security policies.
+menu: resources
+redirect_from: " "
+---
+
+# Contributing to Express
+
+### Looking to contribute to Expressjs.com? Click [here](#expressjs-website-contributing).
+
+Express and the other projects in the [expressjs organization on GitHub](https://github.com/expressjs) are projects of the [OpenJs Foundation](https://openjsf.org/).
+These projects are governed under the general policies and guidelines of the Node.js Foundation along with the additional guidelines below.
+
+- [Technical committee](#technical-committee)
+- [Community contributing guide](#community-contributing-guide)
+- [Collaborator's guide](#collaborators-guide)
+- [Security policies and procedures](#security-policies-and-procedures)
+
+## Technical committee
+
+The Express technical committee consists of active project members, and guides development and maintenance of the Express project. For more information, see [Express Community - Technical committee](community.html#technical-committee).
+
+## Community contributing guide
+
+
+
+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](https://github.com/expressjs/discussions/blob/master/docs/contributing/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. If you feel ready and have been helping triage some issues, reach out to an active member of the organization to ask if they'd
+be willing to support you. If they agree, they can create a pull request to formalize your nomination. In the case of an objection to the nomination, the triage team is responsible for working with the individuals involved and finding a resolution.
+
+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 have landed significant and valuable contributions should be onboarded 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 an existing captain on the **same** repo can nominate another committer
+to the captain role. To do so, they should submit a PR to this document, updating the
+**Active Project Captains** section (while maintaining the sort order) with the project
+name, the nominee's GitHub handle, and their npm username (if different).
+
+- Repos can have as many captains as make sense for the scope of work.
+- A TC member or an existing repo captain **on the same project** can nominate a new captain.
+ Repo captains from other projects should not nominate captains for a different project.
+
+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
+
+The list can be found at [https://github.com/expressjs/discussions/blob/HEAD/docs/contributing/captains_and_committers.md#active-projects-and-members](https://github.com/expressjs/discussions/blob/HEAD/docs/contributing/captains_and_committers.md#active-projects-and-members)
+
+#### Current Initiative Captains
+
+The list can be found at [https://github.com/expressjs/discussions/blob/HEAD/docs/contributing/captains_and_committers.md#current-initiative-captains](https://github.com/expressjs/discussions/blob/HEAD/docs/contributing/captains_and_committers.md#current-initiative-captains)
+
+### Developer's Certificate of Origin 1.1
+
+```text
+By making a contribution to this project, I certify that:
+
+ (a) The contribution was created in whole or in part by me and I
+ have the right to submit it under the open source license
+ indicated in the file; or
+
+ (b) The contribution is based upon previous work that, to the best
+ of my knowledge, is covered under an appropriate open source
+ license and I have the right under that license to submit that
+ work with modifications, whether created in whole or in part
+ by me, under the same open source license (unless I am
+ permitted to submit under a different license), as indicated
+ in the file; or
+
+ (c) The contribution was provided directly to me by some other
+ person who certified (a), (b) or (c) and I have not modified
+ it.
+
+ (d) I understand and agree that this project and the contribution
+ are public and that a record of the contribution (including all
+ personal information I submit with it, including my sign-off) is
+ maintained indefinitely and may be redistributed consistent with
+ this project or the open source license(s) involved.
+```
+
+## Collaborator's guide
+
+
+
+### Website Issues
+
+Open issues for the expressjs.com website in https://github.com/expressjs/expressjs.com.
+
+For issues in other Express managed repos (everything in `expressjs`, `pillarjs` or `jshttp` other than `expressjs/express`), be sure to check their contributing guide and open issues and PRs in the appropriate repository.
+
+### PRs and Code contributions
+
+- Tests must pass.
+- Follow the [JavaScript Standard Style](https://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. `6.x`, for anything intended for
+a future release of Express.
+
+### Steps for contributing
+
+1. Create an issue for the
+ bug you want to fix or the feature that you want to add.
+2. Create your own fork 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.
+
+If your question meets all of the above requirements but you do not believe it needs to be looked at
+by the maintainers
+(for example, if you are just looking for community input) please open it as a discussion topic instead
+of an issue. If you
+are unsure and open an issue, we may move it to discussions if we triage them and decide they do
+not need high
+visibility or maintainer input.
+
+## 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 `express-security@lists.openjsf.org`.
+
+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.
+
+----
+
+# Contributing to Expressjs.com {#expressjs-website-contributing}
+
+
+
+### The Official Documentation of the Express JS Framework
+
+This is the contribution documentation for the [expressjs.com](https://github.com/expressjs/expressjs.com) website.
+
+#### Need some ideas? These are some typical issues.
+
+1. **Website issues**: If you see anything on the site that could use a tune-up, think about how to fix it.
+ - Display or screen sizing problems
+ - Mobile responsiveness issues
+ - Missing or broken accessibility features
+ - Website outages
+ - Broken links
+ - Page structure or user interface enhancements
+
+2. **Content Issues**: Fix anything related to site content or typos.
+ - Spelling errors
+ - Incorrect/outdated Express JS documentation
+ - Missing content
+
+3. **Translation Issues**: Fix any translation errors or contribute new content.
+ - Fix spelling errors
+ - Fix incorrect/poorly translated words
+ - Check out the [Contributing translations](#contributing-translations) section below for a contributing guide.
+
+#### Want to work on a backlog issue?
+
+We often have bugs or enhancements that need work. You can find these under our repo's [Issues tab](https://github.com/expressjs/expressjs.com/issues). Check out the tags to find something that's a good match for you.
+
+#### Have an idea? Found a bug?
+
+If you've found a bug or a typo, or if you have an idea for an enhancement, you can:
+
+- Submit a [new issue](https://github.com/expressjs/expressjs.com/issues/new/choose) on our repo. Do this for larger proposals, or if you'd like to discuss or get feedback first.
+
+- Make a [Github pull request](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/creating-a-pull-request). If you have already done work and it's ready to go, feel free to send it our way.
+
+## Getting Started
+
+The steps below will guide you through the Expressjs.com contribution process.
+
+#### Step 1: (OPTIONAL) Open a New Issue
+
+So you've found a problem that you want to fix, or have a site enhancement you want to make.
+
+1. If you want to get feedback or discuss, open a discussion [issue](https://github.com/expressjs/expressjs.com/issues/new/choose) prior to starting work. This is not required, but encouraged for larger proposals.
+ - While we highly encourage this step, it is only for submissions proposing significant change. It helps us to clarify and focus the work, and ensure it aligns with overall project priorities.
+ - For submissions proposing minor improvements or corrections, this is not needed. You can skip this step.
+ - When opening an issue please give it a title and fill in the description section. The more details you provide, the more feedback we can give.
+
+2. After receiving your issue the Express JS documentation team will respond with feedback. We read every submission and always try to respond quickly with feedback.
+ - For submissions proposing significant change, we encourage you to follow the review process before starting work.
+
+#### Step 2: Get the Application Code Base
+
+Clone the repo and get the code:
+
+```sh
+git clone https://github.com/expressjs/expressjs.com.git
+```
+
+After you've got the code you're ready to start making your changes!
+
+But just in case you need a little extra explanation, this section below outlines the main sections of the code base, where most changes are likely to be made.
+
+**Markdown Page Files**:
+
+- These files render to html and make up the individual pages of the site. Most of the site's documentation text content is written in `md` files.
+- Change these to make changes to individual pages' content/text or markup.
+- Each language has its own complete set of pages, located under their respective language directories - all the Spanish markdown content is found in the `es` directory, for example.
+
+**Includes Partials and Layout Templates**
+
+- `_includes` are partials that are imported and reused across multiple pages.
+ - These are used to import text content for reuse across pages, such as the API documentation, e.g., `_includes > api > en > 5x`, which is included in every language.
+ - These are used to include the page components that make up site-wide user interface and periphery structure, e.g., Header, Footer, etc.
+- `_layouts` are the templates used to wrap the site's individual pages.
+ - These are used to display the structure of the site's periphery, such as the header and footer, and for injecting and displaying individual markdown pages inside the `content` tag.
+
+**Blog Markdown Files**
+
+- These files make up the individual blog posts. If you want to contribute a blog post please
+ follow the specific instructions for [How to write a blog post.](https://expressjs.com/en/blog/write-post.html)
+- Located under the `_posts` directory.
+
+**CSS or Javascript**
+
+- All css and js files are kept in `css` and `js` folders on the project root.
+
+The Express JS website is built using [Jekyll](https://jekyllrb.com/) and is hosted on [Github Pages](https://pages.github.com/).
+
+#### Step 3: Running the Application
+
+Now you'll need a way to see your changes, which means you'll need a running version of the application. You have two options.
+
+1. **Run Locally**: This gets the local version of the application up and running on your machine. Follow our [Local Setup Guide](https://github.com/expressjs/expressjs.com?tab=readme-ov-file#build-the-website-locally) to use this option.
+ - This is the recommended option for moderate to complex work.
+
+2. **Run using Deploy Preview**: Use this option if you don't want to bother with a local installation. Part of our continuous integration pipeline includes [Netlify Deploy Preview](https://docs.netlify.com/site-deploys/deploy-previews/).
+ 1. To use this you'll need to get your changes online - after you've made your first commit on your feature branch, make a _draft_ pull request.
+ 2. After the build steps are complete, you'll have access to a **Deploy Preview** tab that will run your changes on the web, rebuilding after each commit is pushed.
+ 3. After you are completely done your work and it's ready for review, remove the draft status on your pull request and submit your work.
+
+## Contributing translations
+
+We use Crowdin to manage our translations in multiple languages and achieve automatic translation with artificial intelligence. Since these translations can be inefficient in some cases, we need help from the community to provide accurate and helpful translations.
+
+The documentation is translated into these languages:
+
+- Chinese Simplified (`zh-cn`)
+- Chinese Traditional (`zh-tw`)
+- English (`en`)
+- French (`fr`)
+- German (`de`)
+- Italian (`it`)
+- Japanese (`ja`)
+- Korean (`ko`)
+- Brazilian Portuguese (`pt-br`)
+- Spanish (`es`)
+
+### How to translate
+
+1. Request to join the Express.js Website project on [Crowdin](https://express.crowdin.com/website)
+2. [Select the language you want to translate](https://support.crowdin.com/joining-translation-project/#starting-translation)
+3. [Start translating](https://support.crowdin.com/online-editor/)
+
diff --git a/de/resources/glossary.md b/de/resources/glossary.md
old mode 100755
new mode 100644
index 71f78f6ef1..991a7a584a
--- a/de/resources/glossary.md
+++ b/de/resources/glossary.md
@@ -1,23 +1,16 @@
---
layout: page
title: Express-Glossar
+description: A comprehensive glossary of terms related to Express.js, Node.js, middleware, routing, and other key concepts to help you understand and use Express effectively.
menu: resources
-lang: de
+redirect_from: " "
---
# Glossar
-### Anforderung
-
-Eine HTTP-Anforderung. Ein Client übergibt eine HTTP-Anforderungsnachricht an einen Server, der wiederum eine Antwort zurückgibt. Bei der Anforderung muss eine der [Anforderungsmethoden](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods) wie GET, POST usw. verwendet werden.
-
-### Antwort
-
-Eine HTTP-Antwort. Ein Server gibt eine HTTP-Antwortnachricht an den Client zurück. Die Antwort enthält Informationen zum Beendigungsstatus in Bezug auf die Anforderung und kann im Nachrichtenhauptteil auch angeforderten Inhalt enthalten.
-
### Anwendung
-Im Allgemeinen besteht eine Anwendung aus einem oder mehreren Programmen, über die Operationen für bestimmte Zwecke ausgeführt werden. Im Zusammenhang mit Express ist eine Anwendung ein Programm, das die auf der Node.js-Plattform laufende Express-API nutzt. Wird auch als [Anwendungsobjekt](/{{ page.lang }}/api.html#express) bezeichnet.
+Im Allgemeinen besteht eine Anwendung aus einem oder mehreren Programmen, über die Operationen für bestimmte Zwecke ausgeführt werden. Im Zusammenhang mit Express ist eine Anwendung ein Programm, das die auf der Node.js-Plattform laufende Express-API nutzt. Wird auch als [Anwendungsobjekt](/{{ page.lang }}/api.html#express) bezeichnet.
### API
@@ -31,26 +24,42 @@ Schnelles, offenes, unkompliziertes Web-Framework für Node.js-Anwendungen. Im A
Eine plattformübergreifende Unterstützungsbibliothek, bei der die asynchrone Ein-/Ausgabe im Mittelpunkt steht. Sie wurde in erster Linie für die Verwendung in Node.js entwickelt.
-### Middleware
+### middleware
Eine Funktion, die über die Weiterleitungsebene in Express vor dem letzten Anforderungshandler aufgerufen wird. Deshalb befindet sich diese Funktion in der Mitte zwischen einer unformatierten Anforderung und der endgültigen beabsichtigten Weiterleitung. Nachfolgend finden Sie einige Details zur Middlewareterminologie:
- * `var foo = require('middleware')` bedeutet, dass ein Node.js-Modul *benötigt* oder *verwendet* wird. Dann gibt die Anweisung `var mw = foo()` in der Regel die Middleware zurück.
- * `app.use(mw)` bedeutet, dass die *Middleware dem globalen Verarbeitungsstack hinzugefügt wird*.
- * `app.get('/foo', mw, function (req, res) { ... })` bedeutet, dass die *Middleware dem "GET /foo"-Verarbeitungsstack hinzugefügt wird*.
+- `var foo = require('middleware')` bedeutet, dass ein Node.js-Modul _benötigt_ oder _verwendet_ wird. Dann gibt die Anweisung `var mw = foo()` in der Regel die Middleware zurück.
+- `app.use(mw)` bedeutet, dass die _Middleware dem globalen Verarbeitungsstack hinzugefügt wird_.
+- `app.get('/foo', mw, function (req, res) { ... })` bedeutet, dass die _Middleware dem "GET /foo"-Verarbeitungsstack hinzugefügt wird_.
### Node.js
-Eine Softwareplattform, die für die Erstellung skalierbarer Netzanwendungen verwendet wird. Node.js verwendet JavaScript als Scripting-Sprache und erzielt den hohen Durchsatz durch nicht blockierende Ein-/Ausgabe und eine Ereignisschleife mit einem Thread. Siehe auch [nodejs.org](http://nodejs.org/). **Hinweis**: Der ursprüngliche Name lautet "Node.js". Mittlerweile ist die Bezeichnung "Node" geläufig.
+Eine Softwareplattform, die für die Erstellung skalierbarer Netzanwendungen verwendet wird. Node.js verwendet JavaScript als Scripting-Sprache und erzielt den hohen Durchsatz durch nicht blockierende Ein-/Ausgabe und eine Ereignisschleife mit einem Thread. Siehe auch [nodejs.org](http://nodejs.org/). **Hinweis**: Der ursprüngliche Name lautet "Node.js".
### Open-Source
Bei Verwendung als Adjektiv muss dieser Begriff mit Bindestrichen gekoppelt werden: Beispiel: "Dies ist eine Open-Source-Software." Siehe auch [Open-Source-Software in Wikipedia](http://en.wikipedia.org/wiki/Open-source_software).
-### Router
+{% capture english-rules %}
-Siehe [Router](/{{ page.lang }}/4x/api.html#router) in der API-Referenz.
+Although it is common not to hyphenate this term, we are using the standard English rules for hyphenating a compound adjective.
+
+{% endcapture %}
+
+{% include admonitions/note.html content=english-rules %}
+
+### Anforderung
+
+Eine HTTP-Antwort. Ein Server gibt eine HTTP-Antwortnachricht an den Client zurück. Die Antwort enthält Informationen zum Beendigungsstatus in Bezug auf die Anforderung und kann im Nachrichtenhauptteil auch angeforderten Inhalt enthalten.
+
+### Antwort
+
+Eine HTTP-Anforderung. Ein Client übergibt eine HTTP-Anforderungsnachricht an einen Server, der wiederum eine Antwort zurückgibt. The response contains completion status information about the request and might also contain requested content in its message body.
### Weiterleitung (Route)
Teil einer URL, die eine Ressource angibt. Beispiel: In `http://foo.com/products/id` ist "/products/id" die Weiterleitung.
+
+### Router
+
+Siehe [Router](/{{ page.lang }}/4x/api.html#router) in der API-Referenz.
diff --git a/de/resources/learning.md b/de/resources/learning.md
deleted file mode 100755
index 5529984543..0000000000
--- a/de/resources/learning.md
+++ /dev/null
@@ -1,46 +0,0 @@
----
-layout: page
-title: Zusätzliches Lernen
-menu: resources
-lang: de
----
-
-# Zusätzliches Lernen
-
-Disclaimer: Unendorsed community content.
-
-## Books
-
-Here are a few of the many books on Express:
-
- - **[Getting MEAN with Mongo, Express, Angular, and Node](http://www.manning.com/sholmes/)**,
-Manning Publications, early 2015.
- - **[Express.js in Action](http://www.manning.com/hahn/)**,
-Manning Publications, early 2015.
- - **[Mastering Web Application Development with Express](https://www.packtpub.com/web-development/mastering-web-application-development-express-raw)**,
-Packt Publishing, September 2014.
- - **[Web Development with Node and Express](http://shop.oreilly.com/product/0636920032977.do)**,
-O'Reilly Media, July 2014.
- - **[Node.js in Action](http://www.manning.com/cantelon/)**,
-Manning Publications, October 2013.
- - **[Express Web Application Development](https://www.packtpub.com/web-development/express-web-application-development)**,
-Packt Publishing, June 2013.
-- **[express - Middleware für node.js](http://www.amazon.de/express-Middleware-node-js-J%C3%B6rg-Krause/dp/1517281342/ref=sr_1_1?ie=UTF8&qid=1442001556&sr=8-1&keywords=1517281342)**,
-texxtoor, September 2015. In deutscher Sprache / in German language
-- **[JADE - die Template Engine für node.js](http://www.amazon.de/JADE-Die-Template-Engine-node-js/dp/1517282098/ref=sr_1_1?ie=UTF8&qid=1442001592&sr=8-1&keywords=1517282098)**,
-texxtoor, September 2015. In deutscher Sprache / in German language
-- **[Node Web Development, 2nd edition](https://www.packtpub.com/web-development/node-web-development-second-edition)**, Packt Publishing, August 2013
-
-### Add your book here!
-
-[Edit the Markdown file](https://github.com/expressjs/expressjs.com/blob/gh-pages/{{ page.lang }}/resources/learning.md) and add a link to your book, then submit a pull request (GitHub login required). Follow the format of the above listings.
-
-## Blogs
-
-- [StrongLoop Blog: Express category](http://strongloop.com/strongblog/category/express/)
-- [Hage Yaapa's Blog: Express category](http://www.hacksparrow.com/category/express-js)
-- [Codeforgeek Blog: Express category](http://codeforgeek.com/code/nodejs/express/)
-
-### Add your blog here!
-
-[Edit the Markdown file](https://github.com/expressjs/expressjs.com/blob/gh-pages/{{ page.lang }}/resources/learning.md) and add a link to your blog, then submit a pull request (GitHub login required). Follow the format of the above listings.
diff --git a/de/resources/middleware.md b/de/resources/middleware.md
old mode 100755
new mode 100644
index a000551777..6342018377
--- a/de/resources/middleware.md
+++ b/de/resources/middleware.md
@@ -1,64 +1,43 @@
---
-layout: page
+layout: middleware
title: Express-Middleware
+description: Explore a list of Express.js middleware modules maintained by the Express team and the community, including built-in middleware and popular third-party modules.
menu: resources
-lang: de
+redirect_from: " "
+module: mw-home
---
-# Middleware anderer Anbieter
+## Express-Middleware
Nachfolgend sind einige Express-Middlewaremodule aufgeführt:
- - [body-parser](https://github.com/expressjs/body-parser): Bisher: `express.bodyParser`, `json` und `urlencoded`.
- Siehe auch:
- - [body](https://github.com/raynos/body)
- - [co-body](https://github.com/visionmedia/co-body)
- - [raw-body](https://github.com/stream-utils/raw-body)
- - [compression](https://github.com/expressjs/compression): Bisher `express.compress`
- - [connect-image-optimus](https://github.com/msemenistyi/connect-image-optimus): Connect/Express-Middlewaremodule für optimales Image-Serving. Wechselt Images (wenn möglich) zu `.webp` oder `.jxr`.
- - [connect-timeout](https://github.com/expressjs/timeout): Bisher: `express.timeout`
- - [cookie-parser](https://github.com/expressjs/cookie-parser): Bisher: `express.cookieParser`
- - [cookie-session](https://github.com/expressjs/cookie-session): Bisher: `express.cookieSession`
- - [csurf](https://github.com/expressjs/csurf): Bisher: `express.csrf`
- - [errorhandler](https://github.com/expressjs/errorhandler): Bisher: `express.errorHandler`
- - [express-debug](https://github.com/devoidfury/express-debug): Entwicklungstool, mit dem eine Registerkarte mit Informationen zu Vorlagenvariablen (lokalen Variablen), zur aktuellen Sitzung, zu hilfreichen Anforderungsdaten usw. Ihrer Anwendung hinzugefügt werden können.
- - [express-partial-response](https://github.com/nemtsov/express-partial-response): Express-Middlewaremodul für die Filterung von Teilen von JSON-Antworten auf Basis der Abfragezeichenfolge `fields` durch Verwendung der Google-API Partial Response.
- - [express-session](https://github.com/expressjs/session): Bisher: `express.session`
- - [express-simple-cdn](https://github.com/jamiesteven/express-simple-cdn): Express-Middlewaremodul für die Verwendung eines CDN (Content Delivery Network) für statische Assets mit Unterstützung mehrerer Hosts (Beispiel: cdn1.host.com, cdn2.host.com).
- - [express-slash](https://github.com/ericf/express-slash): Express-Middlewaremodul für Benutzer, die hohen Wert auf abschließende Schrägstriche legen.
- - [express-stormpath](https://github.com/stormpath/stormpath-express): Express-Middlewaremodul für Benutzerspeicher, Authentifizierung, Autorisierung, SSO und Datensicherheit.
- - [express-uncapitalize](https://github.com/jamiesteven/express-uncapitalize): Middlewaremodul für die Umleitung von HTTP-Anforderungen mit Großbuchstaben in eine kanonische Form mit Kleinbuchstaben.
- - [helmet](https://github.com/helmetjs/helmet): Modul zur Sicherung Ihrer Anwendungen durch Festlegung verschiedener HTTP-Header.
- - [join-io](https://github.com/coderaiser/join-io "join-io"): Modul für die Verknüpfung von Dateien während der Verarbeitung, um die Anzahl der Anforderungen zu reduzieren.
- - [method-override](https://github.com/expressjs/method-override): Bisher: `express.methodOverride`
- - [morgan](https://github.com/expressjs/morgan): Bisher: `logger`
- - [passport](https://github.com/jaredhanson/passport): Express-Middlewaremodul für die Authentifizierung.
- - [response-time](https://github.com/expressjs/response-time): Bisher: `express.responseTime`
- - [serve-favicon](https://github.com/expressjs/serve-favicon): Bisher: `express.favicon`
- - [serve-index](https://github.com/expressjs/serve-index): Bisher: `express.directory`
- - [serve-static](https://github.com/expressjs/serve-static): Modul für statischen Inhalt.
- - [static-expiry](https://github.com/paulwalker/connect-static-expiry): URLs mit elektronischem Fingerabdruck oder Caching-Headern für statische Assets einschließlich Unterstützung für eine oder mehrere externe Domänen.
- - [vhost](https://github.com/expressjs/vhost): Bisher: `express.vhost`
- - [view-helpers](https://github.com/madhums/node-view-helpers): Express-Middlewaremodul, das allgemeine Helper-Methoden für Ansichten bereitstellt.
- - [sriracha-admin](https://github.com/hdngr/siracha): Express-Middlewaremodul, das eine Administratorsite für Mongoose dynamisch generiert.
+| [express-slash](https://github.com/ericf/express-slash): Express-Middlewaremodul für Benutzer, die hohen Wert auf abschließende Schrägstriche legen. | Beschreibung |
+| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------- |
+| [body-parser](/{{page.lang}}/resources/middleware/body-parser.html) | Parse HTTP request body. |
+| [compression](/{{page.lang}}/resources/middleware/compression.html) | Compress HTTP responses. |
+| [connect-rid](/{{page.lang}}/resources/middleware/connect-rid.html) | Generate unique request ID. |
+| [cookie-parser](/{{page.lang}}/resources/middleware/cookie-parser.html) | Parse cookie header and populate `req.cookies`. See also [cookies](https://github.com/jed/cookies). |
+| [cookie-session](/{{page.lang}}/resources/middleware/cookie-session.html) | Establish cookie-based sessions. |
+| [cors](/{{page.lang}}/resources/middleware/cors.html) | Enable cross-origin resource sharing (CORS) with various options. |
+| [errorhandler](/{{page.lang}}/resources/middleware/errorhandler.html) | Development error-handling/debugging. |
+| [method-override](/{{page.lang}}/resources/middleware/method-override.html) | Override HTTP methods using header. |
+| [morgan](/{{page.lang}}/resources/middleware/morgan.html) | HTTP request logger. |
+| [multer](/{{page.lang}}/resources/middleware/multer.html) | Handle multi-part form data. |
+| [response-time](/{{page.lang}}/resources/middleware/response-time.html) | Record HTTP response time. |
+| [serve-favicon](/{{page.lang}}/resources/middleware/serve-favicon.html) | Serve a favicon. |
+| [serve-index](/{{page.lang}}/resources/middleware/serve-index.html) | Serve directory listing for a given path. |
+| [serve-static](/{{page.lang}}/resources/middleware/serve-static.html) | Serve static files. |
+| [session](/{{page.lang}}/resources/middleware/session.html) | Establish server-based sessions (development only). |
+| [timeout](/{{page.lang}}/resources/middleware/timeout.html) | Set a timeout perioHTTP request processing. |
+| [vhost](/{{page.lang}}/resources/middleware/vhost.html) | Create virtual domains. |
-Einige Middlewaremodule, die bisher zu Connect gehörten, werden vom Connect/Express-Team nicht mehr unterstützt. Diese Module werden durch ein alternatives oder besseres Modul ersetzt. Verwenden Sie eine der folgenden Alternativen:
+## Informationen zu weiteren Middlewaremodulen siehe:
- - express.cookieParser
- - [cookies](https://github.com/jed/cookies) und [keygrip](https://github.com/jed/keygrip)
- - express.limit
- - [raw-body](https://github.com/stream-utils/raw-body)
- - express.multipart
- - [connect-busboy](https://github.com/mscdex/connect-busboy)
- - [multer](https://github.com/expressjs/multer)
- - [connect-multiparty](https://github.com/superjoe30/connect-multiparty)
- - express.query
- - [qs](https://github.com/visionmedia/node-querystring)
- - express.staticCache
- - [st](https://github.com/isaacs/st)
- - [connect-static](https://github.com/andrewrk/connect-static)
+These are some additional popular middleware modules.
-Informationen zu weiteren Middlewaremodulen siehe:
+{% include community-caveat.html %}
- - [http-framework](https://github.com/Raynos/http-framework/wiki/Modules)
- - [expressjs](https://github.com/expressjs)
+| [express-slash](https://github.com/ericf/express-slash): Express-Middlewaremodul für Benutzer, die hohen Wert auf abschließende Schrägstriche legen. | Beschreibung |
+| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [helmet](https://github.com/helmetjs/helmet): Modul zur Sicherung Ihrer Anwendungen durch Festlegung verschiedener HTTP-Header. | Helps secure your apps by setting various HTTP headers. |
+| [passport](https://github.com/jaredhanson/passport): Express-Middlewaremodul für die Authentifizierung. | Authentication using "strategies" such as OAuth, OpenID and many others. See [passportjs.org](https://passportjs.org/) for more information. |
diff --git a/de/resources/middleware/body-parser.md b/de/resources/middleware/body-parser.md
new file mode 100644
index 0000000000..9c3e7e0276
--- /dev/null
+++ b/de/resources/middleware/body-parser.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express body-parser middleware
+menu: resources
+redirect_from: ' '
+module: body-parser
+---
diff --git a/de/resources/middleware/compression.md b/de/resources/middleware/compression.md
new file mode 100644
index 0000000000..d288542a65
--- /dev/null
+++ b/de/resources/middleware/compression.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express compression middleware
+menu: resources
+redirect_from: ' '
+module: compression
+---
diff --git a/de/resources/middleware/connect-rid.md b/de/resources/middleware/connect-rid.md
new file mode 100644
index 0000000000..95b2689265
--- /dev/null
+++ b/de/resources/middleware/connect-rid.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express connect-rid middleware
+menu: resources
+redirect_from: ' '
+module: connect-rid
+---
diff --git a/de/resources/middleware/cookie-parser.md b/de/resources/middleware/cookie-parser.md
new file mode 100644
index 0000000000..55100372e3
--- /dev/null
+++ b/de/resources/middleware/cookie-parser.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express cookie-parser middleware
+menu: resources
+redirect_from: ' '
+module: cookie-parser
+---
diff --git a/de/resources/middleware/cookie-session.md b/de/resources/middleware/cookie-session.md
new file mode 100644
index 0000000000..c6308fa81c
--- /dev/null
+++ b/de/resources/middleware/cookie-session.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express cookie-session middleware
+menu: resources
+redirect_from: ' '
+module: cookie-session
+---
diff --git a/de/resources/middleware/cors.md b/de/resources/middleware/cors.md
new file mode 100644
index 0000000000..4692141929
--- /dev/null
+++ b/de/resources/middleware/cors.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express cors middleware
+menu: resources
+redirect_from: ' '
+module: cors
+---
diff --git a/de/resources/middleware/errorhandler.md b/de/resources/middleware/errorhandler.md
new file mode 100644
index 0000000000..3b11a1208e
--- /dev/null
+++ b/de/resources/middleware/errorhandler.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express errorhandler middleware
+menu: resources
+redirect_from: ' '
+module: errorhandler
+---
diff --git a/de/resources/middleware/method-override.md b/de/resources/middleware/method-override.md
new file mode 100644
index 0000000000..8dff029cd4
--- /dev/null
+++ b/de/resources/middleware/method-override.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express method-override middleware
+menu: resources
+redirect_from: ' '
+module: method-override
+---
diff --git a/de/resources/middleware/morgan.md b/de/resources/middleware/morgan.md
new file mode 100644
index 0000000000..99c4c80fa9
--- /dev/null
+++ b/de/resources/middleware/morgan.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express morgan middleware
+menu: resources
+redirect_from: ' '
+module: morgan
+---
diff --git a/de/resources/middleware/multer.md b/de/resources/middleware/multer.md
new file mode 100644
index 0000000000..2fffab3b73
--- /dev/null
+++ b/de/resources/middleware/multer.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express multer middleware
+menu: resources
+redirect_from: ' '
+module: multer
+---
diff --git a/de/resources/middleware/response-time.md b/de/resources/middleware/response-time.md
new file mode 100644
index 0000000000..78ee67cd32
--- /dev/null
+++ b/de/resources/middleware/response-time.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express response-time middleware
+menu: resources
+redirect_from: ' '
+module: response-time
+---
diff --git a/de/resources/middleware/serve-favicon.md b/de/resources/middleware/serve-favicon.md
new file mode 100644
index 0000000000..7a1c8e6f5c
--- /dev/null
+++ b/de/resources/middleware/serve-favicon.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express serve-favicon middleware
+menu: resources
+redirect_from: ' '
+module: serve-favicon
+---
diff --git a/de/resources/middleware/serve-index.md b/de/resources/middleware/serve-index.md
new file mode 100644
index 0000000000..deeb963c8f
--- /dev/null
+++ b/de/resources/middleware/serve-index.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express serve-index middleware
+menu: resources
+redirect_from: ' '
+module: serve-index
+---
diff --git a/de/resources/middleware/serve-static.md b/de/resources/middleware/serve-static.md
new file mode 100644
index 0000000000..ff9bcc313e
--- /dev/null
+++ b/de/resources/middleware/serve-static.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express serve-static middleware
+menu: resources
+redirect_from: ' '
+module: serve-static
+---
diff --git a/de/resources/middleware/session.md b/de/resources/middleware/session.md
new file mode 100644
index 0000000000..22cf354ae7
--- /dev/null
+++ b/de/resources/middleware/session.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express session middleware
+menu: resources
+redirect_from: ' '
+module: session
+---
diff --git a/de/resources/middleware/timeout.md b/de/resources/middleware/timeout.md
new file mode 100644
index 0000000000..1afa2c5dd3
--- /dev/null
+++ b/de/resources/middleware/timeout.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express timeout middleware
+menu: resources
+redirect_from: ' '
+module: timeout
+---
diff --git a/de/resources/middleware/vhost.md b/de/resources/middleware/vhost.md
new file mode 100644
index 0000000000..2bad4c964f
--- /dev/null
+++ b/de/resources/middleware/vhost.md
@@ -0,0 +1,7 @@
+---
+layout: middleware
+title: Express vhost middleware
+menu: resources
+redirect_from: ' '
+module: vhost
+---
diff --git a/de/resources/utils.md b/de/resources/utils.md
new file mode 100644
index 0000000000..0fd21eea69
--- /dev/null
+++ b/de/resources/utils.md
@@ -0,0 +1,25 @@
+---
+layout: page
+title: Express utilities
+description: Discover utility modules related to Express.js and Node.js, including tools for cookies, CSRF protection, URL parsing, routing, and more to enhance your applications.
+menu: resources
+redirect_from: " "
+---
+
+## Express utility functions
+
+The [pillarjs](https://github.com/pillarjs) GitHub organization contains a number of modules
+for utility functions that may be generally useful.
+
+| Utility modules | Beschreibung |
+| -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| [cookies](https://www.npmjs.com/package/cookies) | Get and set HTTP(S) cookies that can be signed to prevent tampering, using Keygrip. Can be used with the Node.js HTTP library or as Express middleware. |
+| [csrf](https://www.npmjs.com/package/csrf) | Contains the logic behind CSRF token creation and verification. Use this module to create custom CSRF middleware. |
+| [finalhandler](https://www.npmjs.com/package/finalhandler) | Function to invoke as the final step to respond to HTTP request. |
+| [parseurl](https://www.npmjs.com/package/parseurl) | Parse a URL with caching. |
+| [path-to-regexp](https://www.npmjs.com/package/path-to-regexp) | Turn an Express-style path string such as \`\`/user/:name\` into a regular expression. |
+| [resolve-path](https://www.npmjs.com/package/resolve-path) | Resolves a relative path against a root path with validation. |
+| [router](https://www.npmjs.com/package/router) | Simple middleware-style router. |
+| [send](https://www.npmjs.com/package/send) | Library for streaming files as a HTTP response, with support for partial responses (ranges), conditional-GET negotiation, and granular events. |
+
+For additional low-level HTTP-related modules, see [jshttp](http://jshttp.github.io/).
diff --git a/de/starter/basic-routing.md b/de/starter/basic-routing.md
old mode 100755
new mode 100644
index e59ce41246..eaed71d21a
--- a/de/starter/basic-routing.md
+++ b/de/starter/basic-routing.md
@@ -1,24 +1,24 @@
---
layout: page
title: Basisrouting in Express
+description: Learn the fundamentals of routing in Express.js applications, including how to define routes, handle HTTP methods, and create route handlers for your web server.
menu: starter
-lang: de
+redirect_from: " "
---
# Basisrouting
-Per *Routing* wird bestimmt, wie eine Antwort auf eine Clientanforderung an einem bestimmten Endpunkt antwortet. Dies ist eine URI (oder ein Pfad) und eine bestimmte HTTP-Anforderungsmethode (GET, POST usw.).
+Per _Routing_ wird bestimmt, wie eine Antwort auf eine Clientanforderung an einem bestimmten Endpunkt antwortet. Dies ist eine URI (oder ein Pfad) und eine bestimmte HTTP-Anforderungsmethode (GET, POST usw.).
Jede Weiterleitung (Route) kann eine oder mehrere Handlerfunktionen haben, die ausgeführt werden, wenn die Weiterleitung abgeglichen wird.
Weiterleitungsdefinitionen haben die folgende Struktur:
-
-
+```
-Bedeutung:
+Where:
- `app` ist eine Instanz von `express`.
- `METHOD` ist eine [HTTP-Anforderungsmethode](http://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol).
@@ -33,42 +33,36 @@ Die folgenden Beispiele veranschaulichen das Definieren einfacher Weiterleitunge
Antworten Sie mit `Hello World!` auf der Homepage:
-
-
+```js
+app.get('/', (req, res) => {
+ res.send('Hello World!')
+})
+```
-Antworten Sie auf POST-Anforderungen auf die Weiterleitung zum Stammverzeichnis (`/`), der Homepage der Anwendung:
+Respond to a POST request on the root route (`/`), the application's home page:
-
-
+```js
+app.post('/', (req, res) => {
+ res.send('Got a POST request')
+})
+```
Antworten Sie auf eine PUT-Anforderung zur Weiterleitung `/user`:
-
-
+```js
+app.put('/user', (req, res) => {
+ res.send('Got a PUT request at /user')
+})
+```
Antworten Sie auf eine DELETE-Anforderung zur Weiterleitung `/user`:
-
-
+```js
+app.delete('/user', (req, res) => {
+ res.send('Got a DELETE request at /user')
+})
+```
Details zum Thema Routing finden Sie in der entsprechenden [Routinganleitung](/{{ page.lang }}/guide/routing.html).
+
+### [Previous: Express application generator ](/{{ page.lang }}/starter/generator.html) [Next: Serving static files in Express ](/{{ page.lang }}/starter/static-files.html)
diff --git a/de/starter/examples.md b/de/starter/examples.md
new file mode 100644
index 0000000000..a03e016318
--- /dev/null
+++ b/de/starter/examples.md
@@ -0,0 +1,21 @@
+---
+layout: page
+title: Express examples
+description: Explore a collection of Express.js application examples covering various use cases, integrations, and advanced configurations to help you learn and build your projects.
+menu: starter
+redirect_from: " "
+---
+
+{% capture examples %}{% include readmes/express-master/examples.md %}{% endcapture %}
+{{ examples | replace: "](.", "](https://github.com/expressjs/express/tree/master/examples" }}
+
+## Additional examples
+
+These are some additional examples with more extensive integrations.
+
+{% include community-caveat.html %}
+
+- [prisma-fullstack](https://github.com/prisma/prisma-examples/tree/latest/pulse/fullstack-simple-chat) - Fullstack app with Express and Next.js using [Prisma](https://www.npmjs.com/package/prisma) as an ORM
+- [prisma-rest-api-ts](https://github.com/prisma/prisma-examples/tree/latest/orm/express) - REST API with Express in TypeScript using [Prisma](https://www.npmjs.com/package/prisma) as an ORM
+
+### [Previous: Static Files ](/{{ page.lang }}/starter/static-files.html) [Next: FAQ ](/{{ page.lang }}/starter/faq.html)
diff --git a/de/starter/faq.md b/de/starter/faq.md
old mode 100755
new mode 100644
index 89ba8e6a52..178246ecea
--- a/de/starter/faq.md
+++ b/de/starter/faq.md
@@ -1,8 +1,9 @@
---
layout: page
title: Häufig gestellte Fragen zu Express
+description: Finden Sie Antworten auf häufig gestellte Fragen zu Express.js, darunter Themen wie Anwendungsstruktur, Models, Authentifizierung, Template-Engines, Fehlerbehandlung und mehr.
menu: starter
-lang: de
+redirect_from: " "
---
# Häufig gestellte Fragen
@@ -13,14 +14,13 @@ Auf diese Frage gibt es keine verbindliche Antwort. Die Antwort hängt vom Umfan
Weiterleitungen und andere anwendungsspezifische Logik können in einer beliebigen Anzahl von Dateien und in jeder von Ihnen bevorzugten Verzeichnisstruktur vorkommen. Die folgenden Beispiele sollen als Entscheidungshilfe dienen:
-
-* [Weiterleitungslisten](https://github.com/expressjs/express/blob/4.13.1/examples/route-separation/index.js#L32-47)
-* [Weiterleitungszuordnung](https://github.com/expressjs/express/blob/4.13.1/examples/route-map/index.js#L52-L66)
-* [Controller im MVC-Stil](https://github.com/expressjs/express/tree/master/examples/mvc)
+- [Weiterleitungslisten](https://github.com/expressjs/express/blob/4.13.1/examples/route-separation/index.js#L32-47)
+- [Weiterleitungszuordnung](https://github.com/expressjs/express/blob/4.13.1/examples/route-map/index.js#L52-L66)
+- [Controller im MVC-Stil](https://github.com/expressjs/express/tree/master/examples/mvc)
Darüber hinaus gibt es Erweiterungen anderer Anbieter für Express, die zur Vereinfachung einiger dieser Muster beitragen:
-* [Weiterleitung mit "express-resource"](https://github.com/expressjs/express-resource)
+- [Weiterleitung mit "express-resource"](https://github.com/expressjs/express-resource)
## Wie definiere ich Modelle?
@@ -30,40 +30,51 @@ Express hat keine Vorstellungen von einer Datenbank. Dieses Konzept bleibt Node-
## Wie kann ich Benutzer authentifizieren?
-Die Authentifizierung ist ein weiterer meinungsstarker Bereich, in den Express nicht eingreift. Sie können ein Authentifizierungsschema nach Ihren Vorstellungen verwenden. Ein einfaches Benutzername/Kennwort-Schema können Sie in [diesem Beispiel](https://github.com/expressjs/express/tree/master/examples/auth) sehen.
-
+Die Authentifizierung ist ein weiterer meinungsstarker Bereich, in den Express nicht eingreift. Sie können ein Authentifizierungsschema nach Ihren Vorstellungen verwenden.
+Ein einfaches Benutzername/Kennwort-Schema können Sie in [diesem Beispiel](https://github.com/expressjs/express/tree/master/examples/auth) sehen.
## Welche Template-Engines unterstützt Express?
-Express unterstützt jede Template-Engine, die der `(path, locals, callback)`-Signatur entspricht. Informationen zur Normalisierung von Template-Engine-Schnittstellen und -Caching siehe das Projekt [consolidate.js](https://github.com/visionmedia/consolidate.js). Nicht aufgelistete Template-Engines können trotzdem die Express-Signatur unterstützen.
+Express unterstützt jede Template-Engine, die der `(path, locals, callback)`-Signatur entspricht.
+Informationen zur Normalisierung von Template-Engine-Schnittstellen und -Caching siehe das Projekt [consolidate.js](https://github.com/visionmedia/consolidate.js). Nicht aufgelistete Template-Engines können trotzdem die Express-Signatur unterstützen.
+
+For more information, see [Using template engines with Express](/{{page.lang}}/guide/using-template-engines.html).
## Wie handhabe ich 404-Antworten?
In Express sind 404-Antworten nicht das Ergebnis eines Fehlers, sodass diese Antworten von der Fehlerbehandlungsroutine nicht erfasst werden. Dieses Verhalten ist damit zu erklären, dass eine 404-Antwort einfach angibt, dass keine weiteren Arbeiten auszuführen sind. In anderen Worten: Express hat alle Middlewarefunktionen und Weiterleitungen ausgeführt und festgestellt, dass keine Funktion eine Antwort zurückgegeben hat. Sie müssen also bei der Handhabung der 404-Antwort nur eine Middlewarefunktion am Ende des Stacks (unterhalb von allen anderen Funktionen) hinzufügen:
-
-
+```js
+app.use((req, res, next) => {
+ res.status(404).send("Sorry can't find that!")
+})
+```
+
+Add routes dynamically at runtime on an instance of `express.Router()`
+so the routes are not superseded by a middleware function.
## Wie richte ich eine Fehlerbehandlungsroutine ein?
Middleware für die Fehlerbehandlung wird in derselben Weise definiert wie andere Middleware; außer dass sie vier anstatt drei Argumente aufweist. Dies gilt speziell bei der Signatur `(err, req, res, next)`:
-
-
+```js
+app.use((err, req, res, next) => {
+ console.error(err.stack)
+ res.status(500).send('Something broke!')
+})
+```
Weitere Informationen siehe [Fehlerbehandlung](/{{ page.lang }}/guide/error-handling.html).
## Wie gebe ich normales HTML-Format aus?
-Das ist nicht Ihre Aufgabe! Sie müssen kein HTML-Format mit der Funktion `res.render()` ausgeben. Verwenden Sie die Funktion `res.sendFile()`, wenn Sie es mit einer bestimmten Datei zu tun haben. Wenn Sie viele Assets aus einem Verzeichnis bedienen müssen, verwenden Sie die Middlewarefunktion `express.static()`.
+Das ist nicht Ihre Aufgabe! Sie müssen kein HTML-Format mit der Funktion `res.render()` ausgeben.
+Verwenden Sie die Funktion `res.sendFile()`, wenn Sie es mit einer bestimmten Datei zu tun haben.
+Wenn Sie viele Assets aus einem Verzeichnis bedienen müssen, verwenden Sie die Middlewarefunktion `express.static()`.
+
+## Welche Version von Node.js benötigt Express?
+
+- [Express 4.x](/{{ page.lang }}/4x/api.html) requires Node.js 0.10 or higher.
+- [Express 5.x](/{{ page.lang }}/5x/api.html) requires Node.js 18 or higher.
+
+### [Previous: More examples ](/{{ page.lang }}/starter/examples.html)
diff --git a/de/starter/generator.md b/de/starter/generator.md
old mode 100755
new mode 100644
index 11be303f78..f59f6e1d1a
--- a/de/starter/generator.md
+++ b/de/starter/generator.md
@@ -1,29 +1,34 @@
---
layout: page
title: Express-Anwendungsgenerator
+description: Learn how to use the Express application generator tool to quickly create a skeleton for your Express.js applications, streamlining setup and configuration.
menu: starter
-lang: de
+redirect_from: " "
---
# Express-Anwendungsgenerator
Mit dem Application Generator Tool `express` können Sie innerhalb kürzester Zeit ein Anwendungsgerüst erstellen.
-Installieren Sie `express` mit dem folgenden Befehl:
+You can run the application generator with the `npx` command (available in Node.js 8.2.0).
-
-
+```bash
+$ npx express-generator
+```
+
+For earlier Node versions, install the application generator as a global npm package and then launch it:
+
+```bash
+$ npm install -g express-generator
+$ express
+```
Zeigen Sie die Befehlsoptionen mit der Option `-h` an:
-
-
+```
-Im folgenden Beispiel wird eine Express-Anwendung mit dem Namen _myapp_ im aktuellen Arbeitsverzeichnis erstellt:
+Im folgenden Beispiel wird eine Express-Anwendung mit dem Namen _myapp_ im aktuellen Arbeitsverzeichnis erstellt: The app will be created in a folder named _myapp_ in the current working directory and the view engine will be set to Pug:
-
-
+```
Installieren Sie dann Abhängigkeiten:
-
-
+```
-Führen Sie unter MacOS oder Linux die Anwendung mit diesem Befehl aus:
+Verwenden Sie unter Windows diesen Befehl:
-
-
+```
-Verwenden Sie unter Windows diesen Befehl:
+Führen Sie unter MacOS oder Linux die Anwendung mit diesem Befehl aus:
-
-
+```
+
+On Windows PowerShell, use this command:
+
+```bash
+PS> $env:DEBUG='myapp:*'; npm start
+```
Laden Sie dann `http://localhost:3000/` in Ihren Browser, um auf die Anwendung zuzugreifen.
Die erstellte Anwendung hat die folgende Verzeichnisstruktur:
-
-
+```
Die vom Generator erstellte Anwendungsstruktur ist nur eine der vielen Möglichkeiten, Express-Anwendungen zu strukturieren. Sie können diese Struktur verwenden oder sie an Ihre Anforderungen anpassen.
+
+### [Previous: Hello World ](/{{ page.lang }}/starter/hello-world.html) [Next: Basic routing](/{{ page.lang }}/starter/basic-routing.html)
diff --git a/de/starter/hello-world.md b/de/starter/hello-world.md
old mode 100755
new mode 100644
index 3534baba3b..3fd33c8743
--- a/de/starter/hello-world.md
+++ b/de/starter/hello-world.md
@@ -1,8 +1,9 @@
---
layout: page
title: Beispiel "Hello World" in Express
+description: Get started with Express.js by building a simple 'Hello World' application, demonstrating the basic setup and server creation for beginners.
menu: starter
-lang: de
+redirect_from: " "
---
# Beispiel "Hello World"
@@ -11,12 +12,7 @@ lang: de
Dies ist wohl die einfachste Express-Anwendung, die Sie erstellen können. Es handelt sich um eine Anwendung mit nur einer Datei und — *nicht* das, was Sie mit dem [Express Generator](/{{ page.lang }}/starter/generator.html) erhalten würden. Mit dem Generator würde das Gerüst für eine vollständige Anwendung mit zahlreichen JavaScript-Dateien, Jade-Vorlagen und Unterverzeichnissen für verschiedene Zwecke erstellt werden.
-
+```
-Die Anwendung startet einen Server und ist an Port 3000 empfangsbereit für Verbindungen. Die Anwendung antwortet mit "Hello World!" auf Anforderungen zur Stamm-URL (`/`) oder zu *route*. Bei jedem anderen Pfad lautet die Antwort **404 Not Found**.
+Die Anwendung startet einen Server und ist an Port 3000 empfangsbereit für Verbindungen. Die Anwendung antwortet mit "Hello World!" auf Anforderungen zur Stamm-URL (`/`) oder zu _route_. Bei jedem anderen Pfad lautet die Antwort **404 Not Found**.
-
-`req` (Anforderung) und `res` (Antwort) sind genau dieselben Objekte, die Node bereitstellt. Sie können also `req.pipe()`, `req.on('data', callback)` und alle anderen Tasks, die Sie ausführen wollen, ohne Express ausführen.
-
+### Running Locally
+
+Erstellen Sie zunächst ein Verzeichnis namens `myapp`, wechseln Sie in das Verzeichnis und führen Sie `npm init` aus. Installieren Sie dann `express` als Abhängigkeit, wie im [Installationshandbuch](/{{ page.lang }}/starter/installing.html) beschrieben.
+
+Erstellen Sie im Verzeichnis `myapp` eine Datei namens `app.js` und fügen Sie den folgenden Code hinzu:
+
+`req` (Anforderung) und `res` (Antwort) sind genau dieselben Objekte, die Node bereitstellt. Sie können also `req.pipe()`, `req.on('data', callback)` und alle anderen Tasks, die Sie ausführen wollen, ohne Express ausführen.
Führen Sie die Anwendung mit dem folgenden Befehl aus:
-
-
+```
Laden Sie dann [http://localhost:3000/](http://localhost:3000/) in einen Browser, um die Ausgabe zu sehen.
+### [Previous: Installing ](/{{ page.lang }}/starter/installing.html) [Next: Express Generator ](/{{ page.lang }}/starter/generator.html)
diff --git a/de/starter/installing.md b/de/starter/installing.md
old mode 100755
new mode 100644
index e47a9c1cb9..e745549656
--- a/de/starter/installing.md
+++ b/de/starter/installing.md
@@ -1,55 +1,53 @@
---
layout: page
title: Express installieren
+description: Erfahren Sie, wie Sie Express.js in Ihrer Node.js-Umgebung installieren, wie Sie Ihr Projektverzeichnis aufsetzen und Abhängigkeiten mit npm verwalten.
menu: starter
-lang: de
+redirect_from: " "
---
# Installation
Angenommen, Sie haben [Node.js](https://nodejs.org/) bereits installiert. Erstellen Sie ein Verzeichnis für Ihre Anwendung und definieren Sie dieses Verzeichnis als Ihr Arbeitsverzeichnis.
-
-
+```
-Erstellen Sie mit dem Befehl `npm init` eine Datei namens `package.json` für Ihre Anwendung. Weitere Informationen zur Funktionsweise von `package.json` finden Sie in den [Angaben zur Handhabung der npm-Datei package.json](https://docs.npmjs.com/files/package.json).
+Erstellen Sie mit dem Befehl `npm init` eine Datei namens `package.json` für Ihre Anwendung.
+Weitere Informationen zur Funktionsweise von `package.json` finden Sie in den [Angaben zur Handhabung der npm-Datei package.json](https://docs.npmjs.com/files/package.json).
-
-
+```
-Dieser Befehl fordert Sie zur Eingabe verschiedener Angaben wie Name und Version Ihrer Anwendung auf. Für den Moment reicht es, die Eingabetaste zu drücken und die Standardwerte für die meisten Angaben zu akzeptieren. Es gilt jedoch folgende Ausnahme:
+Dieser Befehl fordert Sie zur Eingabe verschiedener Angaben wie Name und Version Ihrer Anwendung auf.
+For now, you can simply hit RETURN to accept the defaults for most of them, with the following exception:
-
-
+```
Geben Sie `app.js` oder einen Namen Ihrer Vorstellung als Namen für die Hauptdatei ein. Wenn dieser Name `index.js` lauten soll, drücken Sie die Eingabetaste, um den vorgeschlagenen Standarddateinamen zu akzeptieren.
Installieren Sie jetzt Express im Verzeichnis `myapp` und speichern Sie es in der Abhängigkeitsliste. Beispiel:
-
-
+```bash
+$ npm install express
+```
Wenn Sie Express vorübergehend installieren und nicht zur Abhängigkeitsliste hinzufügen wollen, geben Sie die Option `--save` nicht an:
-
-
+```bash
+$ npm install express --no-save
+```
Node-Module, die mit der Option `--save` installiert werden, werden zur `Abhängigkeitsliste` in der Datei `package.json` hinzugefügt. Danach werden bei der Ausführung von `npm install` im Verzeichnis `app` automatisch alle Module in der Abhängigkeitsliste installiert.
+
+### [Next: Hello World ](/{{ page.lang }}/starter/hello-world.html)
\ No newline at end of file
diff --git a/de/starter/static-files.md b/de/starter/static-files.md
old mode 100755
new mode 100644
index 9c6197ee3e..620afe0dc0
--- a/de/starter/static-files.md
+++ b/de/starter/static-files.md
@@ -1,72 +1,79 @@
---
layout: page
title: Statische Dateien in Express bereitstellen
+description: Understand how to serve static files like images, CSS, and JavaScript in Express.js applications using the built-in 'static' middleware.
menu: starter
-lang: de
+redirect_from: " "
---
# Statische Dateien in Express bereitstellen
Wenn Sie statische Dateien wie Bilder, CSS-Dateien und JavaScript-Dateien bereitstellen wollen, verwenden Sie die in Express integrierte Middlewarefunktion `express.static`.
-Übergeben Sie den Namen des Verzeichnisses mit den statischen Assets an die Middlewarefunktion `express.static`, um direkt mit dem Bereitstellen der Dateien zu beginnen. Beispiel: Verwenden Sie den folgenden Code, um Bilder, CSS-Dateien und JavaScript-Dateien in einem Verzeichnis namens `public` bereitzustellen:
+The function signature is:
-
-
+```js
+express.static(root, [options])
+```
+
+The `root` argument specifies the root directory from which to serve static assets.
+For more information on the `options` argument, see [express.static](/{{page.lang}}/5x/api.html#express.static).
+
+Beispiel: Verwenden Sie den folgenden Code, um Bilder, CSS-Dateien und JavaScript-Dateien in einem Verzeichnis namens `public` bereitzustellen:
+
+```js
+app.use(express.static('public'))
+```
Jetzt können Sie die Dateien laden, die sich im Verzeichnis `public` befinden:
-
-
+```
-
-Express sucht nach den Dateien, die sich auf das Verzeichnis mit den statischen Assets beziehen. Der Name dieses Verzeichnisses ist also nicht Teil der URL.
+Express sucht nach den Dateien, die sich auf das Verzeichnis mit den statischen Assets beziehen. Der Name dieses Verzeichnisses ist also nicht Teil der URL.
Wenn Sie mehrere Verzeichnisse mit statischen Assets verwenden wollen, rufen Sie die Middlewarefunktion `express.static` mehrmals auf:
-
-
+```js
+app.use(express.static('public'))
+app.use(express.static('files'))
+```
Express sucht in der Reihenfolge nach den Dateien, in der sie die Verzeichnisse mit den statischen Assets über die Middlewarefunktion `express.static` festgelegt haben.
-Wenn Sie ein Präfix für einen virtuellen Pfad (in dem der Pfad nicht wirklich im Dateisystem existiert) für Dateien festlegen wollen, die über die Funktion `express.static` bereitgestellt werden, [müssen Sie einen Mountpfad](/{{ page.lang }}/4x/api.html#app.use) für das Verzeichnis mit den statischen Assets wie unten gezeigt angeben:
+{% capture alert_content %}
+For best results, [use a reverse proxy](/{{page.lang}}/advanced/best-practice-performance.html#use-a-reverse-proxy) cache to improve performance of serving static assets.
+{% endcapture %}
+{% include admonitions/note.html content=alert_content %}
-
-
+To create a virtual path prefix (where the path does not actually exist in the file system) for files that are served by the `express.static` function, [specify a mount path](/{{ page.lang }}/5x/api.html#app.use) for the static directory, as shown below:
+
+```js
+app.use('/static', express.static('public'))
+```
Jetzt können Sie die Dateien, die sich im Verzeichnis `public` befinden, aus dem Pfadpräfix `/static` laden.
-
-
+```
Der Pfad, den Sie für die Funktion `express.static` angeben, ist jedoch relativ zum Verzeichnis, aus dem Sie Ihren Prozess `node` starten. Wenn Sie die Express-Anwendung aus einem anderen Verzeichnis ausführen, ist es sicherer, den absoluten Pfad des Verzeichnisses zu verwenden, das Sie bereitstellen wollen:
-
-
+```js
+const path = require('path')
+app.use('/static', express.static(path.join(__dirname, 'public')))
+```
+
+For more details about the `serve-static` function and its options, see [serve-static](/resources/middleware/serve-static.html).
+
+### [Previous: Basic Routing ](/{{ page.lang }}/starter/basic-routing.html) [Next: More examples ](/{{ page.lang }}/starter/examples.html)
diff --git a/de/support/index.md b/de/support/index.md
new file mode 100644
index 0000000000..3b0c7ad325
--- /dev/null
+++ b/de/support/index.md
@@ -0,0 +1,27 @@
+---
+layout: page
+title: Version-Support
+description: Finden Sie Informationen über den Support-Zeitplan für verschiedene Express.js Versionen, einschließlich der aktuellen Versionen und der End-of-Life-Richtlinien.
+menu: support
+---
+
+# Version-Support
+
+Es wird nur die neueste Version einer bestimmten Hauptversionslinie unterstützt.
+
+Versionen, die EOL (End-of-Life) sind, _können_ Updates für kritische Sicherheitslücken erhalten, aber das Express-Team bietet keine Garantie und plant nicht, Fixes für gefundene Fehler zu entwickeln oder zu veröffentlichen.
+
+| Major Version | Minimale Node.js Version | Support Startdatum | Support-Enddatum |
+| ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------- | ------------------ | ---------------------------------------------------------------- |
+| [**v5.x**{: .supported }](/{{page.lang}}/5x/api.html){: .ignore-underline} | 18 | September 2024 | **läuft derzeit**{: .supported } |
+| [**v4.x**{: .supported }](/{{page.lang}}/4x/api.html){: .ignore-underline} | 0.10.0 | April 2014 | **läuft derzeit**{: .supported } |
+| [**v3.x**{: .eol }](/{{page.lang}}/3x/api.html){: .ignore-underline} | 0.8.0 | Oktober 2012 | Juli 2015 |
+| [**v2.x**{: .eol }](/2x/){: .ignore-underline} | 0.4.1 | März 2011 | Juli 2012 |
+| **v1.x**{: .eol } | 0.2.0 | Dezember 2010 | März 2011 |
+| **v0.14.x**{: .eol } | 0.1.98 | Dezember 2010 | Dezember 2010 |
+
+## Kommerzielle Support Optionen
+
+Wenn Sie nicht auf eine unterstützte Version von Express aktualisieren können, wenden Sie sich bitte an einen unserer Partner, um Sicherheitsaktualisierungen zu erhalten:
+
+- [HeroDevs Never-Ending Support](http://www.herodevs.com/support/express-nes?utm_source=expressjs&utm_medium=link&utm_campaign=express_eol_page)
diff --git a/en/3x/api.md b/en/3x/api.md
index 7421a648df..b421e2afe6 100644
--- a/en/3x/api.md
+++ b/en/3x/api.md
@@ -1,24 +1,27 @@
---
-layout: 3x-api
+layout: api
+version: 3x
title: Express 3.x - API Reference
+description: Access the API reference for Express.js version 3.x, noting that this version is end-of-life and no longer maintained - includes details on modules and methods.
menu: api
-lang: en
redirect_from: "/3x/api.html"
---
- **Express 3.x IS NO LONGER MAINTAINED**
+ **Express 3.x IS END-OF-LIFE AND NO LONGER MAINTAINED**
Known and unknown security and performance issues in 3.x have not been addressed since the last update (1 August, 2015). It is highly recommended to use the latest version of Express.
+
+ If you are unable to upgrade past 3.x, please consider [Commercial Support Options](/{{ page.lang }}/support#commercial-support-options).
3.x API- {% include api/{{ page.lang }}/3x/express.md %} - {% include api/{{ page.lang }}/3x/app.md %} - {% include api/{{ page.lang }}/3x/req.md %} - {% include api/{{ page.lang }}/3x/res.md %} - {% include api/{{ page.lang }}/3x/middleware.md %} + {% include api/en/3x/express.md %} + {% include api/en/3x/app.md %} + {% include api/en/3x/req.md %} + {% include api/en/3x/res.md %} + {% include api/en/3x/middleware.md %}4.x API- {% include api/{{ page.lang }}/4x/express.md %} - {% include api/{{ page.lang }}/4x/app.md %} - {% include api/{{ page.lang }}/4x/req.md %} - {% include api/{{ page.lang }}/4x/res.md %} - {% include api/{{ page.lang }}/4x/router.md %} + {% capture node-version %} + + Express 4.0 requires Node.js 0.10 or higher. + + {% endcapture %} + + {% include admonitions/note.html content=node-version %} + + {% include api/en/4x/express.md %} + {% include api/en/4x/app.md %} + {% include api/en/4x/req.md %} + {% include api/en/4x/res.md %} + {% include api/en/4x/router.md %}5.x API- {% include note.html content="This is early alpha documentation that may be incomplete and is still under development." %} + {% capture node-version %} - {% include api/{{ page.lang }}/5x/express.md %} - {% include api/{{ page.lang }}/5x/app.md %} - {% include api/{{ page.lang }}/5x/req.md %} - {% include api/{{ page.lang }}/5x/res.md %} - {% include api/{{ page.lang }}/5x/router.md %} + Express 5.0 requires Node.js 18 or higher. + + {% endcapture %} + + {% include admonitions/note.html content=node-version %} + + {% include api/en/5x/express.md %} + {% include api/en/5x/app.md %} + {% include api/en/5x/req.md %} + {% include api/en/5x/res.md %} + {% include api/en/5x/router.md %}' + options.message + '') + const rendered = content.toString() + .replace('#title#', `${options.message}`) return callback(null, rendered) }) }) @@ -30,15 +30,15 @@ app.set('view engine', 'ntl') // register the template engine Your app will now be able to render `.ntl` files. Create a file named `index.ntl` in the `views` directory with the following content. -```text +```pug #title# #message# ``` Then, create the following route in your app. ```js -app.get('/', function (req, res) { +app.get('/', (req, res) => { res.render('index', { title: 'Hey', message: 'Hello there!' }) }) ``` -When you make a request to the home page, `index.ntl` will be rendered as HTML. +When you make a request to the home page, `index.ntl` will be rendered as HTML. \ No newline at end of file diff --git a/en/advanced/healthcheck-graceful-shutdown.md b/en/advanced/healthcheck-graceful-shutdown.md index ca1eb19d36..4398238fad 100644 --- a/en/advanced/healthcheck-graceful-shutdown.md +++ b/en/advanced/healthcheck-graceful-shutdown.md @@ -1,8 +1,8 @@ --- layout: page title: Health Checks and Graceful Shutdown +description: Learn how to implement health checks and graceful shutdown in Express apps to enhance reliability, manage deployments, and integrate with load balancers like Kubernetes. menu: advanced -lang: en redirect_from: "/advanced/healthcheck-graceful-shutdown.html" --- @@ -10,9 +10,10 @@ redirect_from: "/advanced/healthcheck-graceful-shutdown.html" ## Graceful shutdown -When you deploy a new version of your application, you must replace the previous version. The [process manager](pm.html) you're using will first send a SIGTERM signal to the application to notify it that it will be killed. Once the application gets this signal, it should stop accepting new requests, finish all the ongoing requests, clean up the resources it used, including database connections and file locks then exit. +When you deploy a new version of your application, you must replace the previous version. The process manager you're using will first send a SIGTERM signal to the application to notify it that it will be killed. Once the application gets this signal, it should stop accepting new requests, finish all the ongoing requests, clean up the resources it used, including database connections and file locks then exit. + +### Example -### Example Graceful Shutdown ```js const server = app.listen(port) @@ -29,153 +30,4 @@ process.on('SIGTERM', () => { A load balancer uses health checks to determine if an application instance is healthy and can accept requests. For example, [Kubernetes has two health checks](https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/): * `liveness`, that determines when to restart a container. -* `readiness`, that determines when a container is ready to start accepting traffic. When a pod is not ready, it is removed from the service load balancers. - -## Third-party solutions - -{% include community-caveat.html %} - -### Terminus - -[Terminus](https://github.com/godaddy/terminus) is an open-source project that adds health checks and graceful shutdown to your application to eliminate the need to write boilerplate code. You just provide the cleanup logic for graceful shutdowns and the health check logic for health checks, and terminus handles the rest. - -Install terminus as follows: - -```sh -npm i @godaddy/terminus --save -``` - -Here's a basic template that illustrates using terminus. For more information, see
-Node.js vulnerabilities directly affect Express. Therefore [keep a watch on Node.js vulnerabilities](http://blog.nodejs.org/vulnerability/) and make sure you are using the latest stable version of Node.js.
+Node.js vulnerabilities directly affect Express. Therefore, [keep a watch on Node.js vulnerabilities](https://nodejs.org/en/blog/vulnerability/) and make sure you are using the latest stable version of Node.js.
The list below enumerates the Express vulnerabilities that were fixed in the specified version update.
-**NOTE**: If you believe you have discovered a security vulnerability in Express, please see
+
+{% capture security-policy %}
+If you believe you have discovered a security vulnerability in Express, please see
[Security Policies and Procedures](/{{page.lang}}/resources/contributing.html#security-policies-and-procedures).
+{% endcapture %}
-## 4.x
+{% include admonitions/note.html content=security-policy %}
+## 4.x
+ * 4.21.2
+ * The dependency `path-to-regexp` has been updated to address a [vulnerability](https://github.com/pillarjs/path-to-regexp/security/advisories/GHSA-rhx6-c78j-4q9w).
+ * 4.21.1
+ * The dependency `cookie` has been updated to address a [vulnerability](https://github.com/jshttp/cookie/security/advisories/GHSA-pxg6-pf52-xh8x), This may affect your application if you use `res.cookie`.
+ * 4.20.0
+ * Fixed XSS vulnerability in `res.redirect` ([advisory](https://github.com/expressjs/express/security/advisories/GHSA-qw6h-vgh9-j6wx), [CVE-2024-43796](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-43796)).
+ * The dependency `serve-static` has been updated to address a [vulnerability](https://github.com/advisories/GHSA-cm22-4g7w-348p).
+ * The dependency `send` has been updated to address a [vulnerability](https://github.com/advisories/GHSA-m6fv-jmcg-4jfg).
+ * The dependency `path-to-regexp` has been updated to address a [vulnerability](https://github.com/pillarjs/path-to-regexp/security/advisories/GHSA-9wv6-86v2-598j).
+ * The dependency `body-parser` has been updated to addres a [vulnerability](https://github.com/advisories/GHSA-qwcr-r2fm-qrc7), This may affect your application if you had url enconding activated.
+ * 4.19.0, 4.19.1
+ * Fixed open redirect vulnerability in `res.location` and `res.redirect` ([advisory](https://github.com/expressjs/express/security/advisories/GHSA-rv95-896h-c2vc), [CVE-2024-29041](https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2024-29041)).
+ * 4.17.3
+ * The dependency `qs` has been updated to address a [vulnerability](https://github.com/advisories/GHSA-hrpp-h998-j3pp). This may affect your application if the following APIs are used: `req.query`, `req.body`, `req.param`.
* 4.16.0
* The dependency `forwarded` has been updated to address a [vulnerability](https://npmjs.com/advisories/527). This may affect your application if the following APIs are used: `req.host`, `req.hostname`, `req.ip`, `req.ips`, `req.protocol`.
* The dependency `mime` has been updated to address a [vulnerability](https://npmjs.com/advisories/535), but this issue does not impact Express.
@@ -44,9 +63,11 @@ The list below enumerates the Express vulnerabilities that were fixed in the spe
## 3.x
- **Express 3.x IS NO LONGER MAINTAINED**
+ **Express 3.x IS END-OF-LIFE AND NO LONGER MAINTAINED**
+
+ Known and unknown security and performance issues in 3.x have not been addressed since the last update (1 August, 2015). It is highly recommended to use the latest version of Express.
- Known and unknown security issues in 3.x have not been addressed since the last update (1 August, 2015). Using the 3.x line should not be considered secure.
+ If you are unable to upgrade past 3.x, please consider [Commercial Support Options](/{{ page.lang }}/support#commercial-support-options).
* 3.19.1
@@ -61,4 +82,4 @@ The list below enumerates the Express vulnerabilities that were fixed in the spe
* Sparse arrays that have extremely high indexes in query string could cause the process to run out of memory and crash the server.
* Extremely nested query string objects could cause the process to block and make the server unresponsive temporarily.
* 3.3.0
- * The 404 response of an unsupported method override attempt was susceptible to cross-site scripting attacks.
+ * The 404 response of an unsupported method override attempt was susceptible to cross-site scripting attacks.
\ No newline at end of file
diff --git a/en/api.md b/en/api.md
index 16227d369e..41382818cc 100644
--- a/en/api.md
+++ b/en/api.md
@@ -1,26 +1,21 @@
---
-layout: 4x-api
-title: Express 4.x - API Reference
-lang: en
+layout: api
+version: 5x
+title: Express 5.x - API Reference
+description: Access the API reference for Express.js detailing all modules, methods, and properties for building web applications with this version.
+menu: api
redirect_from: "/api.html"
---
-
-
diff --git a/en/blog/posts.md b/en/blog/posts.md
new file mode 100644
index 0000000000..b5be34e66c
--- /dev/null
+++ b/en/blog/posts.md
@@ -0,0 +1,28 @@
+---
+layout: post
+title: Express Blog Posts
+description: Explore the latest articles, announcements, and updates from the Express.js team and community on the Express blog.
+menu: blog
+redirect_from: "/blog/posts.html"
+---
+
+Want to write a post? See the submission [guidelines.](/en/blog/write-post.html)
+
+{% if site.posts.size != 0 %}
+4.x API- +5.x API- {% include api/{{ page.lang }}/4x/express.md %} - + {% include api/en/5x/express.md %} - {% include api/{{ page.lang }}/4x/app.md %} - + {% include api/en/5x/app.md %} - {% include api/{{ page.lang }}/4x/req.md %} - + {% include api/en/5x/req.md %} - {% include api/{{ page.lang }}/4x/res.md %} - + {% include api/en/5x/res.md %} - {% include api/{{ page.lang }}/4x/router.md %} - + {% include api/en/5x/router.md %}
+{% for post in site.posts %}
+
+{% else %}
+ There are currently no blog posts.
+{% endif %}
diff --git a/en/blog/write-post.md b/en/blog/write-post.md
new file mode 100644
index 0000000000..21cfc5b4b3
--- /dev/null
+++ b/en/blog/write-post.md
@@ -0,0 +1,51 @@
+---
+layout: post
+title: How to write a blog post
+description: Learn how to propose and write a blog post for the Express.js blog, including submission guidelines and steps to contribute your content.
+menu: blog
+redirect_from: "/blog/write.html"
+---
+
+
+
+If you have an idea for a blog post, follow these steps to propose it and potentially get it published!
+
+1. ### Propose your post
+Before taking the time to write a post, please confirm that we will be able to publish it. We're looking for topics specifically related to Express, and so we want to pre-approve all posts. For the moment, this means we aren't accepting any unsolicited posts. To propose a blog post, [open an issue](https://github.com/expressjs/expressjs.com/issues) entitled `Blog post proposal:
+
+{% endfor %}
+
+ {{ post.title }}
+
+
+ {% include blog/authors.html authors=post.authors %}
+
+ {{ post.date | date:"%b %d, %Y" }}
+ {{post.excerpt | truncate: 240 | markdownify }}
+
+
+# Release changelog
+
+All the latest updates, improvements, and fixes to Express
+
+## Express v5
+{: id="5.x"}
+
+### 5.1.0 - Release date: 2025-03-31
+{: id="5.0.1"}
+
+The 5.1.0 minor release includes some new features and improvements:
+
+* Support for sending responses as Uint8Array
+* Added support for ETag option in `res.sendFile()`
+* Added support for adding multiple links with the same rel with `res.links()`
+* Performance: Use loop for acceptParams
+* [body-parser@2.2.0](https://github.com/expressjs/body-parser/releases/tag/v2.2.0)
+ * Remove legacy node.js support checks for Brotli & `AsyncLocalStorage`
+ * Remove `unpipe` & `destroy`
+* [router@2.2.0](https://github.com/pillarjs/router/releases/tag/v2.2.0)
+ * Restore `debug`. Now with the `router` scope instead of `express`.
+ * Remove legacy node.js support checks for `setImmediate`
+ * Deprecate non-native promise support
+ * Remove `after`, `safe-buffer`, `array-flatten`, `setprotoypeof`, `methods`, `utils-merge`
+* [finalhandler@2.1.0](https://github.com/pillarjs/finalhandler/releases/tag/v2.1.0)
+ * Remove legacy node.js support checks for `headersSent`, `setImmediate`, & http2 support
+ * Remove `unpipe`
+* Transitioned all remaining dependencies to use `^` ranges instead of locked versions
+* Add package.json funding field to highlight our OpenCollective
+* See [Changelog v5.1.0](https://github.com/expressjs/express/releases/tag/v5.1.0)
+### 5.0.1 - Release date: 2024-10-08
+{: id="5.0.1"}
+
+The 5.0.1 patch release includes one security fix:
+
+* Update [jshttps/cookie](https://www.npmjs.com/package/cookie) to address a [vulnerability](https://github.com/advisories/GHSA-pxg6-pf52-xh8x).
+
+### 5.0.0 - Release date: 2024-09-09
+{: id="5.0.0"}
+
+Check the [migration guide](/{{page.lang}}/guide/migrating-5.html) with all the changes in this new version of Express.
+
+## Express v4
+{: id="4.x"}
+
+### 4.21.2 - Release date: 2024-11-06
+{: id="4.21.2"}
+
+The 4.21.2 patch release includes one security fix:
+
+* Update [pillajs/path-to-regexp](https://www.npmjs.com/package/path-to-regexp) to address a [vulnerability](https://github.com/advisories/GHSA-rhx6-c78j-4q9w).
+
+### 4.21.1 - Release date: 2024-10-08
+{: id="4.21.1"}
+
+The 4.21.1 patch release includes one security fix:
+
+* Update [jshttps/cookie](https://www.npmjs.com/package/cookie) to address a [vulnerability](https://github.com/advisories/GHSA-pxg6-pf52-xh8x).
+
+### 4.21.0 - Release date: 2024-09-11
+{: id="4.21.0"}
+
+The 4.21.0 minor release includes one new feature:
+
+* Deprecate `res.location("back")` and `res.redirect("back")` magic string
+
+### 4.20.0 - Release date: 2024-09-10
+{: id="4.20.0"}
+
+The 4.20.0 minor release includes bug fixes and some new features, including:
+
+* The [`res.clearCookie()` method](/{{ page.lang }}/4x/api.html#res.clearCookie) deprecates `options.maxAge` and `options.expires` options.
+* The [`res.redirect()` method](/{{ page.lang }}/4x/api.html#res.redirect) removes HTML link rendering.
+* The [`express.urlencoded()` method](/{{ page.lang }}/4x/api.html#express.urlencoded) method now has a depth level of `32`, whereas it was previously `Infinity`.
+* Adds support for named matching groups in the routes using a regex
+* Removes encoding of `\`, `|`, and `^` to align better with URL spec
+
+For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4200--2024-09-10)
+
+### 4.19.2 - Release date: 2024-03-25
+{: id="4.19.2"}
+
+* Improved fix for open redirect allow list bypass
+
+For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4192--2024-03-25)
+
+### 4.19.1 - Release date: 2024-03-20
+{: id="4.19.1"}
+
+* Allow passing non-strings to res.location with new encoding handling checks
+
+For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4191--2024-03-20)
+
+### 4.19.0 - Release date: 2024-03-20
+{: id="4.19.0"}
+
+* Prevent open redirect allow list bypass due to encodeurl
+* deps: cookie@0.6.0
+
+For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4190--2024-03-20)
+
+### 4.18.3 - Release date: 2024-02-29
+{: id="4.18.3"}
+
+The 4.18.3 patch release includes the following bug fix:
+
+
|