codex-lv3-may-2025

Week 1 Notes

Table of Contents


Day 1

slides

Today we are building a server.

Steps:

Learning Objectives

By the end of today, you’ll be able to:

Web Development Fundamentals

Client-Server Architecture

Introduction to Node.js

Hands-On Practice: Building Your First Server

Server Setup Checklist

Create a Node.js server that demonstrates core web development concepts:

  1. ✅ Project Initialization
    mkdir my-first-server
    cd my-first-server
    npm init -y
    npm install express
    
  2. ✅ Basic Server Structure
    const express = require('express');
    const app = express();
    const PORT = 3000;
       
    app.get('/', (req, res) => {
      res.send('Hello, World!');
    });
       
    app.listen(PORT, () => {
      console.log(`Server running on http://localhost:${PORT}`);
    });
    
  3. ✅ Multiple Routes
    • Create endpoints for different purposes
    • Understand route parameters
    • Handle different HTTP methods (GET, POST)
  4. ✅ Error Handling
    • Implement basic error handling
    • Understand HTTP status codes
    • Create meaningful error responses
  5. 🎯 Bonus Challenge: Dynamic Content
    • Use query parameters
    • Create interactive responses
    • Implement basic data handling

Key Concepts to Master

Learning Resources

Pro Tips

Day 2: JavaScript Fundamentals for React Development

Learning Objectives

By the end of today, you’ll be able to:

Core JavaScript Concepts

Variable Declarations

Functions & Arrow Functions

Template Literals

Conditional Logic

Object Notation

Learning Resources

Hands-On Practice: Enhanced Server Project

Development Environment Setup

First, let’s improve your development workflow with nodemon:

# Install nodemon globally for automatic server restarts
npm install -g nodemon

# Or install as a dev dependency in your project
npm install --save-dev nodemon

Using nodemon:

# Instead of: node server.js
# Use: nodemon server.js
nodemon server.js
# or
npx nodemon server.js

Server Enhancement Checklist

Update your Node.js server to demonstrate modern JavaScript concepts:

  1. ✅ Template Literals
    • Replace string concatenation with backticks and ${}
    • Create dynamic responses using variables
  2. ✅ Multiple Endpoints
    app.get("/my-cat", (req, res) => {
      // Your cat endpoint
    });
       
    app.get("/my-dog", (req, res) => {
      // Your dog endpoint
    });
    
  3. ✅ Object Manipulation
    • Create a POJO (Plain Old JavaScript Object)
    • Use bracket notation for dynamic property access
    • Demonstrate both dot and bracket notation
  4. ✅ Modern Variable Declarations
    • Replace var with let and const appropriately
    • Show understanding of when to use each
  5. 🎯 Bonus Challenge: Ternary Operators
    • Implement conditional logic using ternary operators
    • Create dynamic responses based on request parameters

Reference Materials

Pro Tips

Day 3: Lists and Patterns

Learning Objectives

Core Concepts

Learning Resources

Video on adding data to an array

Hands-On Practice