You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/1/es/part1d.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1132,7 +1132,7 @@ Programar es difícil, por eso usaré todos los medios posibles para hacerlo má
1132
1132
1133
1133
<h3> Ejercicios 1.6.-1.14.</h3>
1134
1134
1135
-
Envía tus soluciones a los ejercicios enviando primero su código a GitHub y luego marcando los ejercicios completados en el [sistema de envío de ejercicios](https://studies.cs.helsinki.fi/stats/courses/fullstackopen).
1135
+
Envía tus soluciones a los ejercicios enviando primero tu código a GitHub y luego marcando los ejercicios completados en el [sistema de envío de ejercicios](https://studies.cs.helsinki.fi/stats/courses/fullstackopen).
1136
1136
1137
1137
Recuerda, envía **todos** los ejercicios de una parte **en una sola presentación**. Una vez que hayas enviado tus soluciones para una parte, **ya no podrás enviar más ejercicios a esa parte**.
1138
1138
@@ -1277,7 +1277,7 @@ Entonces realiza las acciones necesarias para que la advertencia desaparezca. In
1277
1277
1278
1278
<h4>1.12*: anecdotes, paso 1</h4>
1279
1279
1280
-
El mundo de la ingeniería de software está lleno con[anécdotas](http://www.comp.nus.edu.sg/~damithch/pages/SE-quotes.htm) que destilan verdades atemporales de nuestro campo en breves frases.
1280
+
El mundo de la ingeniería de software está lleno de[anécdotas](http://www.comp.nus.edu.sg/~damithch/pages/SE-quotes.htm) que destilan verdades atemporales de nuestro campo en breves frases.
1281
1281
1282
1282
Expande la siguiente aplicación agregando un botón en el que se pueda hacer clic para mostrar una anécdota <i>aleatoria</i> del campo de la ingeniería de software:
Copy file name to clipboardExpand all lines: src/content/3/en/part3a.md
+16-19Lines changed: 16 additions & 19 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -146,7 +146,7 @@ Let's take a closer look at the first line of the code:
146
146
consthttp=require('http')
147
147
```
148
148
149
-
In the first row, the application imports Node's built-in [web server](https://nodejs.org/docs/latest-v8.x/api/http.html) module. This is practically what we have already been doing in our browser-side code, but with a slightly different syntax:
149
+
In the first row, the application imports Node's built-in [web server](https://nodejs.org/docs/latest-v18.x/api/http.html) module. This is practically what we have already been doing in our browser-side code, but with a slightly different syntax:
The code uses the _createServer_ method of the [http](https://nodejs.org/docs/latest-v8.x/api/http.html) module to create a new web server. An <i>event handler</i> is registered to the server that is called <i>every time</i> an HTTP request is made to the server's address <http://localhost:3001>.
170
+
The code uses the _createServer_ method of the [http](https://nodejs.org/docs/latest-v18.x/api/http.html) module to create a new web server. An <i>event handler</i> is registered to the server that is called <i>every time</i> an HTTP request is made to the server's address <http://localhost:3001>.
171
171
172
172
The request is responded to with the status code 200, with the <i>Content-Type</i> header set to <i>text/plain</i>, and the content of the site to be returned set to <i>Hello World</i>.
173
173
@@ -224,7 +224,7 @@ When we open the browser, the displayed format is exactly the same as in [part 2
224
224
225
225
### Express
226
226
227
-
Implementing our server code directly with Node's built-in [http](https://nodejs.org/docs/latest-v8.x/api/http.html) web server is possible. However, it is cumbersome, especially once the application grows in size.
227
+
Implementing our server code directly with Node's built-in [http](https://nodejs.org/docs/latest-v18.x/api/http.html) web server is possible. However, it is cumbersome, especially once the application grows in size.
228
228
229
229
Many libraries have been developed to ease server-side development with Node, by offering a more pleasing interface to work with the built-in http module. These libraries aim to provide a better abstraction for general use cases we usually require to build a backend server. By far the most popular library intended for this purpose is [express](http://expressjs.com).
230
230
@@ -247,7 +247,7 @@ The dependency is also added to our <i>package.json</i> file:
247
247
248
248
The source code for the dependency is installed in the <i>node\_modules</i> directory located at the root of the project. In addition to express, you can find a great number of other dependencies in the directory:
249
249
250
-

250
+

251
251
252
252
These are the dependencies of the express library and the dependencies of all of its dependencies, and so forth. These are called the [transitive dependencies](https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/) of our project.
253
253
@@ -257,7 +257,7 @@ The version 4.18.2 of express was installed in our project. What does the caret
257
257
"express": "^4.18.2"
258
258
```
259
259
260
-
The versioning model used in npm is called [semantic versioning](https://docs.npmjs.com/getting-started/semantic-versioning).
260
+
The versioning model used in npm is called [semantic versioning](https://docs.npmjs.com/about-semantic-versioning).
261
261
262
262
The caret in the front of <i>^4.18.2</i> means that if and when the dependencies of a project are updated, the version of express that is installed will be at least <i>4.18.2</i>. However, the installed version of express can also have a larger <i>patch</i> number (the last number), or a larger <i>minor</i> number (the middle number). The major version of the library indicated by the first <i>major</i> number must be the same.
263
263
@@ -301,7 +301,7 @@ app.listen(PORT, () => {
301
301
})
302
302
```
303
303
304
-
To get the new version of our application into use, we have to restart the application.
304
+
To get the new version of our application into use, first we have to restart it.
305
305
306
306
The application did not change a whole lot. Right at the beginning of our code, we're importing _express_, which this time is a <i>function</i> that is used to create an express application stored in the _app_ variable:
307
307
@@ -354,7 +354,7 @@ The experiment shown below illustrates this point:
354
354
355
355

356
356
357
-
The experiment above was done in the interactive [node-repl](https://nodejs.org/docs/latest-v8.x/api/repl.html). You can start the interactive node-repl by typing in _node_ in the command line. The repl is particularly useful for testing how commands work while you're writing application code. I highly recommend this!
357
+
The experiment above was done in the interactive [node-repl](https://nodejs.org/docs/latest-v18.x/api/repl.html). You can start the interactive node-repl by typing in _node_ in the command line. The repl is particularly useful for testing how commands work while you're writing application code. I highly recommend this!
358
358
359
359
### nodemon
360
360
@@ -632,7 +632,7 @@ If you use *IntelliJ WebStorm* instead, you can use a similar procedure with its
632
632
633
633
### Receiving data
634
634
635
-
Next, let's make it possible to add new notes to the server. Adding a note happens by making an HTTP POST request to the address <http://localhost:3001/api/notes>, and by sending all the information for the new note in the request [body](https://www.w3.org/Protocols/rfc2616/rfc2616-sec7.html#sec7) in JSON format.
635
+
Next, let's make it possible to add new notes to the server. Adding a note happens by making an HTTP POST request to the address <http://localhost:3001/api/notes>, and by sending all the information for the new note in the request [body](https://www.rfc-editor.org/rfc/rfc9112#name-message-body) in JSON format.
636
636
637
637
To access the data easily, we need the help of the express [json-parser](https://expressjs.com/en/api.html) that we can use with the command _app.use(express.json())_.
638
638
@@ -799,8 +799,6 @@ If the data saved in the _body_ variable has the <i>important</i> property, the
799
799
800
800
You can find the code for our current application in its entirety in the <i>part3-1</i> branch of [this GitHub repository](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part3-1).
801
801
802
-
The code for the current state of the application is specified in branch [part3-1](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part3-1).
803
-
804
802

805
803
806
804
If you clone the project, run the _npm install_ command before starting the application with _npm start_ or _npm run dev_.
@@ -828,7 +826,6 @@ What exactly is happening in that line of code? <em>notes.map(n => n.id)</em> cr
828
826
829
827
<divclass="tasks">
830
828
831
-
832
829
### Exercises 3.1.-3.6.
833
830
834
831
**NB:** It's recommended to do all of the exercises from this part into a new dedicated git repository, and place your source code right at the root of the repository. Otherwise, you will run into problems in exercise 3.10.
@@ -837,7 +834,7 @@ What exactly is happening in that line of code? <em>notes.map(n => n.id)</em> cr
837
834
838
835
**Strong recommendation:** When you are working on backend code, always keep an eye on what's going on in the terminal that is running your application.
839
836
840
-
#### 3.1: Phonebook backend step1
837
+
#### 3.1: Phonebook backend step 1
841
838
842
839
Implement a Node application that returns a hardcoded list of phonebook entries from the address <http://localhost:3001/api/persons>.
843
840
@@ -878,7 +875,7 @@ The application must be started with the command _npm start_.
878
875
879
876
The application must also offer an _npm run dev_ command that will run the application and restart the server whenever changes are made and saved to a file in the source code.
880
877
881
-
#### 3.2: Phonebook backend step2
878
+
#### 3.2: Phonebook backend step 2
882
879
883
880
Implement a page at the address <http://localhost:3001/info> that looks roughly like this:
884
881
@@ -890,25 +887,25 @@ There can only be one response.send() statement in an Express app route. Once yo
890
887
891
888
To include a line space in the output, use `<br/>` tag, or wrap the statements in `<p>` tags.
892
889
893
-
#### 3.3: Phonebook backend step3
890
+
#### 3.3: Phonebook backend step 3
894
891
895
892
Implement the functionality for displaying the information for a single phonebook entry. The url for getting the data for a person with the id 5 should be <http://localhost:3001/api/persons/5>
896
893
897
894
If an entry for the given id is not found, the server has to respond with the appropriate status code.
898
895
899
-
#### 3.4: Phonebook backend step4
896
+
#### 3.4: Phonebook backend step 4
900
897
901
898
Implement functionality that makes it possible to delete a single phonebook entry by making an HTTP DELETE request to the unique URL of that phonebook entry.
902
899
903
900
Test that your functionality works with either Postman or the Visual Studio Code REST client.
904
901
905
-
#### 3.5: Phonebook backend step5
902
+
#### 3.5: Phonebook backend step 5
906
903
907
904
Expand the backend so that new phonebook entries can be added by making HTTP POST requests to the address <http://localhost:3001/api/persons>.
908
905
909
906
Generate a new id for the phonebook entry with the [Math.random](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) function. Use a big enough range for your random values so that the likelihood of creating duplicate ids is small.
910
907
911
-
#### 3.6: Phonebook backend step6
908
+
#### 3.6: Phonebook backend step 6
912
909
913
910
Implement error handling for creating new entries. The request is not allowed to succeed, if:
914
911
@@ -1005,15 +1002,15 @@ You can find the code for our current application in its entirety in the <i>part
1005
1002
1006
1003
### Exercises 3.7.-3.8.
1007
1004
1008
-
#### 3.7: Phonebook backend step7
1005
+
#### 3.7: Phonebook backend step 7
1009
1006
1010
1007
Add the [morgan](https://github.com/expressjs/morgan) middleware to your application for logging. Configure it to log messages to your console based on the <i>tiny</i> configuration.
1011
1008
1012
1009
The documentation for Morgan is not the best, and you may have to spend some time figuring out how to configure it correctly. However, most documentation in the world falls under the same category, so it's good to learn to decipher and interpret cryptic documentation in any case.
1013
1010
1014
1011
Morgan is installed just like all other libraries with the _npm install_ command. Taking morgan into use happens the same way as configuring any other middleware by using the _app.use_ command.
1015
1012
1016
-
#### 3.8*: Phonebook backend step8
1013
+
#### 3.8*: Phonebook backend step 8
1017
1014
1018
1015
Configure morgan so that it also shows the data sent in HTTP POST requests:
0 commit comments