π Web Development Notes (JavaScript Backend)
β HTTP Methods
HTTP methods define what action the client wants to perform on the server.
| Method | Purpose |
GET | Retrieve data (read-only) |
POST | Send data to create a resource |
PUT | Update/replace an existing resource |
PATCH | Update (partial) a resource |
DELETE | Remove a resource |
π Communication Protocols
| Protocol | Purpose |
| HTTP | Standard request-response communication over the web |
| WebSockets | Full-duplex communication (real-time apps: chat, games) |
| WebRTC | Peer-to-peer audio, video, and data sharing (used in video calls) |
| gRPC | High-performance remote procedure call protocol (used in microservices) |
π HTTP Status Codes
Status codes are 3-digit responses returned by the server to indicate the result of the request.
β
1. 200 Series β Success
200 OK: Request succeeded201 Created: Resource created204 No Content: Success, no data returned
π 2. 300 Series β Redirection
301 Moved Permanently302 Found (Temporary redirect)
β 3. 400 Series β Client Error
400 Bad Request401 Unauthorized403 Forbidden404 Not Found
π οΈ 4. 500 Series β Server Error
500 Internal Server Error502 Bad Gateway503 Service Unavailable
π£οΈ Routes
Routes define what endpoint/path is used and what happens when it is hit.
They map incoming HTTP requests to specific handler functions.
Example:
jsCopyEditapp.get('/todos', getAllTodos); // Fetch todos
app.post('/todo', createTodo); // Add a todo
app.delete('/todo/:id', deleteTodo); // Delete by ID
Routing is the mechanism Express (or any web framework) uses to match a URL and method with the appropriate code to run.