Skip to content

Commit b42dc50

Browse files
committed
upodate dependencies examples
1 parent fe8b384 commit b42dc50

File tree

17 files changed

+235
-50
lines changed

17 files changed

+235
-50
lines changed

11 Axios/01_get/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,11 @@ $ mongo
5656

5757
Now we can start the server
5858
$ gulp
59+
60+
* To get running via docker, from project root folder
61+
62+
$ docker-compose up
63+
64+
* To get running server-mock, from ./server-mock
65+
66+
$ npm start

11 Axios/01_get/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"parcel": "^1.8.1"
14+
"parcel": "^1.12.4"
1515
},
1616
"dependencies": {
1717
"axios": "^0.18.0"

11 Axios/02_post/README.md

Lines changed: 54 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,48 @@ export const getBooks = () => {
3535

3636
### 2. Lets change index.html to have a form, so we can post a new book to server.
3737

38-
* Paste this code after _div_ with _books-container id_.
39-
40-
<div class="container-add-book">
41-
<form>
42-
Title:</br>
43-
<input type="text" id="title" name="title" />
44-
<br/>
45-
Genre:</br>
46-
<input type="text" id="genre" name="genre" />
47-
<br/>
48-
Author:</br>
49-
<input type="text" id="author" name="author" />
50-
</br>
51-
Have you read this book?:</br>
52-
<input type="checkbox" id="read" name="read" />
53-
</br></br>
54-
<button id="container-add-book-form-submit">Add book</button>
55-
</form>
56-
</div>
38+
* Edit as follows __.\index.html__.
39+
40+
```html
41+
<!DOCTYPE html>
42+
<html lang="en">
43+
44+
<head>
45+
<meta charset="UTF-8">
46+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
47+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
48+
<title>Document</title>
49+
<link rel="stylesheet" href="./src/content/site.css">
50+
</head>
51+
52+
<body>
53+
<div id="books-container" class="container">
54+
<button id="button-retrieve-books">Retrieve books</button>
55+
</div>
56+
<!-- diff -->
57+
<div class="container-add-book">
58+
<form>
59+
Title:</br>
60+
<input type="text" id="title" name="title" />
61+
<br/>
62+
Genre:</br>
63+
<input type="text" id="genre" name="genre" />
64+
<br/>
65+
Author:</br>
66+
<input type="text" id="author" name="author" />
67+
</br>
68+
Have you read this book?:</br>
69+
<input type="checkbox" id="read" name="read" />
70+
</br></br>
71+
<button id="container-add-book-form-submit">Add book</button>
72+
</form>
73+
</div>
74+
<!-- diff -->
75+
<script src="./src/app.js"></script>
76+
</body>
77+
78+
</html>
79+
```
5780

5881
### 3. Now we have to change app.js
5982

@@ -85,13 +108,21 @@ document.addEventListener('DOMContentLoaded', () => {
85108

86109
### 4. We have to get the server and mongo running in order to get this working.
87110

88-
To get running mongod
111+
* To get running mongod
89112

90-
$ mongod
91-
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
113+
$ mongod "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
92114

93115
To get running mongo console
94116
$ mongo
95117

96-
Now we can rtun the server
118+
Now we can start the server
97119
$ gulp
120+
121+
* To get running via docker, from project root folder
122+
123+
$ docker-compose up
124+
125+
* To get running server-mock, from ./server-mock
126+
127+
$ npm start
128+

11 Axios/02_post/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
<div id="books-container" class="container">
1414
<button id="button-retrieve-books">Retrieve books</button>
1515
</div>
16+
<!-- diff -->
1617
<div class="container-add-book">
1718
<form>
1819
Title:</br>
@@ -30,6 +31,7 @@
3031
<button id="container-add-book-form-submit">Add book</button>
3132
</form>
3233
</div>
34+
<!-- diff -->
3335
<script src="./src/app.js"></script>
3436
</body>
3537

11 Axios/03_callbacks/.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-proposal-class-properties"
4+
]
5+
}

11 Axios/03_callbacks/README.md

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,46 @@
22

33
## 3 Using callbacks
44

5-
### 1. Currently our bookService is doing several things, it is calling the server for data handling the response, and displaying data. Lets start to honor SRP, and start by passing callbacks that could be passed from outsite of our service to segregate responsabilities.
5+
### 1. Update parcel dependenies
6+
7+
Add ./.babelrc
8+
9+
```json
10+
{
11+
"plugins": [
12+
"@babel/plugin-proposal-class-properties"
13+
]
14+
}
15+
```
16+
17+
Update ./package.json
18+
19+
```diff
20+
{
21+
"name": "00_get_started",
22+
"version": "1.0.0",
23+
"description": "",
24+
"main": "app.js",
25+
"scripts": {
26+
"test": "echo \"Error: no test specified\" && exit 1",
27+
"start": "parcel index.html"
28+
},
29+
"keywords": [],
30+
"author": "",
31+
"license": "ISC",
32+
"devDependencies": {
33+
+ "@babel/core": "^7.8.4",
34+
+ "@babel/plugin-proposal-class-properties": "^7.8.3",
35+
"parcel": "^1.12.4"
36+
},
37+
"dependencies": {
38+
"axios": "^0.18.0"
39+
}
40+
}
41+
42+
```
43+
44+
### 2. Currently our bookService is doing several things, it is calling the server for data handling the response, and displaying data. Lets start to honor SRP, and start by passing callbacks that could be passed from outsite of our service to segregate responsabilities.
645

746
```diff bookAPI.js
847
import axios from 'axios';
@@ -82,13 +121,21 @@ document.addEventListener('DOMContentLoaded', () => {
82121

83122
### 3. We have to get the server and mongo running in order to get this working.
84123

85-
To get running mongod
124+
* To get running mongod
86125

87-
$ mongod
88-
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
126+
$ mongod "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
89127

90128
To get running mongo console
91129
$ mongo
92130

93-
Now we can rtun the server
131+
Now we can start the server
94132
$ gulp
133+
134+
* To get running via docker, from project root folder
135+
136+
$ docker-compose up
137+
138+
* To get running server-mock, from ./server-mock
139+
140+
$ npm start
141+

11 Axios/03_callbacks/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"parcel": "^1.8.1"
14+
"@babel/core": "^7.8.4",
15+
"@babel/plugin-proposal-class-properties": "^7.8.3",
16+
"parcel": "^1.12.4"
1517
},
1618
"dependencies": {
1719
"axios": "^0.18.0"

11 Axios/04_promises/.babelrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"plugins": [
3+
"@babel/plugin-proposal-class-properties"
4+
]
5+
}

11 Axios/04_promises/README.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,20 @@ document.addEventListener('DOMContentLoaded', () => {
7777

7878
### 3. We have to get the server and mongo running in order to get this working.
7979

80-
To get running mongod
80+
* To get running mongod
8181

82-
$ mongod
83-
"C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
82+
$ mongod "C:\Program Files\MongoDB\Server\3.4\bin\mongod.exe" --dbpath "D:\mongodb\data"
8483

8584
To get running mongo console
8685
$ mongo
8786

88-
Now we can rtun the server
87+
Now we can start the server
8988
$ gulp
89+
90+
* To get running via docker, from project root folder
91+
92+
$ docker-compose up
93+
94+
* To get running server-mock, from ./server-mock
95+
96+
$ npm start

11 Axios/04_promises/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111
"author": "",
1212
"license": "ISC",
1313
"devDependencies": {
14-
"parcel": "^1.8.1"
14+
"@babel/core": "^7.8.4",
15+
"@babel/plugin-proposal-class-properties": "^7.8.3",
16+
"parcel": "^1.12.4"
1517
},
1618
"dependencies": {
1719
"axios": "^0.18.0"

0 commit comments

Comments
 (0)