Get Programming with Node.js teaches you to write server-side code in JavaScript using Node.js. In 34 fast-paced, fun, and practical lessons, you'll discover how to extend your existing JavaScript skills to write back-end code for your web applications. After setting up the perfect developer environment, you'll get straight into developing your first app using Express.js, a lightweight MVC-style web framework. You'll learn all-important security and authentication features, as well as database tasks. When your basic app is completed, you'll add extra functionality like chat before deploying the finished product. Thanks to the easy-to-digest examples and exercises, you'll be coding with Node.js like a pro in no time!
"...easy to read style and lots of short cuts I didn't know about that makes coding a lot quicker & convenient..."
~ Aindriu Mac Giolla Eoin
"Takes you from knowing nothing to serving web pages using Node.js."
~ Roger Sperberg
"If you are a web developer and want to get into Node.js, this book is a very good option for you."
~ Vinicius Miana Bezerra
Unit 0: Getting Set Up
Lesson 0: Set up Node.js and the JavaScript Engine
0.1 What you’re going to learn
0.2 Understanding Node.js
0.3 The minimally qualified reader
0.4 Why learn to develop in Node.js?
0.5 Preparing yourself for this book
0.6 Summary
0.7 Answers to Quick Check Exercises
Lesson 1: Setting up your environment
1.1 Installing Node.js
1.2 Installing a text editor
1.3 Setting up deployment tools
1.4 Working with the Node.js REPL in terminal
1.5 Summary
Lesson 2: Running a Node.js application
2.1 Creating a JavaScript file
2.2 Running your JavaScript file with Node.js
2.3 Running Individual JavaScript Commands
2.4 Summary
2.5 Answers to Quick Check Exercises
Unit 1: Getting Started with Node.js
Lesson 3: Setting up a Node.js application
3.1 Creating a Node.js module
3.2 Running npm commands
3.3 Initializing a Node.js application
3.4 Summary
3.5 Answers to Quick Check Exercises
Lesson 4: Building a simple web server in Node.js
4.1 Understanding web servers
4.2 Initialize the application with npm
4.3 Code the application
4.4 Run the application
4.5 Summary
4.6 Answers to Quick Check Exercises
Lesson 5: Handling incoming data
5.1 Reworking your server code
5.2 Analyzing request data
5.3 Adding Routes to a Web Application
5.4 Summary
5.5 Answers to Quick Check Exercises
Lesson 6: Writing better routes and serving external files
6.1 Serving static files with the fs module
6.2 Serving assets
6.3 Moving your routes to another file
6.4 Summary
6.5 Answers to Quick Check Exercises
Lesson 7: Capstone: A static web application
7.1 Initializing the application
7.2 Application directory structure
7.3 Creating main.js and router.js
7.4 Creating views
7.5 Adding Assets
7.6 Creating routes
7.7 Handle file reading errors
7.8 Summary
Unit 2: Easier Web Development with Express
Lesson 8: Setting up an app with Express.js
8.1 Installing the Express.js package
8.2 Building your first Express.js application
8.3 Working your way around a web framework
8.4 Summary
8.5 Answers to Quick Check Exercises
Lesson 9: Routing in Express.js
9.1 Building routes with Express.js
9.2 Analyzing Request data
9.3 Express.js and MVC
9.4 Summary
9.5 Answers to Quick Check Exercises
Lesson 10: Connecting Views with templates
10.1 Connecting a templating engine
10.2 Passing data from your controllers
10.3 Setting up partials and layouts
10.4 Summary
10.5 Answers to Quick Check Exercises
Lesson 11: Configurations and error handling
11.1 Modifying your start script
11.2 Handling errors with Express.js
11.3 Serving static files
11.4 Summary
11.5 Answers to Quick Check Exercises
Lesson 12: Capstone : Enhancing the Confetti Cuisine site with Express.js
12.1 Initializing the application
12.2 Building the application
12.3 Adding more routes
12.4 Routing to views
12.5 Serving static views
12.6 Passing content to the views
12.7 Handle the errors
12.8 Summary
Unit 3: Connecting to a database
Lesson 13: Set up a MongoDB database
13.1 Setting up MongoDB
13.2 Running commands in the MongoDB shell
13.3 Connecting MongoDB to your application
13.4 Summary
13.5 Answers to Quick Check Exercises
Lesson 14: Building Models with Mongoose
14.1 Setting up Mongoose with your Node.js application
14.2 Creating a schema
14.3 Organizing your models
14.4 Summary
14.5 Answers to Quick Check Exercises
Lesson 15: Connecting Controllers and Models
15.1 Creating a controller for subscribers
15.2 Saving posted data to a model
15.3 Using promises with Mongoose
15.4 Summary
15.5 Answers to Quick Check Exercises
Lesson 16: Capstone: Saving user subscriptions
16.1 Setting up the database
16.2 Modeling data
16.3 Adding a subscription form
16.4 Summary
Unit 4: Building a user model
Lesson 17: Improving your data models
17.1 Adding validations on the model
17.2 Testing models in REPL
17.3 Creating model associations
17.4 Populating data from associated models
17.5 Summary
17.6 Answers to Quick Check Exercises
Lesson 18: Building the user model
18.1 Building the user model
18.2 Adding CRUD methods to your models
18.3 Building the index page
18.4 Summary
18.5 Answers to Quick Check Exercises
Lesson 19: Creating and reading your models
19.1 Building the new user form
19.2 Creating new users from a view
19.3 Reading user data with show
19.4 Summary
19.5 Answers to Quick Check Exercises
Lesson 20: Updating and deleting your models
20.1 Building the edit user form
20.2 Updating users from a view
20.3 Deleting users with the delete action
20.4 Summary
20.5 Answers to Quick Check Exercises
Lesson 21: Capstone: Adding CRUD models to Confetti Cuisine
21.1 Getting set up
21.2 Building the models
21.3 Creating the views
21.4 Structuring routes
21.5 Creating controllers
21.6 Summary
Unit 5: Authenticating user accounts
Lesson 22 Adding sessions and flash messages
22.1 Setting up flash message modules
22.2 Adding flash messages to controller actions
22.3 Summary
22.4 Answers to Quick Check Exercises
Lesson 23 Building a user login and encrypting passwords
23.1 Implementing the user login form
23.2 Encrypting passwords
23.3 Adding validation middleware with express-validator
23.4 Summary
23.5 Answers to Quick Check Exercises
Lesson 24 Adding user authentication
24.1 Implementing Passport.js
24.2 Modifying the create action to use passport registration
24.3 Authenticating users at login
24.4 Summary
24.5 Answers to Quick Check Exercises
Lesson 25 Capstone: Adding user authentication
25.1 Getting set up
25.2 Creating a login form
25.3 Adding encryption with Passport.js
25.4 Adding flash messaging
25.5 Adding validation middleware with express-validator
25.6 Adding authentication with Passport.js
25.7 Logging in and out
25.8 Summary
Unit 6: Building an API
Lesson 26 Adding an API to your application
26.1 Organizing your routes
26.2 Creating an API
26.3 Calling your API from the client
26.4 Summary
26.5 Answers to Quick Check Exercises
Lesson 27 Accessing your API from your app
27.1 Applying an API namespace
27.2 Joining groups via modal
27.3 Creating an API endpoint to connect models
27.4 Summary
27.5 Answers to Quick Check Exercises
Lesson 28 Adding API security
28.1 Simple security
28.2 API token
28.3 JSON Web Tokens
28.4 Summary
28.5 Answers to Quick Check Exercises
Lesson 29 Capstone: Building an API
29.1 Restructuring routes
29.2 Adding the courses partial
29.3 Creating the AJAX function
29.4 Adding an API endpoint
29.5 Creating an action to enroll users'
29.6 Summary
Unit 7: Adding Chat functionality
Lesson 30 Working with Socket.io
Lesson 31 Saving chat messages
Lesson 32 Adding a chat notification indicator
Lesson 33 Capstone: Add a chat feature to Confetti Cuisine
Unit 8: Deploying and managing in production
Lesson 34 Deploying your application
Lesson 35 Managing in production
Lesson 36 Testing your application
Lesson 37 Capstone: Deploying Confetti Cuisine
Unit A: Appendixes
Appendix A: JavaScript Essentials
A.1 New in ES6
A.2 Let
A.3 Const
A.3.1 String Interpolation
A.3.2 Arrow Functions
A.4 JavaScript in Node.js
Appendix B: JavaScript ES6
B.1 Logging
B.2 Global objects
B.2.1 Other non-global objects
About the Technology
Why use several languages for a web application when you only need one? Node.js is a server-side platform and runtime that you can use to build full stack web applications entirely in JavaScript! Node supports scalable, high-performance applications with easy asynchronous communication, an event-driven mindset, and a vast ecosystem of tools and modules. Node can handle the real-time response rates that games, chat sites, and statistical services need, and you get to program everything in JavaScript.
What's inside
- Setting up your Node development environment
- Creating a simple web server
- Working with Express.js
- Saving application data to a MongoDB database
- Building a complete REST API
- Deploying the finished product
- Debugging your app in production order
About the reader
Written for developers who know HTML, CSS, and JavaScript. No prior experience with Node.js is required.
About the author
Jonathan Wexler has an extensive background in computer theory and web development. Having curated a Node.js curriculum as the academic director and lead developer for The New York Code and Design Academy, Jonathan has instructed multiple intensive programs in full stack development and currently works as a senior developer for Bloomberg LP.
FREE domestic shipping on three or more pBooks