-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhttpservernotes.txt
More file actions
72 lines (49 loc) · 2.76 KB
/
Copy pathhttpservernotes.txt
File metadata and controls
72 lines (49 loc) · 2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
Ports are logical endpoints used by protocols to identify specific processes running on a computer or server. They help direct network traffic to the correct application or process on a system.
HTTP Protocol
HTTP is a protocol for communication between clients and servers
Methods-get, post, put, delete etc
Status code
200 Series Successful
200 - OK
204 - No Content
404 - Not Found
500 - Internal Server Error
300 Series Redirects
301 - Moved Permanently
302 - Found
303 - See Other
304 - Not Modified
307 - Temporary Redirect
400 Series Client Errors
400 - Bad Request
401 - Unauthorized
403 - Forbidden
500 Series Server Errors
501 - Not Implemented
502 - Bad Gateway
503 - Service Unavailable
504 - Gateway Timeout
505 - HTTP Version Not Supported
Body with the request has the data that is sent by the client to the server along with the request like POST, PUT, DELETE etc
basically the body is the data that is sent to the server/backend
Routes are paths or endpoints that define how incoming requests are handled by the server
Routing is the mechnanism used to direct incoming HTTP requests to the appropriate handler functions or resources based on the URL path
https://www.api.website.com/route
this route can be used to handle all incoming requests to the website
Express.js, or simply Express, is a back end web application framework for building RESTful APIs with Node.js, released as free and open-source software under the MIT License. It is designed for building web applications and APIs.[2] It has been called the de facto standard server framework for Node.js.[3]
req.params.firstname can alos be used to get the firstname from the url
req.query.firstname can alos be used to get the firstname from the query string
req.body.firstname can alos be used to get the firstname from the body
MIDDLEWARE
Express is a routing and middleware web framework that has minimal functionality of its own. An Express application is composed of a series of middleware function calls that are executed in the order that they are defined.
Middleware functions are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle, denoted by a function parameter named next.
Middleware functions can perform the following tasks:
1. Execute any code.
2. Make changes to the request and the response objects.
3. End the request-response cycle.
4. Call the next middleware function in the stack.
Axios is a promise based http client for the browser and Node.js
Fetch is also same.
Cors is a mechanism that allows restricted resources on a web page to be requested from another domain outside the domain from which the first resource was served.
Cors-Cross-Origin-Resource-Sharing
should be blocked by default