Superfilter AI
Course Description
Take your JavaScript skills to the server with Node.js! Learn to build command-line interfaces, read and write from files and databases, and create scalable servers. Use third-party modules, asynchronous coding, and CRUD operations. Test your code with Jest. Gain all the skills you need to develop professional Node.js applications!
This course and others like it are available as part of our Frontend Masters video subscription.
Preview
CloseWhat They're Saying
I just completed "Introduction to Node.js, v3" by Scott Moss on Frontend Masters! The big thing covered in this class is using ES6 modules and syntax in node.js. Scott covers how you can write a CLI app in node with ES6.
![Tamara Temple](https://senjaio.b-cdn.net/public/media/9f254530-f6eb-40f6-9b50-a92a52e9925b_a03f3405-f676-4549-989f-a74508275505_1559597103761.jpg)
Tamara Temple
tamouse
I just completed "Introduction to Node.js, v3" by Scott Moss on Frontend Masters! Lots of fun and opened my eyes to all the things I can build knowing this.
![noah](https://pbs.twimg.com/profile_images/1535152885935267840/gf4UVxJa.jpg)
noah
noahh_ts
Course Details
Published: August 13, 2023
Learning Paths
Topics
Learn Straight from the Experts Who Shape the Modern Web
Your Path to Senior Developer and Beyond
- 200+ In-depth courses
- 18 Learning Paths
- Industry Leading Experts
- Live Interactive Workshops
Table of Contents
Introduction
Section Duration: 4 minutes
- Scott Moss introduces the course by providing some personal and professional background. An overview of the material that will be covered and course resources are also provided in this segment.
Node Basics
Section Duration: 27 minutes
- Scott summarizes Node.js as a JavaScript runtime used outside of web browsers. Created by Ryan Dahl in 2009, it overcame web browser limitations and server-side scripting inefficiencies.
- Scott explains the non-blocking I/O model employed by Node.js to handle concurrent connections in high-performance network applications. Key features, such as event loops, callbacks, non-blocking APIs, and its single-threaded nature, contribute to its efficiency.
- Scott walks through the setup of Node.js and a version manager called nvm. The segment includes creating a simple Node.js program that prints to the terminal.
- Scott explains the distinctions between how JavaScript is handled in the browser and Node.js, offering an overview of the Node.js REPL. The segment covers differences in the global object, modules, DOM, and console.
Creating a CLI
Section Duration: 26 minutes
- Scott explains the global process object, highlighting commonly used properties and methods attached to it. The segment also covers using process.env to access environment variables.
- Scott explains command-line interfaces, demonstrates creating a Node.js project using npm, and covers the contents of the generated package.json file. The segment also includes linking to the file and defining the script's environment with a hashbang.
- Scott walks through the process of building out the logic for a custom note-taking CLI, enabling it to accept input from the terminal as a new note.
Modules
Section Duration: 45 minutes
- Scott discusses Node.js modules, which are self-contained pieces of code designed to perform specific tasks. Node.js has three types of modules: internal, user-created, and third-party modules.
- Scott demonstrates how to import both internal and external modules in Node.js. The differences between using `require` and `import` for including external modules are also explained in this segment.
- Scott discusses things to keep in mind when developing modules for Node.js apps. This segment covers topics such as module contents, export and import patterns, and index.js patterns.
- Scott discusses built-in modules that are available within the Node.js environment. Installing, updating, and removing third-party modules using npm is also covered in this segment.
- Scott demonstrates the installation and usage of the third-party yargs module to implement a help command for the custom note-taking CLI.
- Scott sets up the foundation for CLI commands such as new, all, find, remove, web, and clean.
File I/O
Section Duration: 1 hour, 20 minutes
- Scott explains the benefits of asynchronous code, which allows other operations to occur while waiting for a task to complete. A demonstration of how to avoid nested callbacks using promises is also covered in this segment.
- Scott demonstrates how to use the built-in FS module, which provides an API for interacting with the file system. Student questions regarding debugging errors involving nesting callbacks are also covered in this segment.
- Scott demonstrates how to use the FS module and a JSON file as a database to store created notes. The foundation for utility functions to read the db.json file, save a JavaScript object, and add a new note are also covered in this segment.
- Scott explains CRUD operations, which involve create, read, update, and delete actions on the notes in the database. Abstracting the previously created insert utility function for creating new notes and a student's question about destructuring are also covered in this segment.
- Scott develops a function to fetch all notes from the database and filters them based on the provided filter string. A demonstration of the process of removing notes with specific IDs and clearing all notes from the database in this segment is also provided in this segment.
- Scott updates the commands to utilize the previously created CRUD methods, allowing for better functionality and interaction with the notes in the database.
Testing
Section Duration: 33 minutes
- Scott discusses the different types of testing in a Node.js application, which include unit testing, integration testing, end-to-end testing, and API testing.
- Scott demonstrates writing and running tests using the Jest testing framework. Jest automatically scans for test files in the tests directory and executes them.
- Scott discusses testing with mock functions and data to perform tests without modifying the actual data in the database. Mock functions, also referred to as "spies," observe the behavior of indirectly called functions, allowing for thorough testing of function behavior and output.
- Scott demonstrates additional examples of tests for different functionalities and use cases.
Servers
Section Duration: 28 minutes
- Scott discusses the concept of a Node.js server, which listens for incoming network requests and responds by executing code or providing data. A walk through the process of creating a basic Node.js server is also covered this segment.
- Scott showcases how to interpolate the notes data, inserting or embedding values into a string or template to dynamically create a new string. How to define the format of the returned notes is also covered in this segment.
- Scott illustrates the utilization of the createServer function to take the array of notes and generate a Node.js HTTP server that serves the formatted HTML to the client.
Wrapping Up
Section Duration: 6 minutes
- Scott wraps up the course by summarizing the CLI app built throughout the lessons. Resources and suggestions for further learning opportunities are also provided in this segment.
Learn Straight from the Experts Who Shape the Modern Web
- In-depth Courses
- Industry Leading Experts
- Learning Paths
- Live Interactive Workshops