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: module1-introduction-to-backend/r1-introduction-to-backend/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -24,7 +24,7 @@ But where does all the data to be displayed on the frontend come from? How is a
24
24
25
25
A backend developer builds and maintains the code that powers those components which together enable the user-facing side of the website to even exist in the first place. Backend developers must be competent with one or more server-side languages such as JavaScript (Node.js), Ruby, Python, PHP or Java, frameworks like ExpressJS, Ruby on Rails, Python Django and databases like MySQL, PostgreSQL or MongoDB. They are also familiar with Linux as a deployment environment and DevOps tools like AWS, GCP, Apache, Nginx, Docker and Kubernetes.
26
26
27
-
Backend developers need to be able to navigate across larger codebases and not get lost in the complexities of what may seem like programming labyrinths. They also need to be very meticulous when making changes to not "break" anything as there are usually delicate dependencies. Even frontend codebases are large and complex with delicate dependencies, but unlike frontend development where the written code translates directly to visual output one can see and interact with, backend development of business logic is often hard to visualise. Therefore to be a good backend developer, you need to be comfortable with dealing with abstracts.
27
+
Backend developers need to be able to navigate across larger codebases and not get lost in the complexities. They also need to be very meticulous when making changes to not "break" anything as there are usually delicate dependencies. Even frontend codebases are large and complex with delicate dependencies, but unlike frontend development where the written code translates directly to visual output one can see and interact with, backend development of business logic is often hard to visualise. Therefore to be a good backend developer, you need to be comfortable with dealing with abstracts.
Let's start diving deeper into what do we mean when we say frontend and backend. The frontend is the code that is executed on the client side. This code runs in the user’s browser and creates the user interface. The backend is the code that runs on the server, receives requests from the clients, and contains the logic to send the appropriate data back to the client. The backend also includes the database, which will persistently store all of the data for the application.
Copy file name to clipboardExpand all lines: module1-introduction-to-backend/r2.1-diving-into-rest-apis/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,7 +20,7 @@ HTTP defines a set of request methods to indicate the desired action to be perfo
20
20
21
21
While developing APIs, GET and POST are the most commonly and frequently used methods.
22
22
23
-
## Structure of a HTTP Request
23
+
## Structure of an HTTP Request
24
24
25
25
HTTP requests, and responses, share similar structure and are composed of:
26
26
1. A start-line describing the requests to be implemented, or its status of whether successful or a failure. This start-line is always a single line.
@@ -67,7 +67,7 @@ Bodies can be broadly divided into two categories:
67
67
- Single-resource bodies, consisting of one single file, defined by the two headers: Content-Type and Content-Length.
68
68
- Multiple-resource bodies, consisting of a multipart body, each containing a different bit of information. This is typically associated with HTML Forms.
Copy file name to clipboardExpand all lines: module1-introduction-to-backend/r3.4-api-best-practices/README.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -26,7 +26,7 @@ Please note: This list is not necessarily exhaustive and there is always room fo
26
26
REST APIs should accept JSON for request payload and also send responses to JSON. JSON is the standard for transferring data. Almost every networked technology can use it: JavaScript has built-in methods to encode and decode JSON either through the Fetch API or another HTTP client. Server-side technologies have libraries that can decode JSON without doing much work.
27
27
28
28
In Express, we can use the body-parser middleware to parse the JSON request body.
29
-
```
29
+
```js
30
30
constexpress=require('express');
31
31
constbodyParser=require('body-parser');
32
32
@@ -49,7 +49,7 @@ For example, we should create routes like GET `/articles` for getting news artic
49
49
The combination of the HTTP verb and resource noun convey the purpose of an API endpoint. API endpoints like GET `/fetchArticles` or POST `/update-articles` use redundant verbs like "fetch" and "update" which is not required.
50
50
51
51
In Express, we can write these endpoints as:
52
-
```
52
+
```js
53
53
constexpress=require('express');
54
54
constbodyParser=require('body-parser');
55
55
@@ -89,7 +89,7 @@ When designing endpoints, it makes sense to group those that contain associated
89
89
For example, if we want an endpoint to get the comments for a news article, we should append the `/comments` path to the end of the `/articles` path.
90
90
91
91
In Express, we can write this as:
92
-
```
92
+
```js
93
93
constexpress=require('express');
94
94
constbodyParser=require('body-parser');
95
95
@@ -123,7 +123,7 @@ To eliminate confusion for API users when an error occurs, we should handle erro
123
123
Along with error codes, try to provide good feedback through your response messages. Good feedback involves positive validation on correct implementation, and an informative error on incorrect implementation that can help users debug and correct the way they use the product. Describe your error responses well, but keep them concise and neat.
124
124
125
125
For example, if we want to reject the data from the request payload, then we should return a 400 response as follows in an Express API:
The databases behind a REST API can get very large. Sometimes, there’s so much data that it shouldn’t be returned all at once because it’s way too slow or will bring down our systems. Therefore, we need ways to filter items. We also need ways to paginate data so that we only return a few results at a time. We don’t want to tie up resources for too long by trying to get all the requested data at once. Filtering and pagination both increase performance by reducing the usage of server resources.
154
154
155
155
Here’s a small example where an API can accept a query string with various query parameters to let us filter out items by their fields:
156
-
```
156
+
```js
157
157
constexpress=require('express');
158
158
constbodyParser=require('body-parser');
159
159
@@ -209,7 +209,7 @@ This way, we can gradually phase out old endpoints instead of forcing everyone t
209
209
Versioning is usually done with `/v1/`, `/v2/`, etc. added at the start of the API path.
210
210
211
211
For example, we can do that with Express as follows:
0 commit comments