Skip to content

Commit bcc90f9

Browse files
committed
'Taken into use' is an akward phrase. Replaced it with more natural (and hopefully clearer) wording. Made some other phrasing changes.
1 parent de34caf commit bcc90f9

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/content/3/en/part3a.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ In the first row, the application imports Node's built-in [web server](https://n
152152
import http from 'http'
153153
```
154154

155-
These days, code that runs in the browser uses ES6 modules. Modules are defined with an [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) and taken into use with an [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
155+
These days, code that runs in the browser uses ES6 modules. Modules are defined with an [export](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export) and included in the current file with an [import](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import).
156156

157157
Node.js uses [CommonJS](https://en.wikipedia.org/wiki/CommonJS) modules. The reason for this is that the Node ecosystem needed modules long before JavaScript supported them in the language specification. Currently, Node also supports the use of ES6 modules, but since the support is not quite perfect yet, we'll stick to CommonJS modules.
158158

@@ -956,7 +956,7 @@ Middleware are functions that can be used for handling _request_ and _response_
956956

957957
The json-parser we used earlier takes the raw data from the requests that are stored in the _request_ object, parses it into a JavaScript object and assigns it to the _request_ object as a new property <i>body</i>.
958958

959-
In practice, you can use several middlewares at the same time. When you have more than one, they're executed one by one in the order that they were taken into use in express.
959+
In practice, you can use several middlewares at the same time. When you have more than one, they're executed one by one in the order that they were listed in the application code.
960960

961961
Let's implement our own middleware that prints information about every request that is sent to the server.
962962

@@ -974,15 +974,15 @@ const requestLogger = (request, response, next) => {
974974

975975
At the end of the function body, the _next_ function that was passed as a parameter is called. The _next_ function yields control to the next middleware.
976976

977-
Middleware is taken into use like this:
977+
Middleware is used like this:
978978

979979
```js
980980
app.use(requestLogger)
981981
```
982982

983-
Middleware functions are called in the order that they're taken into use with the express server object's _use_ method. Notice that json-parser is taken into use before the _requestLogger_ middleware, because otherwise <i>request.body</i> will not be initialized when the logger is executed!
983+
Remember, middleware functions are called in the order that they're encountered by the JavaScript engine. Notice that _json-parser_ is listed before _requestLogger_ , because otherwise <i>request.body</i> will not be initialized when the logger is executed!
984984

985-
Middleware functions have to be taken into use before routes if we want them to be executed before the route event handlers are called. There are also situations where we want to define middleware functions after routes. In practice, this means that we are defining middleware functions that are only called if no route handles the HTTP request.
985+
Middleware functions have to be used before routes when we want them to be executed by the route event handlers. Sometimes, we want to use middleware functions after routes. We do this this when the middleware functions are only called if no route handles process the HTTP request.
986986

987987
Let's add the following middleware after our routes. This middleware will be used for catching requests made to non-existent routes. For these requests, the middleware will return an error message in the JSON format.
988988

0 commit comments

Comments
 (0)