File tree 4 files changed +18
-9
lines changed
4 files changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,20 @@ Documentation:
51
51
52
52
## Building a REST API for To-Dos
53
53
54
+ Videos:
55
+
56
+ [ What is REST?] ( http://www.restapitutorial.com/lessons/whatisrest.html )
57
+
58
+ Documentation:
59
+
60
+ [ REST] ( https://en.wikipedia.org/wiki/Representational_state_transfer )
61
+
62
+ [ Learn REST: A RESTful Tutorial] ( http://www.restapitutorial.com/ )
63
+
54
64
### To-Do API
55
65
56
- This week we are going to write an Express application using [ body-parser ] ( https://github.com/expressjs/body-parser )
57
- middleware that automatically parses JSON from request body .
66
+ This week we are going to write an Express application with request body in JSON
67
+ format .
58
68
59
69
There are 4 [ CRUD] ( https://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete )
60
70
actions:
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " hyf-node-week-3-todo" ,
3
- "version" : " 1.0.0 " ,
3
+ "version" : " 1.0.1 " ,
4
4
"description" : " HackYourFuture Node.js Week 3 - To-Do App" ,
5
5
"repository" : " https://github.com/HackYourFuture/nodejs.git" ,
6
6
"main" : " src/index.js" ,
7
7
"author" : " George Sapkin" ,
8
8
"license" : " MIT" ,
9
9
"dependencies" : {
10
- "body-parser" : " ^1.18.2" ,
11
10
"express" : " ^4.16.2" ,
12
11
"uuid" : " ^3.2.1"
13
12
},
Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- const bodyParser = require ( 'body-parser' ) ;
4
- const Express = require ( 'express' ) ;
3
+ const Express = require ( 'express' ) ;
5
4
6
5
// import our CRUD actions
7
6
const {
@@ -19,9 +18,10 @@ const TODO_SLUG = 'todos';
19
18
20
19
const todo = new Todo ( FILENAME ) ;
21
20
22
- const app = Express ( ) ;
21
+ const app = new Express ( ) ;
23
22
24
- app . use ( bodyParser . json ( ) ) ;
23
+ // Use built-in JSON middleware to automatically parse JSON
24
+ app . use ( Express . json ( ) ) ;
25
25
26
26
app . post ( `/${ TODO_SLUG } ` , createTodo . bind ( null , todo ) ) ;
27
27
app . get ( `/${ TODO_SLUG } ` , readTodos . bind ( null , todo ) ) ;
Original file line number Diff line number Diff line change @@ -102,7 +102,7 @@ balanced-match@^1.0.0:
102
102
version "1.0.0"
103
103
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
104
104
105
- [email protected] , body-parser@^1.18.2 :
105
+
106
106
version "1.18.2"
107
107
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454"
108
108
dependencies :
You can’t perform that action at this time.
0 commit comments