Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 23f4c69

Browse files
committed
Using built-in JSON parser
1 parent d543d4b commit 23f4c69

File tree

4 files changed

+18
-9
lines changed

4 files changed

+18
-9
lines changed

week3/README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,20 @@ Documentation:
5151

5252
## Building a REST API for To-Dos
5353

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+
5464
### To-Do API
5565

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.
5868

5969
There are 4 [CRUD](https://en.wikipedia.org/wiki/Create%2C_read%2C_update_and_delete)
6070
actions:

week3/lecture/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
{
22
"name": "hyf-node-week-3-todo",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "HackYourFuture Node.js Week 3 - To-Do App",
55
"repository": "https://github.com/HackYourFuture/nodejs.git",
66
"main": "src/index.js",
77
"author": "George Sapkin",
88
"license": "MIT",
99
"dependencies": {
10-
"body-parser": "^1.18.2",
1110
"express": "^4.16.2",
1211
"uuid": "^3.2.1"
1312
},

week3/lecture/src/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use strict';
22

3-
const bodyParser = require('body-parser');
4-
const Express = require('express');
3+
const Express = require('express');
54

65
// import our CRUD actions
76
const {
@@ -19,9 +18,10 @@ const TODO_SLUG = 'todos';
1918

2019
const todo = new Todo(FILENAME);
2120

22-
const app = Express();
21+
const app = new Express();
2322

24-
app.use(bodyParser.json());
23+
// Use built-in JSON middleware to automatically parse JSON
24+
app.use(Express.json());
2525

2626
app.post(`/${TODO_SLUG}`, createTodo.bind(null, todo));
2727
app.get(`/${TODO_SLUG}`, readTodos.bind(null, todo));

week3/lecture/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ balanced-match@^1.0.0:
102102
version "1.0.0"
103103
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
104104

105-
[email protected], body-parser@^1.18.2:
105+
106106
version "1.18.2"
107107
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.18.2.tgz#87678a19d84b47d859b83199bd59bce222b10454"
108108
dependencies:

0 commit comments

Comments
 (0)