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: week3/LESSONPLAN.md
+92-33Lines changed: 92 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -28,82 +28,141 @@ Additionally, middleware can either terminate the HTTP request or pass it on to
28
28
29
29
**Example**
30
30
31
-
Try out the following code and use Postman to make the request. Show the student the importance of `express.json()`to parse the request and makes the form data available in the `req.body`.
31
+
Try out the following code and show how the middleware gets applied to the request, before it reaches the endpoint `/test`.
Middleware allows the web server to modify the request gets in order to make it better interpretable within the route. For example, when sending form data in a request we want to make sure the server can understand the format it comes in properly. Therefore, we use the middleware `express.json()`.
60
66
61
-
In reality the server does not do everything on its own. Instead it uses services from other servers
- reuse - we do not want to write new code if someone has already done that in the past and we can just use it
67
-
- separation-of-concerns - especially in big organizations like netflix etc
71
+
Web applications are built using many different services. There's no need to have your application's do everything, from authentication to payment processing. To make things easier we use external services, also known as `web APIs`. Such a service can be used through their API, which allows us to get access to certain functionality and data, to use in our own application. This server to server communication through APIs is also known as `consumation` of web APIs.
-Social login is a way for applications to outsource authentication, via services like Facebook or Google (examples are [Udemy](https://www.udemy.com/join/login-popup/), or [Medium](https://medium.com/))
76
+
-Online payment processing is outsourced to services like Stripe or Adyen (examples are [Udemy](https://www.udemy.com/), or [bol.com](https://www.bol.com)))
73
77
74
78
**Exercise**
75
79
76
-
1. Get the image from https://randomfox.ca/floof/ and redirect to it
80
+
Ask students to create a simple Express server:
77
81
78
-
2. Instead of redirecting show it inside HTML
82
+
- With 1 GET endpoint `/github`
83
+
- Inside the route, make an API request using `node-fetch` to `https://api.github.com/users/:username/repos`
84
+
- Replace the `:username:` with your own GitHub user name
85
+
- Respond to the client with the first repository that comes up
86
+
- Use Postman to test your work
79
87
80
-
This is prelude to part 2, mention how it is ugly that the HTML and javascript are all mixed up
88
+
**Essence**
89
+
90
+
Why write everything yourself, when you can make use of other web services? By consuming web APIs we can extend the usability of our application, without the need to do all the work ourselves!
A templating engine is a technology that makes it possible to to create `dynamic` pages. Instead of writing regular HTML, you'll create `templates`. This is similar to HTML, but with one big difference: certain values serve as placeholders. These placeholders will be filled in with actual content, when the page is rendered. The type of content that is chosen depends on the person that's viewing it.
89
99
90
-
Motivation: make a story with a link to last exercise. The js, html and styling code are all intermixed in same file, it is a mess
100
+
**Example**
91
101
92
-
Solution is to use a templating engine to separate the view from the node code but still use the data from node in the view
0 commit comments