RPC vs RESTful
(remote protocol call vs respresentational state)
(function driven vs resource driven)
eg:
example.com/createStudents
vs
example.com/students
.fetch() does not treat status code ‘errors’ (400s, 500s) as an error
axios.get() catches status code ‘errors’
CORS
Cross-origin (includes different subdomains)
to prevent malicious websites from cross origins, client can send the OPTIONS request with Origin:
Origin: http://www.example.com
Server responds with ACAO (access control allow origin):
only allow same-origin
instead of just accept all cross-origin
CORS = middle ground
Access-Control-Allow-Origin: http://www.example.com
![]()
API (Application programming interface)
Interface which supplies an API method that takes an input (like a ‘black box’) and returns an output
reserved port numbers:
- 20: File Transfer Protocol (FTP) Data Transfer
- 21: File Transfer Protocol (FTP) Command Control
- 22: Secure Shell (SSH) Secure Login
- 23: Telnet remote login service, unencrypted text messages
- 25: Simple Mail Transfer Protocol (SMTP) E-mail routing
- 53: Domain Name System (DNS) service
- 80: Hypertext Transfer Protocol (HTTP) used in the World Wide Web
- 110: Post Office Protocol (POP3)
- 119: Network News Transfer Protocol (NNTP)
- 123: Network Time Protocol (NTP)
- 143: Internet Message Access Protocol (IMAP) Management of digital mail
- 161: Simple Network Management Protocol (SNMP)
- 194: Internet Relay Chat (IRC)
- 443: HTTP Secure (HTTPS) HTTP over TLS/SSL
Making a node server
Using express:
const express = require("express");
const port = 8080;
const app = express();
app.get("/", (req, res) => {
res.end("Hello");
});
app.get("/watermelon", (req, res) => {
res.end("watermelon");
});
app.listen(8080, () => {
console.log(`Server is running on http://localhost:${port}`);
});
npm run dev (because dev is a custom command and not recognized)
middleware