Skip to content

Commit 059ea5d

Browse files
committed
adding lessons
1 parent 1a13dac commit 059ea5d

File tree

41 files changed

+226
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+226
-28
lines changed

lessons/02-promises/lecture/NOTES.md

Lines changed: 1 addition & 1 deletion

lessons/03-async-await/lecture/index.ts renamed to lessons/04-async-await/lecture/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,5 @@ function signup(user: User) {
1414
signup({ name: 'brad' }).then(() => {
1515
console.log('✅ User Added')
1616
})
17+
18+
// Remember "top-level" await

lessons/03-async-await/practice/index.final.ts renamed to lessons/04-async-await/practice/index.final.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ async function main() {
3434

3535
// async function getPersonVehicles(id: number): Promise<string[]> {
3636
// const response = await fetch(`https://swapi.dev/api/people/${id}`)
37-
// const person = await response.json()
37+
// const person = await response.json() as Record<string, any>
3838

3939
// // The above could also be written as
4040
// // const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) => response.json())
@@ -74,7 +74,7 @@ async function main() {
7474
// async function getPersonVehicles(id: number): Promise<string[]> {
7575
// const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
7676
// response.json()
77-
// )
77+
// ) as Record<string, any>
7878
// return person.vehicles
7979
// }
8080

lessons/03-async-await/practice/index.ts renamed to lessons/04-async-await/practice/index.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ main()
77
Practice: 1
88
*****************************************/
99

10-
function wait(ms: number) {
11-
return new Promise((resolve) => {
12-
setTimeout(resolve, ms)
13-
})
14-
}
10+
// function wait(ms: number) {
11+
// return new Promise((resolve) => {
12+
// setTimeout(resolve, ms)
13+
// })
14+
// }
1515

16-
// Re-write main to use async/await
16+
// // Re-write main to use async/await
1717

18-
function main() {
19-
wait(1000).then(() => {
20-
console.log('Wait for one second')
21-
})
22-
}
18+
// function main() {
19+
// wait(1000).then(() => {
20+
// console.log('Wait for one second')
21+
// })
22+
// }
2323

2424
/****************************************
2525
Practice: 2
@@ -33,7 +33,7 @@ function main() {
3333

3434
// function getPersonVehicles(id: number): Promise<string[]> {
3535
// return fetch(`https://swapi.dev/api/people/${id}`)
36-
// .then((response) => response.json())
36+
// .then((response) => response.json() as Record<string, any>)
3737
// .then((person) => person.vehicles)
3838
// }
3939

@@ -71,9 +71,9 @@ function main() {
7171
// }
7272

7373
// async function getPersonVehicles(id: number): Promise<string[]> {
74-
// const person = await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
74+
// const person = (await fetch(`https://swapi.dev/api/people/${id}`).then((response) =>
7575
// response.json()
76-
// )
76+
// )) as Record<string, any>
7777
// return person.vehicles
7878
// }
7979

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

package-lock.json

Lines changed: 179 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
{
22
"name": "javascript-node-workshop",
3-
"description": "(c) copyright ReactTraining.com",
43
"private": true,
54
"scripts": {
65
"/////////// NOTES: backslashes in --exec commands for Windows to work": "",
76
"/////////// LECTURES:": "",
87
"lecture-1": "node lessons/01-js-and-node/lecture",
98
"lecture-2": "ts-node lessons/02-promises/lecture/index.ts",
10-
"lecture-3": "ts-node lessons/03-async-await/lecture/index.ts",
11-
"lecture-4": "ts-node lessons/04-cli/lecture/index.ts",
9+
"lecture-3": "",
10+
"lecture-4": "ts-node lessons/04-async-await/lecture/index.ts",
11+
"lecture-5": "ts-node lessons/05-cli/lecture/index.ts",
1212
"/////////// PRACTICES:": "",
1313
"practice-1": "node lessons/01-js-and-node/practice",
1414
"practice-2": "ts-node lessons/02-promises/practice/index.ts",
15-
"practice-3": "ts-node lessons/03-async-await/practice/index.ts",
16-
"practice-4": "ts-node lessons/04-cli/practice/index.ts"
15+
"practice-3": "",
16+
"practice-4": "ts-node lessons/04-async-await/practice/index.ts",
17+
"practice-5": "ts-node lessons/05-cli/practice/index.ts"
18+
},
19+
"dependencies": {
20+
"node-fetch": "^3.3.2",
21+
"readline-sync": "^1.4.10"
1722
},
1823
"devDependencies": {
19-
"ts-node": "^10.9.2"
24+
"@types/node-fetch": "^2.6.11",
25+
"@types/readline-sync": "^1.4.8",
26+
"ts-node": "^10.9.2",
27+
"typescript": "^5.4.5"
2028
},
2129
"prettier": {
2230
"printWidth": 100,

tsconfig.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"compilerOptions": {
3+
"strict": true,
4+
"module": "commonjs",
5+
"esModuleInterop": true,
6+
"jsx": "react",
7+
"target": "ES2020",
8+
"moduleResolution": "node",
9+
// "noEmitOnError": false,
10+
"sourceMap": true,
11+
"skipLibCheck": true,
12+
"lib": ["es2020.promise"]
13+
}
14+
}

0 commit comments

Comments
 (0)