Skip to content

orassayag/nodejs-learning-v2

Repository files navigation

Nodejs Learning V2

A comprehensive Node.js learning repository built while following Mosh Hamedani's "Node.js: The Complete Guide to Build RESTful APIs (2018)" course.

Built in November 2018, the project is organized into four progressive modules covering Node.js fundamentals, core modules, file system operations, debugging, testing with Jest, and Express.js basics. It also includes web scraping examples using Nightmare.js and Crawler, while exploring JavaScript concepts such as closures, scope, context binding, IIFEs, and ES6 features, providing a practical foundation for backend development.

Features

  • 📚 4 Progressive learning modules from basics to advanced
  • 🧪 Testing examples with Jest
  • 🔍 Debugging configurations for VSCode
  • 🌐 Web scraping examples with Nightmare.js and Crawler
  • 🗂️ File system operations and directory traversal
  • 🚀 Express.js server setup examples
  • 💡 JavaScript fundamentals (scope, closures, context)

Core Capabilities

  • Module-based Learning: 4 self-contained modules progressing from basics to advanced
  • Hands-on Examples: Practical code examples for every concept
  • Testing Integration: Jest testing examples in core modules
  • Debugging Tools: VSCode debugging configurations
  • Web Scraping Examples: Nightmare.js and Crawler implementations
  • JavaScript Deep Dive: Scope, closures, context, arrow functions, and more

Technical Excellence

  • Clean Code Organization: Each module is self-contained with clear separation
  • Testing Coverage: Jest testing framework integration
  • Debugging Support: Built-in debugging configurations for VSCode
  • Module System Best Practices: Proper use of Node.js require/module.exports
  • Error Handling Examples: Asynchronous patterns and error management

Developer Experience

  • Progressive Learning Path: Modules build on each other incrementally
  • VSCode Integration: Debug configurations and settings
  • Self-contained Modules: Each module can be explored independently
  • Comprehensive Examples: Real-world use cases like web scraping and Express servers
  • Clear Documentation: Learning objectives for each module

Getting Started

Prerequisites

  • Node.js (v8 or higher recommended for course compatibility)
  • npm (comes with Node.js)
  • VSCode (recommended for debugging features)

Installation

  1. Clone the repository:
git clone https://github.com/orassayag/nodejs-learning-v2.git
cd nodejs-learning-v2
  1. Navigate to a specific module and install dependencies:
cd 02/first-app
npm install
  1. Run the module:
npm start

Usage

Module Navigation

Each module is self-contained in directories 01-04:

# Module 01 - Hello World
cd 01/first-app
node app.js

# Module 02 - Core Modules
cd 02/first-app
npm install
npm start

# Module 03 - JavaScript Fundamentals
cd 03/firstApp
node index.js

# Module 04 - Advanced Topics
cd 04/debug-demo
npm install
node index.js

Configuration

Environment

  • No environment configuration required
  • Each module is self-contained
  • Dependencies are installed per-module

VSCode Settings

VSCode configurations are provided in .vscode/settings.json and .vscode/launch.json for debugging.

Architecture Principles

This project follows these learning-focused architecture principles:

  1. Progressive Complexity: Modules start simple and increase in complexity
  2. Self-containment: Each module can be explored independently
  3. Practical Examples: Every concept has a working code example
  4. Clear Separation: Concerns are separated by module purpose
  5. Testability: Examples include testing where appropriate

Architecture

Directory Structure

nodejs-learning-v2/
├── 01/first-app/          # Module 01: Hello World
│   └── app.js
├── 02/first-app/          # Module 02: Core Modules + Testing
│   ├── app.js
│   ├── logger.js
│   ├── package.json
│   └── .vscode/
│       ├── launch.json
│       └── settings.json
├── 03/firstApp/           # Module 03: JavaScript Fundamentals
│   └── index.js
├── 04/debug-demo/         # Module 04: Advanced Topics
│   ├── index.js
│   └── package.json
├── .github/
│   └── rulesets/
├── .vscode/
│   └── settings.json
├── .gitignore
├── .prettierrc
├── CHANGELOG.md
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── INSTRUCTIONS.md
├── LICENSE
├── README.md
└── SECURITY.md

Design Patterns

  • Module Pattern: Using Node.js module system (require/module.exports)
  • Factory Pattern: Examples in custom modules
  • Singleton Pattern: Logger module example
  • Closure Patterns: Demonstrated in JavaScript fundamentals
  • IIFE (Immediately Invoked Function Expressions): For scope control

Best Practices

Learning Approach

  1. Follow Module Order: Start with Module 01 and progress through to Module 04
  2. Run All Examples: Execute each code example to see it in action
  3. Experiment: Modify code to see how changes affect behavior
  4. Use Debugger: Step through code with VSCode debugger
  5. Write Tests: Practice writing additional tests with Jest

Code Organization

  1. Keep Modules Self-contained: Each module has its own dependencies
  2. Use Clear Naming: Files and functions have descriptive names
  3. Comment Where Necessary: Complex examples include explanatory comments
  4. Test Your Changes: Use Jest to verify your modifications

Support

For questions, issues, or contributions:

Learning Modules

Module 01: Hello World

Path: 01/first-app/

Basic Node.js execution with a simple greeting function.

cd 01/first-app
node app.js

Learning objectives:

  • Running JavaScript with Node.js
  • Function definitions
  • Template literals

Module 02: Node.js Core Modules

Path: 02/first-app/

Explores Node.js built-in modules including path, file system, and custom modules.

cd 02/first-app
npm install
npm start

Learning objectives:

  • Creating and importing custom modules
  • Working with the path module
  • File system operations (fs)
  • Directory traversal algorithms
  • Unit testing with Jest

Module 03: JavaScript Fundamentals

Path: 03/firstApp/

JavaScript basics focusing on scope and iteration.

cd 03/firstApp
node index.js

Learning objectives:

  • Block scope with let
  • Loop constructs
  • Variable lifecycle

Module 04: Advanced Topics

Path: 04/debug-demo/

Advanced examples including web scraping, debugging, and Express.js.

cd 04/debug-demo
npm install
node index.js

Learning objectives:

  • Web scraping with Nightmare.js (headless browser)
  • Crawling with the Crawler library
  • Debugging with breakpoints
  • Express.js server setup
  • Arrow functions vs regular functions
  • Context (this) binding
  • Closures and IIFE patterns
  • Recursive file system traversal

Project Structure

graph TD
    A[nodejs-learning-v2] --> B[01/first-app]
    A --> C[02/first-app]
    A --> D[03/firstApp]
    A --> E[04/debug-demo]

    B --> B1[app.js - Hello World]

    C --> C1[app.js - Core modules]
    C --> C2[logger.js - Custom module]
    C --> C3[package.json - Jest testing]

    D --> D1[index.js - Scope examples]

    E --> E1[index.js - Scraping & debugging]
    E --> E2[Dependencies: nightmare, crawler, express]
Loading

Module Flow Diagram

flowchart LR
    A[Start Learning] --> B[Module 01: Basics]
    B --> C[Module 02: Core Modules]
    C --> D[Module 03: JavaScript Fundamentals]
    D --> E[Module 04: Advanced Topics]
    E --> F[Complete]

    style A fill:#e1f5ff
    style F fill:#d4edda
Loading

Available Scripts

Each module may have different scripts. Common ones:

Module 02

npm start    # Run the application
npm test     # Run Jest tests

Modules 01, 03, 04

node app.js    # or node index.js

Debugging

VSCode

Module 02 includes VSCode launch configurations:

  1. Open the module in VSCode
  2. Set breakpoints in code
  3. Press F5 to start debugging

Node.js Inspector

node inspect index.js

Dependencies Overview

Module 02

  • jest (^22.2.2) - Testing framework

Module 04

  • express (^4.16.4) - Web application framework
  • nightmare (^3.0.1) - Headless browser automation
  • crawler (^1.2.0) - Web crawling and scraping
  • after-load (^1.0.4) - HTML page loading utility

Key Concepts Covered

Node.js Core

  • Module system (require, module.exports)
  • Built-in modules (path, fs)
  • Asynchronous patterns
  • Error handling

JavaScript Advanced

  • Arrow functions vs regular functions
  • Context (this) binding
  • Closures and scope
  • IIFE (Immediately Invoked Function Expressions)
  • Block scope vs function scope

Web Development

  • Express.js basics
  • Web scraping ethics and techniques
  • HTTP requests
  • DOM manipulation with headless browsers

Development Practices

  • Unit testing with Jest
  • Debugging techniques
  • Code organization
  • Module patterns

Code Examples

Custom Module (Module 02)

// logger.js
module.exports = function (message) {
  console.log(message);
};

// app.js
const log = require('./logger');
log('Hello World');

Web Scraping (Module 04)

const Nightmare = require('nightmare');
const nightmare = Nightmare();

nightmare
  .goto('https://example.com')
  .evaluate(() => document.querySelector('h1').innerText)
  .then(console.log);

Contributing

Contributions to this project are released to the public under the project's open source license.

Everyone is welcome to contribute. Contributing doesn't just mean submitting pull requests—there are many different ways to get involved, including answering questions and reporting issues.

Please feel free to contact me with any question, comment, pull-request, issue, or any other thing you have in mind.

Author

License

This application has an MIT license - see the LICENSE file for details.

Acknowledgments

  • Built for educational and research purposes
  • Respects robots.txt and implements rate limiting
  • Uses user-agent rotation to avoid detection
  • Implements polite crawling practices

About

A comprehensive Node.js learning repository demonstrating fundamental to advanced concepts from Mosh Hamedani's "Node.js: The Complete Guide to Build RESTful APIs (2018)" course. Built in November 2018. This repository contains 4 progressive learning modules covering Node.js basics, core modules, debugging, web scraping, and Express.js fundamental

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors