The web is typically bifurcated into two parts, the “front-end” and the “back-end”. Node.js is software that allows you to author your back-end code in JavaScript.
Let’s explore the ecosystem.
What is a protocol?
HTTP can be summarized as text strings passed back and forth between computers over a network connection.
- Content-Type
- Host
- Access-Control-Allow-Origin (CORS)
- GET
- PUT
- POST
- DELETE
telnet google.com 80 GET /
Play around with this!
A browser is a really fancy implementation for communicating over protocols and displaying responses.
Run the server:
node server.js
Telnet and examine the response:
telnet localhost 1337 GET /
Run the server:
node server-with-headers.js
Telnet and examine the response:
telnet localhost 1337 GET /
Neat, check it out in a browser…
Run the server:
node server-with-json.js
Telnet and examine the response:
telnet localhost 1337 GET /
Neat, check it out in a browser…
Run the server:
node server-with-image.js
Telnet and examine the response:
telnet localhost 1337 GET /
Neat, check it out in a browser…
Run the server:
node server-with-json.js
open index.html
Didn’t work? Thats because of the browser security policy CORS.
Run the server with the CORS header enabled:
node server-with-access.js
- What is a module system?
- Module Scoping
- Creating a module
- Consuming a module
- console.log the request in your http server
- A fancy pants tool for making requests. (A human friendly cURL)
- GET - Gets entities /users/
- POST - Creates entities /users/
- PUT - Updates entities /users/1
- DELETE - Deletes entities /users/1