Skip to content

VersatileSoul/nodejs-learning

Repository files navigation

Node.js Learning Journey

A comprehensive learning repository for Node.js fundamentals and best practices.

📚 Table of Contents

Introduction

This repository contains learning materials and code examples for Node.js development. Each module builds upon the previous one, providing a structured learning path from basics to more advanced concepts.

Modules

01 - Introduction to Node.js

Directory: 01-Introduction-to-Node.js

Learn the fundamentals of Node.js, including:

  • What is Node.js and how it works
  • JavaScript on the server
  • When and why to use Node.js
  • Key features and advantages
  • Popular use cases

Files:

  • Introduction-to-Node.js.md - Comprehensive documentation

Key Topics:

  • Node.js runtime environment
  • V8 JavaScript Engine
  • Single-threaded, event-driven architecture
  • NPM ecosystem
  • Use cases and best practices

View Documentation →


02 - Reading and Writing Files

Directory: 02-Reading-and-Writing-Files

Learn how to interact with the file system in Node.js:

  • Synchronous vs Asynchronous file operations
  • Reading files with fs.readFileSync() and fs.readFile()
  • Writing files with fs.writeFileSync() and fs.writeFile()
  • Understanding blocking vs non-blocking I/O

Files:

  • sync-way.js - Synchronous file operations example
  • async-way.js - Asynchronous file operations example
  • input.txt - Sample input file
  • Reading-and-Writing-Files.md - Complete documentation

Key Topics:

  • File System (fs) module
  • Synchronous operations (blocking)
  • Asynchronous operations (non-blocking)
  • Callbacks and error handling
  • When to use each approach

View Documentation →


03 - Creating Web Server

Directory: 03-Creating-web-server

Build your first HTTP server using Node.js:

  • Creating HTTP servers with the http module
  • Handling different routes
  • Request and response objects
  • Setting status codes and headers
  • Building a simple web server

Files:

  • App.js - HTTP server with routing
  • Creating-web-server.md - Complete documentation

Key Topics:

  • HTTP module
  • createServer() method
  • Request (req) and Response (res) objects
  • Route handling
  • Status codes and headers
  • res.writeHead() and res.end()

View Documentation →


04 - Building Simple API

Directory: 04-Building-simple-api

Create a simple REST API that serves JSON data:

  • Building API endpoints
  • Serving JSON data from files
  • Loading data at server startup
  • Understanding __dirname
  • Setting proper Content-Type headers

Files:

  • App.js - Simple API server
  • data.json - Sample JSON data
  • Building-simple-api.md - Complete documentation

Key Topics:

  • REST API concepts
  • JSON data handling
  • File system integration
  • API endpoints
  • Content-Type headers
  • Synchronous vs Asynchronous data loading

View Documentation →


05 - Parsing Variables from URL

Directory: 05-Parsing-variables-from-url

Learn how to extract data from URLs:

  • Parsing query strings
  • Extracting URL parameters
  • Using modern WHATWG URL API
  • Working with URLSearchParams
  • Combining URL parameters and query strings

Files:

  • App.js - Server with URL parsing examples
  • Parsing-variables-from-url.md - Complete documentation

Key Topics:

  • Modern URL API (WHATWG standard)
  • Query string parameters
  • URL path parameters
  • URLSearchParams object
  • new URL() constructor
  • Extracting dynamic route segments

View Documentation →


06 - Introduction to NPM

Directory: 06-Introduction-to-NPM

Master Node Package Manager:

  • Understanding npm and package management
  • Creating and managing package.json
  • Installing and managing dependencies
  • NPM scripts
  • Best practices and workflows

Files:

  • App.js - Example server using npm
  • package.json - Project configuration
  • .gitignore - Git ignore file
  • Introduction-to-NPM.md - Complete documentation

Key Topics:

  • Package management
  • package.json structure
  • Dependencies vs DevDependencies
  • NPM commands
  • NPM scripts
  • node_modules and package-lock.json
  • Version ranges and semantic versioning

View Documentation →

Project Structure

nodejs-learning/
├── 01-introduction-tonNode.js/
│   └── introduction-to-node.js.md
├── 02-reading-and-writing-files/
│   ├── sync-way.js
│   ├── async-way.js
│   ├── input.txt
│   ├── sync-output.txt
│   ├── async-output.txt
│   └── reading-and-writing-files.md
├── 03-creating-web-server/
│   ├── App.js
│   └── creating-web-server.md
├── 04-building-simple-api/
│   ├── App.js
│   ├── data.json
│   └── building-simple-api.md
├── 05-parsing-variables-from-url/
│   ├── App.js
│   └── parsing-variables-from-url.md
├── 06-introduction-to-npm/
│   ├── App.js
│   ├── package.json
│   ├── package-lock.json
│   ├── .gitignore
│   └── introduction-to-npm.md
└── README.md

Getting Started

Prerequisites

  • Node.js installed (v12 or higher recommended)
  • Basic knowledge of JavaScript
  • A code editor (VS Code recommended)
  • Terminal/Command Prompt

Installation

  1. Clone this repository (or download the files)
  2. Ensure Node.js is installed:
    node --version
    npm --version

Learning Path

Follow the modules in order:

  1. Start Here: Introduction to Node.js
  2. File Operations: Reading and Writing Files
  3. Web Servers: Creating Web Server
  4. APIs: Building Simple API
  5. URL Parsing: Parsing Variables from URL
  6. Package Management: Introduction to NPM

Running Examples

Each module contains working code examples. To run them:

# Navigate to the module directory
cd 03-Creating-web-server

# Run the example
node App.js

For modules with npm dependencies (like module 06):

cd 06-Introduction-to-NPM

# Install dependencies first
npm install

# Run the server
npm start

# Or run in development mode
npm run dev

Key Concepts Covered

Core Node.js Concepts

  • ✅ Node.js runtime and V8 engine
  • ✅ Event-driven, non-blocking I/O
  • ✅ Single-threaded architecture
  • ✅ File system operations
  • ✅ HTTP servers and APIs

File System

  • ✅ Synchronous vs Asynchronous operations
  • ✅ Reading and writing files
  • ✅ Error handling
  • ✅ Best practices

Web Development

  • ✅ Creating HTTP servers
  • ✅ Handling routes
  • ✅ Request and response objects
  • ✅ Building REST APIs
  • ✅ Serving JSON data

URL Handling

  • ✅ Modern URL API (WHATWG)
  • ✅ Query string parsing
  • ✅ URL parameter extraction
  • ✅ URLSearchParams

Package Management

  • ✅ NPM basics
  • ✅ package.json
  • ✅ Dependencies management
  • ✅ NPM scripts
  • ✅ Best practices

Best Practices

  1. Always use asynchronous methods for production applications
  2. Handle errors properly in all file and network operations
  3. Use modern APIs (avoid deprecated methods like url.parse())
  4. Set appropriate Content-Type headers for API responses
  5. Keep dependencies updated and use semantic versioning
  6. Commit package-lock.json but not node_modules
  7. Use npm scripts for common tasks

Additional Resources

Summary

This repository covers:

  • Module 1: Understanding Node.js fundamentals
  • Module 2: File system operations (sync vs async)
  • Module 3: Creating HTTP web servers
  • Module 4: Building simple REST APIs
  • Module 5: Parsing URL parameters and query strings
  • Module 6: NPM package management

Each module builds upon the previous knowledge, creating a comprehensive learning path for Node.js development.


Happy Learning! 🚀

This repository is part of a Node.js learning journey. Keep coding and exploring!

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published