Node.js Web Basics Tutorial

From Hello World to REST APIs

This tutorial takes you from running your first Node.js script to building a complete REST API. Each module builds on the previous one, showing you how Node.js web development works from the ground up.

Unlike PHP (which runs inside a web server), Node.js applications create their own HTTP servers. You'll learn what that means and how to leverage it.

Tutorial Modules

01. Hello World

Understand Node.js fundamentals: running scripts, ES6+ features, and the event loop.

  • Running JavaScript with Node
  • The event loop concept
  • Callbacks and async patterns
Start Module

02. HTTP Server

Build a web server from scratch using Node's built-in http module.

  • http.createServer()
  • Request and response objects
  • Manual routing and file serving
Start Module

03. Express Basics

The Express framework: routing, middleware, and static files.

  • npm and package management
  • Express routing
  • Serving static files
Start Module

04. Form Handling

Process GET and POST data, parse request bodies.

  • req.query and req.body
  • Body parsing middleware
  • Comparison with PHP
Start Module

05. REST API

Build a simple RESTful API with CRUD operations.

  • REST principles
  • HTTP verbs and resources
  • JSON responses
Start Module

Running the Demos

Prerequisites: You need Node.js installed. Check with:
node --version

If not installed, download from nodejs.org

Quick Reference

PHP Node.js (Express)
$_GET['name'] req.query.name
$_POST['email'] req.body.email
$_SERVER['REQUEST_METHOD'] req.method
header('Content-Type: ...') res.set('Content-Type', '...')
echo json_encode($data) res.json(data)

Back to CSE 135 Home | Node.js Overview | Start Tutorial