📘 MODULE 1 — JavaScript Fundamentals (Backend-Focused)
Duration: 5–7 days
CHAPTER 1 — Core JavaScript Basics
1.1 What is JavaScript? (Backend Perspective)
• JS in browser vs JS in [Link]
• Single-threaded nature and the Event Loop
• Why JavaScript's non-blocking I/O is perfect for backend services
• The role of the V8 engine
🎥 Video: What is JavaScript? — Mosh [Link]
1.2 Variables & Data Types
• var vs let vs const: When and why to use each
• Scope: Global, Function, and Block scope
• Hoisting: How var and function declarations are moved to the top
• Mutability: Understanding const with objects and arrays
🎥 Video: let, const, var explained — Akshay Saini [Link]
1.3 Primitive Types
• Number, String, Boolean, Undefined, Null, BigInt, Symbol
• Type Coercion: How JavaScript converts types automatically
• Checking types with typeof
🎥 Video: Primitive Data Types — Kevin Powell [Link]
1.4 Operators
• Arithmetic (+, -, *, /, %, **)
• Logical (&&, ||, !)
• Comparison (==, ===, !=, !==, >, <)
• Nullish coalescing ?? and Optional chaining ?.
🎥 Video: JS Operators Explained — CodeWithHarry [Link]
✔ Assignment: Age & Alcohol Eligibility Checker
Write a program that takes a user's age and prints:
• If they are a teen, adult, or senior.
• If they can legally vote (age >= 18).
• If they are legally old enough to purchase alcohol (age >= 21 in many regions).
CHAPTER 2 — Mastering Arrays
2.1 What is an Array?
• Ordered collection of data
• Zero-based indexing
• length property
• Arrays are mutable
🎥 Video: Arrays for Beginners — Bro Code [Link]
2.2 Array Methods (Basic)
• Adding/Removing: push(), pop(), shift(), unshift()
• Finding: includes(), indexOf(), lastIndexOf()
🎥 Video: Array Methods (Basic) — Hitesh Choudhary [Link]
2.3 Array Methods (Advanced)
• Iteration & Transformation: map(), filter(), reduce(), forEach()
• Finding: find(), findIndex()
• Testing: some(), every()
• Sorting: sort() (and why it can be tricky)
🎥 Video: map, filter, reduce — Akshay Saini [Link]
2.4 Spread Operator & Rest Parameters
• Copying arrays (const newArr = [...oldArr])
• Merging arrays (const combined = [...arr1, ...arr2])
• Passing multiple values to a function (function sum(...numbers))
🎥 Video: Spread & Rest Explained — freeCodeCamp [Link]
✔ Mini-Project: Restaurant Menu Calculator
• Create an array of menu item objects, each with name, category, and price.
• Use filter() to create a new array containing only items from a specific category (e.g., "beer" or "cake").
• Use map() to create an array of just the prices.
• Use reduce() to calculate the total cost of the filtered items, including tax.
CHAPTER 3 — Objects (Super Important for Backend)
3.1 Object Basics
• Key-value pairs
• Accessing properties: Dot notation ([Link]) vs. Bracket notation (obj['name'])
• Adding, updating, and deleting properties
🎥 Video: JavaScript Objects — Mosh [Link]
3.2 Nested Objects & Arrays
• Objects inside objects (e.g., a user object with an address object)
• Arrays of objects (e.g., a restaurant object with a menu array)
3.3 Object Methods
• [Link](): Get an array of keys
• [Link](): Get an array of values
• [Link](): Get an array of [key, value] pairs
• [Link](): Copy properties from one object to another
🎥 Video: Object Methods — freeCodeCamp [Link]
✔ Mini-Project: Beer Tasting Notes Tracker
• Create a main object beerJournal.
• Each key will be a unique beer ID.
• The value for each key will be an object containing: name, brewery, style, abv, rating (1-5), and tastingNotes (an array of strings).
• Write functions to addBeer(), findBeerByName(), and getAverageRating().
CHAPTER 4 — Functions (Deep Dive)
4.1 Declaring Functions
• Function declarations
• Function expressions
• Arrow functions and their lexical this
🎥 Video: Functions Explained — Programming with Mosh [Link]
4.2 Parameters & Arguments
• Default parameters (function greet(name = 'Guest'))
• Rest parameters (function sum(...numbers))
4.3 Callbacks (Important for [Link])
• Functions passed as arguments to other functions
• Why callbacks are essential for asynchronous operations
• Introduction to "Callback Hell"
🎥 Video: Callback Hell Explained — Akshay Saini [Link]
✔ Assignment: Order Processing Task Runner
Create a function processOrder(order, callbacks) that takes an order object and an object of callbacks: validateOrder, chargePayment,
updateInventory. It should execute these callbacks in sequence.
CHAPTER 5 — Asynchronous JavaScript
5.1 Synchronous vs Asynchronous
• Blocking vs non-blocking code
• The Event Loop in detail
• How setTimeout, fetch, and other async operations work
🎥 Video: JS Event Loop – Best Explanation — Fireship [Link]
5.2 Promises
• The three states: pending, fulfilled, rejected
• Creating promises with new Promise()
• Consuming promises with .then(), .catch(), .finally()
🎥 Video: Promises Tutorial — Mosh [Link]
5.3 Async / Await
• Syntactic sugar over Promises
• Writing cleaner, more readable async code
• Using try...catch for error handling
🎥 Video: Async Await Explained — Hitesh Choudhary [Link]
5.4 Fetch & Axios
• Making GET requests to retrieve data
• Making POST requests to send data
• Handling network errors and API error responses
🎥 Video: Axios Crash Course — Traversy Media [Link]
✔ Mini-Project: Alcohol Unit Calculator
• Ask the user for the type of drink (beer, wine, spirits) and volume in ml.
• Use async/await with fetch to get a mock ABV (Alcohol By Volume) for that drink type from a fake API endpoint (you can
simulate this with a local JSON file).
• Calculate and display the number of alcohol units and responsible drinking guidelines.
CHAPTER 6 — Working With JSON
6.1 What is JSON?
• JavaScript Object Notation
• JSON vs. a JavaScript object
• [Link](): Convert a JS object to a JSON string
• [Link](): Convert a JSON string back to a JS object
🎥 Video: JSON Crash Course — Traversy Media [Link]
✔ Assignment: Recipe Database Export
• Create an array of cake recipe objects, each with name, ingredients (array), and instructions (string).
• Use [Link]() to convert the array into a nicely formatted JSON string.
• Save this string to a file named [Link].
CHAPTER 7 — Modules & Clean Folder Structure
7.1 CommonJS vs ES Modules
• require() / [Link] (CommonJS - default in Node)
• import / export (ES Modules - modern standard)
🎥 Video: Modules Explained — Codevolution [Link]
7.2 Folder Structure for Backend
• controllers/: Logic for handling requests
• routes/: Defines API endpoints
• models/: Data structure and business logic
• utils/: Helper functions
• config/: Configuration files
✔ Mini-Project: Modularize Your Projects
• Take your Beer Tasting Notes Tracker or Restaurant Menu Calculator.
• Refactor it into a clean folder structure. For example, put the data manipulation logic in a models/[Link] and the console
interaction logic in a [Link].
⭐ END OF MODULE 1
📗 MODULE 2 — [Link] Core Foundations (Backend Level)
Duration: 7–10 days
CHAPTER 1 — Understanding [Link] in Depth
1.1 What is [Link]?
• Node as a JavaScript runtime, not a language or framework
• The V8 engine and how it executes JS
• Single-threaded but non-blocking I/O model
• Use cases: APIs, microservices, CLI tools
🎥 Video: [Link] Explained (simple) — Programming with Mosh [Link]
1.2 Node Architecture
• Call Stack, Node APIs, Callback Queue
• The role of the Libuv library
• How the Event Loop orchestrates everything
🎥 Video: How [Link] Works — Fireship [Link]
1.3 Installing Node + npm
• Installing [Link] (which includes npm)
• Checking versions (node -v, npm -v)
• Using nvm (Node Version Manager) to switch between versions
✔ Assignment: System Info Script
Write a [Link] script that uses the built-in os module to print:
• OS platform ([Link]())
• CPU architecture ([Link]())
• Total system memory in GB ([Link]())
CHAPTER 2 — [Link] Built-In Modules (Very Important)
2.1 FS Module (File System)
• Reading files: [Link]() (async) vs [Link]() (sync)
• Writing files: [Link](), [Link]()
• Working with directories: [Link](), [Link]()
• Watching for file changes with [Link]()
🎥 Video: Node FS Module Explained — CodeWithHarry [Link]
2.2 Path Module
• Creating cross-platform paths with [Link]()
• Getting absolute paths with [Link]()
• Extracting filename, directory, and extension
🎥 Video: Path Module Crash Course — Dave Gray [Link]
2.3 Events Module
• The EventEmitter class
• on() for listening to events
• emit() for triggering events
🎥 Video: EventEmitter Explained — Web Dev Simplified [Link]
2.4 Crypto Module
• Creating hashes ([Link]())
• Generating random bytes for tokens or salts
🎥 Video: Crypto Module Crash Course — The Net Ninja [Link]
✔ Mini-Project: Restaurant Reservation System CLI
• Use readline to get user input (name, date, time, party size).
• Use fs and path to save each reservation as a JSON object in a reservations/ directory.
• Use crypto to generate a unique ID for each reservation.
• Create a function to list all reservations for a given date.
CHAPTER 3 — npm & Package Management
3.1 What is npm?
• The npm registry and public packages
• [Link]: The heart of a Node project
• Semantic versioning (SemVer): [Link]
🎥 Video: npm Crash Course — Traversy Media [Link]
3.2 Installing Packages
• npm install <package> (local dependency)
• npm install -g <package> (global tool)
• npm install --save-dev <package> (development dependency)
• Understanding [Link]
3.3 Useful Developer Packages
• nodemon: Automatically restart server on file changes
• dotenv: Load environment variables from a .env file
• axios: Make HTTP requests from Node
• chalk: Colorize console output
✔ Assignment: Project Setup
• Create a new Node project.
• Run npm init -y.
• Install nodemon and dotenv as dev dependencies.
• Add a "dev": "nodemon [Link]" script to [Link].
CHAPTER 4 — Creating Servers Without Express
4.1 HTTP Module
• [Link](): The foundation of all Node servers
• The req (request) and res (response) objects
• Setting headers and status codes with [Link]()
• Sending different content types (HTML, JSON, plain text)
🎥 Video: Node HTTP Server Crash Course — Traversy [Link]
4.2 Routing Manually
• Using if/else or switch on [Link] and [Link]
• Parsing URL parameters manually
• Handling a POST request body by listening to req data chunks
✔ Mini Project: Beer Inventory Manager API
• Create a simple API without Express.
• GET /beers: Return a list of beers from a local JSON file.
• POST /beers: Accept a new beer object and add it to the JSON file.
• GET /beers/:name: Find and return a specific beer.
CHAPTER 5 — Asynchronous Patterns in [Link]
5.1 Callback Pattern
• Error-first callbacks: function(err, data) { ... }
• Why this pattern is common in Node's built-in modules
• Avoiding callback hell with named functions or control flow libraries
5.2 Promises
• Using [Link] to convert callback-based functions to promises
• Chaining .then() for sequential async operations
5.3 Async Await
• The modern way to handle async in Node
• Using await at the top level of a module (inside an async IIFE)
• Robust error handling with try...catch
🎥 Video: Async & Await — Hitesh (same as Module 1, but focus on Node context) [Link]
✔ Assignment: File Processor
• Read a JSON file of cake recipes ([Link]).
• Use map() to add a new prepTime property to each recipe.
• Save the modified array back to a new file ([Link]).
• Wrap the entire logic in an async function and handle errors with try/catch.
CHAPTER 6 — Working With JSON Files (Mini Database)
6.1 Using JSON as Storage
• The "read-modify-write" pattern
• Ensuring data integrity during writes
6.2 CRUD Operations using JSON
• Create: Add new item to the array and write to file.
• Read: Read the file and find items.
• Update: Find an item, modify it, and write the entire array back.
• Delete: Filter an item out of the array and write back.
✔ Project: Local JSON Cake Recipe Database
• Create a [Link] module that handles all CRUD operations for [Link].
• Functions: getAllRecipes(), getRecipeById(id), addRecipe(data), updateRecipe(id, data), deleteRecipe(id).
• Each function should use [Link] and be asynchronous.
CHAPTER 7 — Creating CLI Applications
7.1 Readline Module
• [Link](): Set up input/output streams
• [Link](): Ask the user a question and get a response
• Creating interactive menus with a loop
🎥 Video: Node CLI in 15 minutes – Fireship [Link]
✔ Mini Project: Bar Order Manager CLI
• Create an interactive menu for a bartender.
• Options: [1] Add new order, [2] View all orders, [3] Mark order as complete, [4] Exit.
• Store orders in a JSON file. Each order has an id, items (array of drink names), status ('pending', 'complete'), and timestamp.
CHAPTER 8 — [Link] Best Practices
8.1 Environment Variables
• Using dotenv to manage configuration (port numbers, database strings, API keys).
• Never commit .env files to git.
8.2 File & Folder Structure
• Revisit the controllers, routes, models, utils, config structure.
• The importance of separation of concerns.
8.3 Error Handling
• Using try/catch for synchronous and async/await code.
• Creating a centralized error handler function.
8.4 Clean Code Practices
• Meaningful variable and function names.
• Functions should do one thing.
• Avoid deeply nested code.
🎥 Video: Clean Code Tips — Web Dev Simplified [Link]
✔ Assignment: Refactor for Best Practices
• Take your Bar Order Manager CLI.
• Move the file logic into a models/[Link].
• Move the CLI menu logic into a [Link].
• Use dotenv for the file path where orders are stored.
🌟 END OF MODULE 2
📕 MODULE 3 — [Link] Mastery (Backend Level)
Duration: 10–14 days
CHAPTER 1 — Introduction to [Link]
1.1 What is Express?
• A minimal and flexible [Link] web application framework
• Unopinionated: You decide how to structure your app
• Provides a robust set of features for web and mobile apps
🎥 Video: What is Express? (Basics) — Mosh [Link]
1.2 Setting Up Express
• npm install express
• Creating the basic server: express(), [Link]()
• Handling the root route /
🎥 Video: Express Setup in 10 Minutes — Traversy Media [[Link]
✔ Assignment:
Create an Express server that returns: { "message": "Welcome to the Bar & Grill API!" } when you visit [Link]
CHAPTER 2 — Routing in Express
2.1 Basic Routes
• [Link](), [Link](), [Link](), [Link]()
• Defining routes for different resources
2.2 Route Parameters
• Capturing values from the URL: /users/:userId
• Accessing them via [Link]
2.3 Query Parameters
• Handling search/filter parameters: /beers?style=IPA
• Accessing them via the [Link] object
2.4 Sending Responses
• [Link](): Send a response of various types
• [Link](): Send a JSON response (sets correct Content-Type header)
• [Link](): Set the HTTP status code
• Chaining methods: [Link](404).json({ error: 'Not found' })
🎥 Video: Express Routing Crash Course — Web Dev Simplified [Link]
✔ Mini-Project: Restaurant Menu API
• Create routes for a menu stored in a local JSON file.
• GET /menu: Returns the entire menu.
• GET /menu/:category: Returns only items from a category (e.g., "starters", "mains", "beers", "cakes").
• GET /menu/search?term=<name>: Returns items matching the search term.
CHAPTER 3 — Middleware (The Heart of Express)
3.1 What is Middleware?
• Functions that execute during the request-response cycle
• Access to req, res, and next
• The power of next(): Passing control to the next middleware
🎥 Video: Middleware Explained — Mosh [Link]
3.2 Built-in Middlewares
• [Link](): Parse incoming JSON payloads
• [Link](): Parse URL-encoded bodies (from forms)
• [Link](): Serve static files (images, CSS, JS)
3.3 Custom Middleware
• Creating your own middleware: [Link]((req, res, next) => { ... })
• Application-level vs. Route-level middleware
3.4 Third-Party Middleware
• morgan: HTTP request logger
• helmet: Set security-related HTTP headers
• cors: Enable Cross-Origin Resource Sharing
🎥 Video: Using Morgan & Helmet — Traversy Media [[Link]
✔ Mini-Project: Age Verification Middleware
• Create a middleware function checkAge.
• This middleware should check for a query parameter ?age=XX.
• If age is less than 21, send back a 403 Forbidden response.
• If age is 21 or older, call next().
• Apply this middleware to a route like /api/alcohol.
CHAPTER 4 — Controllers + Splitting Routes (Best Practices)
4.1 Why Controllers?
• Separating routing logic from business logic
• Making the code more modular, maintainable, and testable
4.2 Creating Controllers
• A controller is just a file with functions that handle requests.
• Example: [Link] with getAllBeers, getBeerById, etc.
4.3 Creating Route Files
• Use [Link]() to create modular, mountable route handlers.
• Example: routes/[Link] will define all /beers endpoints.
4.4 Best Folder Structure
/src
/controllers
/routes
/models
/middleware
/utils
[Link] (or [Link])
🎥 Video: Folder Structure Best Practices — Codevolution [Link]
✔ Assignment: Refactor the Menu API
• Take your Restaurant Menu API.
• Create [Link] with functions for each route.
• Create [Link] that uses [Link] and defines the routes.
• In [Link], [Link]('/api/menu', menuRoutes).
CHAPTER 5 — Handling Request Body + Validation
5.1 Parsing Request Body
• Ensure [Link]() is used before routes that need it.
• Accessing the parsed body in [Link].
5.2 Validating Data
• Why you should never trust client input.
• Manual validation with if checks.
• Using a validation library like Joi or express-validator.
🎥 Video: Validating Express Requests with Joi — Web Dev Simplified
[[Link]
✔ Mini-Project: Brewery Account Registration
• Create a POST /api/breweries/register endpoint.
• The request body should contain name, address, websiteUrl.
• Use Joi to create a schema that validates:
o name: Required, min 3 characters.
o address: Required.
o websiteUrl: Must be a valid URL.
• If validation fails, send back a 400 Bad Request with the error details.
• If it passes, save the new brewery to your JSON file and send back a 201 Created response.
CHAPTER 6 — Error Handling in Express
6.1 Try/Catch in Controllers
• Wrapping async controller logic in try/catch blocks.
• Passing errors to a central handler: next(error).
6.2 Global Error Middleware
• Creating a middleware with 4 arguments: (err, req, res, next).
• Placing it at the end of the middleware stack.
• Sending consistent error responses.
6.3 Custom Error Classes
• Extending the Error class to create custom error types (e.g., AppError).
• Adding a statusCode and isOperational property.
🎥 Video: Express Error Handling — Dave Gray [[Link]
✔ Assignment:
• Implement a global error handler middleware in your API.
• Refactor your brewery registration controller to use try/catch and next(error).
• Create a simple AppError class and use it to throw a 400 error if validation fails.
CHAPTER 7 — Express + File System (Mini Local Database)
7.1 Reading & Writing JSON in Express
• Using the [Link] API within async route handlers.
• Handling the asynchronous nature of file operations.
7.2 CRUD Operations
• Implementing Create, Read, Update, Delete for a resource (e.g., cakes) using Express routes and the fs module.
✔ Mini-Project: Alcohol Delivery Tracker API
• Create an API to track delivery orders.
• Model: Each order has id, customerName, items, status ('preparing', 'out-for-delivery', 'delivered').
• Routes:
o POST /orders: Create a new order (status: 'preparing').
o GET /orders: Get all orders.
o PUT /orders/:id/status: Update the status of an order.
• Store all orders in a single [Link] file.
CHAPTER 8 — Express + Postman/API Testing Tools
8.1 Installing & Using Postman/Insomnia
• Testing all your routes and methods (GET, POST, PUT, DELETE).
• Sending request bodies, headers, and query parameters.
• Inspecting response status, body, and headers.
8.2 Creating Collections
• Grouping related requests into a collection.
• Saving requests for easy reuse.
• Documenting your API within Postman.
🎥 Video: Postman Crash Course — Traversy Media [[Link]
✔ Assignment:
• Create a Postman collection for your Alcohol Delivery Tracker API.
• Include a request for each route, with example bodies for POST/PUT.
CHAPTER 9 — Express Advanced Topics
9.1 CORS
• Understanding the Same-Origin Policy.
• Using the cors middleware to allow requests from your frontend.
9.2 Rate Limiting
• Preventing abuse and brute-force attacks.
• Using the express-rate-limit package.
🎥 Video: Rate Limit with Express — Midudev [[Link]
9.3 File Uploads
• Handling multipart/form-data.
• Using the multer middleware to handle file uploads.
• Saving files to the server's disk.
🎥 Video: Express Multer Guide — Traversy Media [[Link]
✔ Mini-Project: Brewery Logo Uploader
• Extend your brewery API.
• Create a POST /api/breweries/:id/logo route.
• Use multer to accept a single image file upload.
• Save the image to a public/logos/ directory.
• Return the public URL of the uploaded image.
CHAPTER 10 — Large Real Project: Full Restaurant Ordering System
API
🔹 Build a "Restaurant Ordering System API" (Full Express Project)
FEATURES:
• Menu Management: Full CRUD for menu items, organized by category.
• Reservations: Users can make reservations for a specific date/time.
• Orders: Users can place orders containing multiple menu items.
• Error Handling: Centralized, custom error classes.
• Middleware: Logging, CORS, rate limiting.
• Validation: Joi schemas for all incoming data.
• File Structure: Clean, modular, and scalable.
• Data Storage: Use a local JSON file for each resource ([Link], [Link], [Link]).
This project is the culmination of your Express knowledge and prepares you for replacing the JSON file with a real database.
🎥 Video for reference: REST API Best Practices — Traversy Media [[Link]
MTSQjw5DrM]
🌟 END OF MODULE 3
📘 MODULE 4 — TypeScript for Backend (Node + Express + TS)
Duration: 7–10 days
CHAPTER 1 — Why TypeScript for Backend?
1.1 What TypeScript Gives You
• Static typing: Catch errors before you run the code.
• Enhanced IDE support: Autocomplete, refactoring, and inline documentation.
• Self-documenting code: Types act as documentation.
• Safer and more maintainable codebases, especially for large teams.
🎥 Video: Why TypeScript? — Mosh [[Link]
1.2 How TS Helps in Node
• Type req, res, [Link], [Link].
• Define clear contracts (interfaces) for your data models.
• Prevent runtime errors from undefined or incorrectly typed data.
🎥 Video: TypeScript Node Intro — Academind [[Link]
CHAPTER 2 — Installing & Configuring TS
2.1 Install TS Globally + Locally
• npm install -g typescript (for the tsc command)
• npm install -D typescript ts-node (for project-specific use)
2.2 Create [Link]
• Run npx tsc --init.
• Key properties to understand:
o target: Which JS version to compile to (e.g., ES2020).
o module: Module system (CommonJS for Node).
o outDir: Where to put the compiled JS files (./dist).
o rootDir: Where your TS source files are (./src).
o strict: Enables all strict type-checking options (highly recommended).
o esModuleInterop: For better compatibility between CommonJS and ES modules.
🎥 Video: TypeScript Config Tutorial — Traversy Media [[Link]
✔ Assignment:
• Initialize a new Node project.
• Install TypeScript and ts-node.
• Create a [Link] optimized for a [Link] backend.
CHAPTER 3 — Core TS: Types, Interfaces, Enums
3.1 Basic Types
• string, number, boolean
• Array<string> or string[]
• any, unknown, never, void
🎥 Video: TS Basic Types — Programming with Mosh [[Link]
3.2 Interfaces vs Types
• interface: Defines the structure of an object. Can be extended.
• type: Can represent primitives, unions, intersections, and more.
• When to use which.
🎥 Video: Interface vs Type Alias — Fireship [[Link]
3.3 Enums & Literal Types
• enum: A way to give friendly names to sets of numeric values (e.g., enum OrderStatus { Pending = 'pending', ... }).
• Union types with string literals: type Theme = 'light' | 'dark'.
🎥 Video: Enums Explained — Academind [[Link]
✔ Mini Exercises:
• Define an interface MenuItem with properties like id: string, name: string, price: number, category: string.
• Define an interface CakeRecipe that extends MenuItem and adds ingredients: string[].
• Define an enum BeerStyle with values like IPA, Stout, Lager.
CHAPTER 4 — TS with Node (Without Express First)
4.1 ts-node Execution
• Run TS files directly without pre-compiling: npx ts-node src/[Link].
• Adding a script to [Link]: "dev": "ts-node src/[Link]".
4.2 Modules in TS
• Using import/export syntax.
• import * as fs from 'fs'; for importing CommonJS modules.
• Path aliases in tsconfig and [Link].
🎥 Video: TS Modules for Node — Ben Awad [[Link]
✔ Assignment:
• Build a Logger Utility in src/utils/[Link].
• It should export a function log(message: string): void.
• Import and use it in src/[Link].
CHAPTER 5 — Express + TypeScript (Core)
5.1 Installing Types for Express
• npm install express
• npm install -D @types/express @types/node (for type definitions)
5.2 Typed Express Setup
• Importing Request, Response, NextFunction from express.
• Typing your route handlers: [Link]('/', (req: Request, res: Response) => { ... }).
🎥 Video: Express with TypeScript Crash Course — Traversy Media
[[Link]
5.3 TS Folder Structure
• Same as before, but now all files are .ts.
• src/types/[Link]: A place to store shared type definitions and interfaces.
✔ Mini-Project:
• Convert your Restaurant Menu API from Module 3 to TypeScript.
• Define interfaces for MenuItem and Category.
• Type all your route handlers and request bodies.
CHAPTER 6 — Typing Controllers & Routes
6.1 Controller Function Signatures
• Ensuring req, res, and next are typed.
6.2 Typed Request Bodies
• Creating interfaces for incoming data (DTOs - Data Transfer Objects).
• Using generics to type the Request object: Request<{}, {}, CreateUserDto>.
6.3 Utility Types
• Partial<T>: Make all properties of T optional (great for updates).
• Pick<T, K>: Create a new type by picking a set of properties K from T.
• Omit<T, K>: Create a new type by omitting a set of properties K from T.
🎥 Video: Utility Types in TS — Fireship [[Link]
✔ Assignment:
• In your TS Menu API, create a CreateMenuItemDto interface.
• Type your POST /menu route handler to use this DTO for [Link].
• For a PUT /menu/:id route, use Partial<CreateMenuItemDto> to allow partial updates.
CHAPTER 7 — Custom Types & Reuse
7.1 Defining App-Level Types
• Create src/types/[Link] to extend the global Express types.
• Example: Add a custom user property to the Request object.
7.2 Custom Error Type
• Define a class AppError that extends Error.
• Add properties like statusCode: number and isOperational: boolean.
7.3 Error Handling Middleware
• Type your error handler: (err: AppError, req: Request, res: Response, next: NextFunction) => { ... }.
🎥 Video: Express Error Handling in TS — Codevolution [[Link]
CHAPTER 8 — Validation with Zod / Joi in TS
8.1 Why Validation Matters
• Ensuring data integrity and security.
• Zod provides TypeScript-first, schema-based validation.
8.2 Using Zod
• npm install zod
• Define schemas: const userSchema = [Link]({ name: [Link]() });
• Infer types from schemas: type User = [Link]<typeof userSchema>;
🎥 Video: Zod Tutorial (TS) — Andrew Mead [[Link]
✔ Mini-Project: Beer Rating Application
• Create an API for beers and reviews.
• Use Zod to define schemas for Beer and Review.
• In your POST /reviews route, validate the [Link] against the Review schema before saving it.
CHAPTER 9 — TS Generics for Reusable Code
9.1 What Are Generics?
• Creating functions, classes, or interfaces that work with a variety of types.
• Provides type safety without sacrificing flexibility.
🎥 Video: TypeScript Generics Explained — Fireship [[Link]
✔ Exercise:
• Build a generic API response wrapper:
interface ApiResponse<T> {
statusCode: number;
message: string;
data: T;
}
• Use this wrapper in all your successful API responses.
CHAPTER 10 — Building a TS + Express API (Real World)
10.1 Define Models as Types
• Create src/models/ with files like [Link], [Link], etc., defining the TypeScript interfaces.
10.2 Strongly Typed Routes
• Rebuild your Full Restaurant Ordering System API from Module 3, but this time in TypeScript.
• All models, DTOs, request parameters, and responses must be typed.
10.3 Error Handling
• Implement the AppError class and global error handler.
10.4 Refactor Old JS Code to TS
• This is the main goal: a complete, type-safe API.
🎥 Video: TypeScript API Real Project — Traversy Media [[Link]
⭐ END OF MODULE 4
🗄 MODULE 5 — PostgreSQL + Prisma (The Modern Database Stack)
Duration: 10–14 days (We will use Option A: PostgreSQL + Prisma for its excellent TypeScript integration)
CHAPTER 1 — Introduction to SQL & PostgreSQL
1.1 What is a Relational Database?
• Tables, rows, columns, primary keys, foreign keys.
• The importance of relationships and normalization.
1.2 Introduction to PostgreSQL
• A powerful, open-source object-relational database system.
• Why it's a popular choice for modern applications.
1.3 Installing PostgreSQL & pgAdmin
• Installing PostgreSQL on your OS (Windows, Mac, Linux).
• Using pgAdmin (a GUI tool) to visualize and interact with your database.
1.4 Basic SQL Commands
• CREATE TABLE, INSERT INTO, SELECT, UPDATE, DELETE.
• JOIN (INNER, LEFT) to combine data from multiple tables.
🎥 Video: PostgreSQL Tutorial for Beginners — freeCodeCamp [[Link]
✔ Assignment:
• Using pgAdmin, create a Breweries table and a Beers table.
• Manually insert a few breweries and beers, linking them with a foreign key.
• Write a SELECT query with a JOIN to list all beers with their brewery name.
CHAPTER 2 — Introduction to Prisma
2.1 What is an ORM?
• Object-Relational Mapping: A technique to convert data between incompatible systems.
• Why use an ORM: Write less SQL, prevent SQL injection, work with objects in your code.
2.2 Why Prisma?
• Type-safe database access (auto-generated types!).
• Declarative schema modeling.
• Great developer experience with migrations and a visual database browser (Prisma Studio).
2.3 Setting Up Prisma in Your Project
• npm install prisma --save-dev
• npx prisma init
• Configuring the DATABASE_URL in your .env file.
🎥 Video: Prisma Crash Course — Fireship [[Link]
✔ Assignment:
• Take your TypeScript Express API from Module 4.
• Initialize Prisma in the project.
• Configure the .env file to connect to your local PostgreSQL instance.
CHAPTER 3 — Defining the Database Schema with Prisma
3.1 The Prisma Schema Language
• Understanding [Link].
• Defining models (model User { ... }).
3.2 Defining Fields & Types
• Int, String, Boolean, DateTime, etc.
• Making fields optional with ?.
• Setting default values with @default.
3.3 Defining Relations
• One-to-one: @relation
• One-to-many: @relation
• Many-to-many: Requires an implicit or explicit relation table.
✔ Project: Design the Restaurant Database Schema
• In prisma/[Link], define the following models:
o User (id, email, name, password hash)
o Category (id, name)
o MenuItem (id, name, description, price, categoryId, imageUrl)
o Order (id, userId, status, createdAt, total)
o OrderItem (id, orderId, menuItemId, quantity)
o Reservation (id, userId, partySize, reservationTime)
• Define all the necessary relations between these models.
CHAPTER 4 — Migrations & Database Seeding
4.1 Migrations
• npx prisma migrate dev --name init
• How Prisma reads your schema and generates the SQL to create/update tables.
• The migrations/ folder.
4.2 Seeding the Database
• Creating a prisma/[Link] file.
• Writing a script to populate your database with initial data (e.g., default categories, menu items).
• Running the seed script with npx prisma db seed.
🎥 Video: Prisma Migrations and Seeding — Prisma YouTube [[Link]
✔ Assignment:
• Run your first migration to create the tables in PostgreSQL.
• Create a seed file that adds a few categories (e.g., "Appetizers", "Main Courses", "Beers", "Cakes") and some sample menu
items.
• Run the seed script to populate your database.
CHAPTER 5 — Prisma Client - CRUD Operations
5.1 Instantiating Prisma Client
• Creating a singleton instance of PrismaClient to avoid creating too many connections.
5.2 Basic CRUD Queries
• findMany(): Get all records (with filtering, sorting, pagination).
• findUnique(): Get a single record by its unique identifier.
• create(): Create a new record.
• update(): Update an existing record.
• delete(): Delete a record.
🎥 Video: Prisma Client CRUD — Prisma YouTube [[Link]
✔ Mini-Project: Menu Manager with Prisma
• Create a new file src/scripts/[Link].
• Write functions using Prisma Client to:
o Add a new MenuItem.
o List all MenuItems in a specific Category.
o Update the price of a MenuItem.
o Delete a MenuItem.
• Run these scripts using ts-node to see your database change.
CHAPTER 6 — Advanced Queries & Relations
6.1 Fetching Relations
• Using include to fetch related data in a single query (e.g., fetch MenuItem and its Category).
• Using select to choose which fields to return (for performance and data privacy).
6.2 Filtering, Sorting, and Pagination
• Filtering with where: findMany({ where: { price: { gt: 10 } } }).
• Sorting with orderBy: findMany({ orderBy: { name: 'asc' } }).
• Pagination with skip and take.
✔ Assignment:
• In your Express API, update the GET /menu route.
• Use Prisma Client to fetch all menu items, but include their category information.
• Add optional query parameters for filtering by categoryId and sorting by price.
CHAPTER 7 — Integrating Prisma with Express + TypeScript
7.1 Putting It All Together
• Refactor your Full Restaurant Ordering System API to use Prisma instead of the JSON file.
• Your controllers will now call Prisma functions instead of fs functions.
7.2 Handling Not Found Errors
• Prisma's findUnique returns null if no record is found.
• Check for null and throw your custom AppError with a 404 status.
7.3 Connection Management
• The best practice for connecting/disconnecting Prisma Client in an Express app.
✔ Project: Full API Refactor
• This is the main task of the chapter. Convert every route in your API to use Prisma for all database operations.
• Ensure your TypeScript types are now coming from Prisma's auto-generated types (@prisma/client).
CHAPTER 8 — Authentication & Authorization with Prisma
8.1 Storing Users
• Hashing passwords with bcrypt before saving them to the database.
• Creating a User model with email and passwordHash.
8.2 JWT (JSON Web Tokens)
• Using jsonwebtoken to create and verify tokens.
• Creating a /login route that validates credentials and returns a JWT.
8.3 Protecting Routes
• Creating an authMiddleware that verifies the JWT from the Authorization header.
• Using the middleware to protect routes like POST /orders.
• Using [Link] (added via middleware) to ensure users can only access their own data.
🎥 Video: [Link] Authentication with JWT — Traversy Media [[Link]
✔ Assignment:
• Implement user registration and login in your API.
• Hash passwords before saving.
• Create a protected route (e.g., GET /users/profile) that requires a valid JWT.
CHAPTER 9 — Final Capstone Project: Full-Stack Restaurant System
9.1 Project Requirements
• Backend: Your fully-functional, type-safe, authenticated Restaurant Ordering API built with Node, Express, TypeScript,
Prisma, and PostgreSQL.
• Frontend: A simple frontend (React, Vue, or even plain HTML/JS) that consumes your API.
• Features:
o User authentication (register/login).
o View the menu, with categories and filtering.
o Add items to a cart (can be stored in frontend state/localStorage).
o Place an order (creates Order and OrderItem records).
o View order history.
o Make a reservation.
9.2 Deployment Considerations
• Using Docker to containerize your [Link] app and PostgreSQL database.
• Setting environment variables for production.
• Deploying to a service like Heroku, AWS, or DigitalOcean.
✔ Final Project:
• Build and deploy the full-stack application. This is your portfolio piece, demonstrating mastery of the entire backend
development stack from the ground up.
🎉 END OF THE FULL CURRICULUM