Skip to content

Commit 40a38e0

Browse files
github-actions[bot]create-or-update-pull-requestbjohansebas
authored
i18n: new crowdin translations (#2542)
Co-authored-by: Create or Update Pull Request Action <create-or-update-pull-request@users.noreply.github.com> Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
1 parent aad3091 commit 40a38e0

381 files changed

Lines changed: 12274 additions & 8876 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/content/docs/de/4x/guide/debugging.mdx‎

Lines changed: 103 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ description: Erfahren Sie, wie Sie Debugging-Logs in Express.js-Anwendungen akti
44
---
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
7+
import PackageManagerCommand from '@components/patterns/PackageManagerCommand/PackageManagerCommand.astro';
78

89
Um alle internen Logs zu sehen, die in Express verwendet werden, setzen Sie die Umgebungsvariable `DEBUG` auf
910
`express:*` beim Starten Ihrer App.
@@ -86,22 +87,119 @@ Wenn eine Anfrage an die App gestellt wird, sehen Sie die im Express-Code angege
8687

8788
Um die Protokolle nur von der Router-Implementierung zu sehen, setzen Sie den Wert `DEBUG` auf `express:router`. Um Protokolle nur von der Anwendungsimplementierung zu sehen, setzten Sie den Wert von `DEBUG` auf `express:application`, und so weiter.
8889

89-
## Anwendungen generiert von `Express`
90+
## Using `debug` in your own code
9091

91-
Eine Anwendung, die durch den Befehl `express generiert` erzeugt wird, benutzt das Modul `debug` und sein Debug-Namensraum wird auf den Namen der Anwendung übertragen.
92+
The same [debug](https://www.npmjs.com/package/debug) module that Express uses internally is available for your application code. Install it, create one or more loggers scoped to a namespace of your choosing, and call them wherever you would otherwise use `console.log`:
9293

93-
Wenn Sie zum Beispiel die App mit `$ express Beispiel-App` erstellt haben, können Sie die Debug-Anweisungen mit folgendem Befehl aktivieren:
94+
<PackageManagerCommand command="npm install debug" />
95+
96+
```cjs title="index.cjs"
97+
const express = require('express');
98+
const debug = require('debug')('myapp:server');
99+
100+
const app = express();
101+
102+
app.get('/', (req, res) => {
103+
debug('handling request from %s', req.ip);
104+
res.send('Hello World!');
105+
});
106+
107+
app.listen(3000, () => {
108+
debug('listening on port 3000');
109+
});
110+
```
111+
112+
```mjs title="index.mjs"
113+
import express from 'express';
114+
import debugModule from 'debug';
115+
116+
const debug = debugModule('myapp:server');
117+
const app = express();
118+
119+
app.get('/', (req, res) => {
120+
debug('handling request from %s', req.ip);
121+
res.send('Hello World!');
122+
});
123+
124+
app.listen(3000, () => {
125+
debug('listening on port 3000');
126+
});
127+
```
128+
129+
These statements print nothing by default. Enable them through the same `DEBUG` environment variable, using your own namespace:
94130

95131
```bash
96-
$ DEBUG=sample-app:* node ./bin/www
132+
$ DEBUG=myapp:* node index.js
97133
```
98134

99135
Sie können mehr als einen Debug-Namensraum angeben, indem Sie eine kommaseparierte Namensliste zuweisen:
100136

101137
```bash
102-
$ DEBUG=http,mail,express:* node index.js
138+
$ DEBUG=myapp:*,express:router node index.js
139+
```
140+
141+
## Setting DEBUG in your IDE
142+
143+
The `DEBUG` environment variable can be set by any process launcher that supports environment variables, including the run and debug configurations of your IDE. For example, in VS Code you can set it in the `env` property of a launch configuration:
144+
145+
```json title=".vscode/launch.json"
146+
{
147+
"type": "node",
148+
"request": "launch",
149+
"name": "Launch Express app",
150+
"program": "${workspaceFolder}/index.js",
151+
"env": { "DEBUG": "express:*" }
152+
}
103153
```
104154

155+
See [Node.js debugging in VS Code](https://code.visualstudio.com/docs/nodejs/nodejs-debugging) for the full list of launch options.
156+
157+
## Using the Node.js inspector
158+
159+
Debug logs show what the app did; for stepping through your code with breakpoints, use the built-in Node.js inspector. Start your app with the `--inspect` flag:
160+
161+
```bash
162+
$ node --inspect index.js
163+
```
164+
165+
Then attach a debugging client, such as Chrome DevTools (open `chrome://inspect`), VS Code, or any other inspector-capable tool, to set breakpoints in your route handlers and middleware, step through code, and inspect variables.
166+
167+
If you need to debug something that happens during startup, use `--inspect-brk` instead, which pauses execution on the first line until a debugger attaches. See the [Node.js debugging guide](https://nodejs.org/learn/getting-started/debugging) for details.
168+
169+
## Debugging the HTTP layer
170+
171+
Express runs on top of the Node.js `http` module, which has its own debugging facilities that work with any Express app.
172+
173+
Setting the `NODE_DEBUG` environment variable to `http` makes Node.js print internal logs from the HTTP layer, such as connection handling and socket events:
174+
175+
```bash
176+
$ NODE_DEBUG=http node index.js
177+
```
178+
179+
You can combine it with other subsystems, such as `net` or `stream`, in a comma-separated list. Be aware that this output can expose sensitive data such as authentication headers, so use it only in development.
180+
181+
## Diagnostics channels
182+
183+
Node.js publishes an event for every HTTP request through the [diagnostics_channel](https://nodejs.org/api/diagnostics_channel.html#http) module, which you can subscribe to without patching Express or adding middleware:
184+
185+
```cjs title="index.cjs"
186+
const { subscribe } = require('node:diagnostics_channel');
187+
188+
subscribe('http.server.request.start', ({ request }) => {
189+
console.log(`${request.method} ${request.url}`);
190+
});
191+
```
192+
193+
```mjs title="index.mjs"
194+
import { subscribe } from 'node:diagnostics_channel';
195+
196+
subscribe('http.server.request.start', ({ request }) => {
197+
console.log(`${request.method} ${request.url}`);
198+
});
199+
```
200+
201+
Other built-in channels cover the rest of the request lifecycle, such as `http.server.response.finish`, and the client side of `http.request` calls. See the [diagnostics_channel documentation](https://nodejs.org/api/diagnostics_channel.html#http) for the full list.
202+
105203
## Erweiterte Optionen
106204

107205
Wenn Sie über Node.js laufen, können Sie ein paar Umgebungsvariablen festlegen, die das Verhalten der Debug-Protokollierung ändern:

‎src/content/docs/de/4x/guide/error-handling.mdx‎

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -62,29 +62,39 @@ app.get('/', (req: Request, res: Response, next: NextFunction) => {
6262
});
6363
```
6464

65-
Starting with Express 5, route handlers and middleware that return a Promise
66-
will call `next(value)` automatically when they reject or throw an error.
67-
Zum Beispiel:
65+
Errors from rejected promises are not passed to `next` automatically, and this includes `async` functions: if an `async` route handler throws or awaits a rejected promise, the rejection is unhandled, which crashes the process on current Node.js versions. You must catch the error yourself and pass it to Express:
6866

6967
```js
7068
app.get('/user/:id', async (req, res, next) => {
71-
const user = await getUserById(req.params.id);
72-
res.send(user);
69+
try {
70+
const user = await getUserById(req.params.id);
71+
res.send(user);
72+
} catch (err) {
73+
next(err);
74+
}
7375
});
7476
```
7577

7678
```ts
7779
import { type Request, type Response, type NextFunction } from 'express';
7880

7981
app.get('/user/:id', async (req: Request, res: Response, next: NextFunction) => {
80-
const user = await getUserById(req.params.id);
81-
res.send(user);
82+
try {
83+
const user = await getUserById(req.params.id);
84+
res.send(user);
85+
} catch (err) {
86+
next(err);
87+
}
8288
});
8389
```
8490

85-
Wenn `getUserById` einen Fehler oder eine Ablehnung, wird `next` entweder mit
86-
dem Wurffehler oder dem abgelehnten Wert aufgerufen. Wenn kein abgelehnter Wert angegeben wird, wird `next`
87-
mit einem Standard-Fehlerobjekt aufgerufen, das vom Express-Router bereitgestellt wird.
91+
<Alert type="info">
92+
93+
Consider [updating to Express 5](/guide/migrating-5), where route handlers and middleware that
94+
return a Promise call `next(value)` automatically when they reject or throw an error, making the
95+
`try...catch` above unnecessary.
96+
97+
</Alert>
8898

8999
Wenn du etwas an die `next()` Funktion übergibt (außer den String `'route'`),
90100
Express betrachtet die aktuelle Anfrage als Fehler und überspringt alle
@@ -180,9 +190,7 @@ app.get('/', (req: Request, res: Response, next: NextFunction) => {
180190
});
181191
```
182192

183-
Da Versprechungen automatisch sowohl synchrone Fehler als auch abgelehnte Versprechungen fangen,
184-
du kannst einfach `next` angeben, da der letzte Catch Handler und Express Fehler fängt an
185-
weil der Catch-Handler den Fehler als erstes Argument angibt.
193+
If a callback in the promise chain throws, the chain turns that exception into a rejection, which travels down to the final `.catch`. There, passing `next` as the handler is enough: `.catch` calls it with the error as its first argument, which is exactly the argument `next` expects, so the error reaches Express.
186194

187195
Sie können auch eine Kette von Handlern verwenden, um sich auf synchrone Fehler
188196
zu stützen, indem Sie den asynchronen Code auf etwas Triviales reduzieren. Zum Beispiel:
@@ -219,8 +227,8 @@ app.get('/', [
219227
]);
220228
```
221229

222-
Das obige Beispiel hat ein paar triviale Anweisungen aus dem Aufruf `readFile`
223-
. If `readFile` causes an error, then it passes the error to Express, otherwise you
230+
The above example contains a couple of trivial statements following the `readFile`
231+
call. If `readFile` causes an error, then it passes the error to Express, otherwise you
224232
quickly return to the world of synchronous error handling in the next handler
225233
in the chain. Dann versucht das obige Beispiel die Daten zu verarbeiten. Wenn dies fehlschlägt, fängt der Synchron-Fehlerhandler
226234
ihn ab. Hätten Sie diese Verarbeitung innerhalb von
@@ -424,7 +432,7 @@ function logErrors(err: Error, req: Request, res: Response, next: NextFunction)
424432

425433
Auch in diesem Beispiel wird `clientErrorHandler` wie folgt definiert; in diesem Fall wird der Fehler explizit an den nächsten weitergegeben.
426434

427-
Beachten Sie, dass, wenn _not_ in einer Fehlerbehandlungsfunktion "Weiter" aufruft, Sie dafür verantwortlich sind, die Antwort zu schreiben (und zu beenden). Andernfalls werden diese Anträge "hängen" und sind nicht für die Müllsammlung berechtigt.
435+
Notice that when you do not call `next` in an error-handling function, you are responsible for writing (and ending) the response. Andernfalls werden diese Anträge "hängen" und sind nicht für die Müllsammlung berechtigt.
428436

429437
```js
430438
function clientErrorHandler(err, req, res, next) {

‎src/content/docs/de/4x/guide/overriding-express-api.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Discover how to customize and extend the Express.js API by overridi
55

66
import Alert from '@components/primitives/Alert/Alert.astro';
77

8-
Die Express API besteht aus verschiedenen Methoden und Eigenschaften auf den Anfrage- und Antwort-Objekten. Diese werden vom Prototyp geerbt. Es gibt zwei Erweiterungspunkte für die Express API:
8+
The Express API consists of various methods and properties on the [request](/api/request) and [response](/api/response) objects. Diese werden vom Prototyp geerbt. Es gibt zwei Erweiterungspunkte für die Express API:
99

1010
1. Die globalen Prototypen unter `express.request` und `express.response`.
1111
2. App-spezifische Prototypen bei `app.request` und `app.response`.

‎src/content/docs/de/4x/guide/routing.mdx‎

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ _Routing_ bezieht sich darauf, wie die Endpunkte einer Anwendung (URIs) auf Kund
99
Für eine Einführung in das Routing siehe [Basic routing](/starter/basic-routing).
1010

1111
Du definierst Routing, indem du Methoden des Express `app` Objekts verwendest, die den HTTP-Methoden entsprechen;
12-
zum Beispiel, `app. et()` um GET-Anfragen und `app.post` zu behandeln, um POST-Anfragen zu bearbeiten. For a full list,
12+
zum Beispiel, `app.get()` um GET-Anfragen und `app.post` zu behandeln, um POST-Anfragen zu bearbeiten. For a full list,
1313
see [app.METHOD](/api/application#appmethod). You can also use [app.all()](/api/application#appall) to handle all HTTP methods and [app.use()](/api/application#appuse) to
1414
specify middleware as the callback function (See [Using middleware](/guide/using-middleware) for details).
1515

16-
These routing methods specify a callback function (sometimes called a "handler function") that Express automatically runs when the application receives a request matching the specified route (endpoint) and HTTP method. Mit anderen Worten, die Anwendung "lauscht" für Anforderungen, die mit der angegebenen Route(s) und Methode(n) übereinstimmen und wenn es ein Spiel erkennt, ruft es die angegebene Callback-Funktion auf.
16+
Mit anderen Worten, die Anwendung "lauscht" für Anforderungen, die mit der angegebenen Route(s) und Methode(n) übereinstimmen und wenn es ein Spiel erkennt, ruft es die angegebene Callback-Funktion auf. Mit anderen Worten, die Anwendung "lauscht" für Anforderungen, die mit der angegebenen Route(s) und Methode(n) übereinstimmen und wenn es ein Spiel erkennt, ruft es die angegebene Callback-Funktion auf.
1717

1818
In der Tat können die Routing-Methoden mehr als eine Callback-Funktion als Argumente haben.
1919
Mit mehreren Callback-Funktionen, es ist wichtig, `next` als Argument für die Callback-Funktion zur Verfügung zu stellen und dann `next()` im Körper der Funktion aufzurufen, um die Steuerung
@@ -88,7 +88,7 @@ app.post('/', (req: Request, res: Response) => {
8888
Express unterstützt Methoden, die allen HTTP-Anfragemethoden entsprechen: `get`, `post` und so weiter.
8989
For a full list, see [app.METHOD](/api/application#appmethod).
9090

91-
Es gibt eine spezielle Routing-Methode, `app.all()`, die benutzt wird, um Middleware-Funktionen an einem Pfad für _all_ HTTP-Requestmethoden zu laden. For example, the following handler is executed for requests to the route `"/secret"` whether using `GET`, `QUERY`, `POST`, `PUT`, `DELETE`, or any other HTTP request method supported in the [http module](https://nodejs.org/api/http.html#http_http_methods).
91+
Es gibt eine spezielle Routing-Methode, `app.all()`, die benutzt wird, um Middleware-Funktionen an einem Pfad für _all_ HTTP-Requestmethoden zu laden. For example, the following handler is executed for requests to the route `"/secret"` whether using `GET`, `QUERY`, `POST`, `PUT`, `DELETE`, or any other HTTP request method supported in the [http module](https://nodejs.org/api/http.html#httpmethods).
9292

9393
```js
9494
app.all('/secret', (req, res, next) => {
@@ -108,7 +108,7 @@ app.all('/secret', (req: Request, res: Response, next: NextFunction) => {
108108

109109
## Routenpfade
110110

111-
Routenpfade in Kombination mit einer Anfragemethode definieren die Endpunkte, an denen Anfragen gestellt werden können. Routenpfade können Zeichenketten, Zeichenkettenmuster oder reguläre Ausdrücke sein.
111+
Routenpfade in Kombination mit einer Anfragemethode definieren die Endpunkte, an denen Anfragen gestellt werden können. Routenpfade können Zeichenketten, Zeichenkettenmuster oder reguläre Ausdrücke sein. They can also capture values from the URL, as described in [Route parameters](#route-parameters) below.
112112

113113
<Alert type="info">
114114

@@ -235,6 +235,26 @@ app.get('/ab(cd)?e', (req: Request, res: Response) => {
235235
});
236236
```
237237

238+
A wildcard (`*`) on its own matches anything at its position, including entire subpaths. For example, this route path will match `/file/style.css` as well as `/file/javascripts/jquery.js`. Wildcards are unnamed, so the matched value is available as `req.params[0]` instead of a named parameter.
239+
240+
```js
241+
app.get('/file/*', (req, res) => {
242+
// GET /file/javascripts/jquery.js
243+
res.send(req.params[0]);
244+
// => 'javascripts/jquery.js'
245+
});
246+
```
247+
248+
```ts
249+
import { type Request, type Response } from 'express';
250+
251+
app.get('/file/*', (req: Request, res: Response) => {
252+
// GET /file/javascripts/jquery.js
253+
res.send(req.params[0]);
254+
// => 'javascripts/jquery.js'
255+
});
256+
```
257+
238258
### Routenpfade basierend auf regulären Ausdrücken
239259

240260
<Alert type="warnung">
@@ -348,6 +368,14 @@ Zeichen mit einem zusätzlichen Backslash maskieren, zum Beispiel `\d+`.
348368
The [`*`](https://github.com/expressjs/express/issues/2495) character in regular expressions is not interpreted in the usual way. Benutze `{0,}` anstelle von `*`.
349369
</Alert>
350370

371+
Unlike named route parameters, wildcard (`*`) matches in [string patterns](#route-paths-based-on-string-patterns) and capture groups in regular expressions are unnamed: their values are available by position, as `req.params[0]`, `req.params[1]`, and so on.
372+
373+
```
374+
Route path: /file/*/size/*
375+
Request URL: http://localhost:3000/file/javascripts/jquery.js/size/large
376+
req.params: { "0": "javascripts/jquery.js", "1": "large" }
377+
```
378+
351379
## Routenhandler
352380

353381
Du kannst mehrere Callback-Funktionen bereitstellen, die sich wie [middleware](/guide/using-middleware) verhalten um eine Anfrage zu bearbeiten. Die einzige Ausnahme ist, dass diese Callbacks `next('route')` aufrufen könnten, um die restlichen Rufnummern zu umgehen. Sie können diesen Mechanismus nutzen, um Vorbedingungen auf einer Route aufzuerlegen, dann die Kontrolle an die nachfolgenden Routen übergeben, wenn es keinen Grund gibt, mit der aktuellen Route fortzufahren.
@@ -527,7 +555,7 @@ app.get(
527555

528556
## Antwortmethoden
529557

530-
Die Methoden auf dem Antwortobjekt (`res`) in der folgenden Tabelle können eine Antwort an den Client senden und den Request-Antwort-Zyklus beenden. Wenn keine dieser Methoden von einem Routenhandler aufgerufen wird, bleibt die Client-Anfrage hängen.
558+
The methods on the [response object](/api/response) (`res`) in the following table can send a response to the client, and terminate the request-response cycle. Wenn keine dieser Methoden von einem Routenhandler aufgerufen wird, bleibt die Client-Anfrage hängen.
531559

532560
| Methode | Beschreibung |
533561
| ----------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
@@ -544,7 +572,7 @@ Die Methoden auf dem Antwortobjekt (`res`) in der folgenden Tabelle können eine
544572
## app.route()
545573

546574
Sie können verkettende Routenhandler für einen Routenpfad erstellen, indem Sie `app.route()` verwenden.
547-
Da der Weg an einem einzigen Ort angegeben wird, ist die Schaffung modularer Routen hilfreich, ebenso wie die Reduzierung von Redundanz und Typos. Weitere Informationen über Routen finden Sie unter [Router() documentation](/api/router).
575+
Because the path is specified in a single location, this helps to create modular routes and reduces redundancy and typos. For more information about routes, see the [Router() documentation](/api/router).
548576

549577
Hier ist ein Beispiel für verkettete Routenhandler, die mit `app.route()` definiert werden.
550578

@@ -677,7 +705,7 @@ app.use('/birds', birds);
677705

678706
Die App wird nun in der Lage sein, Anfragen an `/birds` und `/birds/about` zu bearbeiten, aufrufen sowie die Middleware-Funktion `timeLog` aufrufen, die spezifisch für die Route ist.
679707

680-
Aber wenn die übergeordnete Route `/birds` Pfadparameter hat, wird sie standardmäßig nicht von den Unterrouten aus erreichbar sein. To make it accessible, you will need to pass the `mergeParams` option to the Router constructor [reference](/api/application#appuse).
708+
Aber wenn die übergeordnete Route `/birds` Pfadparameter hat, wird sie standardmäßig nicht von den Unterrouten aus erreichbar sein. To make it accessible, you will need to pass the `mergeParams` option to the [Router constructor](/api/express/#expressrouter).
681709

682710
```js
683711
const router = express.Router({ mergeParams: true });

0 commit comments

Comments
 (0)