Node. js for Beginners A Comprehensive Guide to Building Efficient, Full-Featured Web Applications with Node. js

Build your first production-grade web application from scratch using Node.js, Express, MongoDB, authentication, and testing with the help of expert guidance and step-by-step explanations Key Features Learn JavaScript, async programming, and event-driven architectures in Node.js Discover best practic...

Descripción completa

Detalles Bibliográficos
Otros Autores: Gascón, Ulises, author (author)
Formato: Libro electrónico
Idioma:Inglés
Publicado: Birmingham : Packt Publishing [2024]
Edición:First edition
Materias:
Ver en Biblioteca Universitat Ramon Llull:https://discovery.url.edu/permalink/34CSUC_URL/1im36ta/alma991009820418306719
Tabla de Contenidos:
  • Cover
  • Title Page
  • Copyright
  • Dedication
  • Contributors
  • Table of Contents
  • Preface
  • Part 1: Node.js Overview and JavaScript Language
  • Chapter 1: Introduction to Node.js
  • Technical requirements
  • Why is Node.js so popular?
  • Lightweight and fast
  • Cross-platform and multi-purpose
  • Easy learning curve
  • Ecosystem
  • Community-powered
  • The Node.js single-thread architecture
  • I/O needs to be done differently
  • Non-blocking I/O
  • Going deeper into the event loop
  • Node.js versions
  • Semantic versioning (SemVer)
  • Release details
  • Release schedule
  • Summary
  • Further reading
  • Chapter 2: Setting Up the Development Environment
  • Technical requirements
  • Installing Node.js on macOS, Windows, and Linux
  • macOS
  • Windows
  • Linux
  • Other environments
  • Verifying the installation
  • Managing Node.js versions
  • Managing Node.js by using nvm
  • Installing and using versions
  • Using a .nvmrc file
  • Node.js REPL
  • Interacting with JavaScript using Chrome DevTools
  • The Console panel
  • The Network panel
  • Using Chrome DevTools
  • Summary
  • Further reading
  • Chapter 3: JavaScript Fundamentals
  • Technical requirements
  • JavaScript is a powerful language
  • Understanding versioning - TC39
  • Understanding versioning - ECMAScript
  • What is included in the next version of JavaScript?
  • What is not included in the JavaScript specification?
  • Exploring JavaScript documentation
  • Linting JavaScript code
  • Commenting JavaScript code
  • Using JSDoc
  • Printing values and debugging
  • Variables and constants
  • Naming conventions
  • let versus const
  • Understanding data types
  • undefined
  • object
  • boolean
  • number
  • string
  • function
  • bigint
  • symbol
  • Exploring numbers
  • Arithmetic operators
  • Assignment operators
  • Useful methods
  • The Math object
  • Other numbers
  • Exploring Dates object.
  • Conditional statements
  • Math comparison operators
  • Equality operators
  • Logical operators
  • The NOT operator (!)
  • Equality in JavaScript
  • The nullish coalescing operator (??)
  • The if statement
  • The switch statement
  • Ternary operator
  • Understanding loops
  • while
  • do...while
  • for
  • Using strings in JavaScript
  • Important methods
  • Exploring arrays
  • Basic operations
  • Iterating over an array
  • Destructuring
  • Sets
  • Using objects in JavaScript
  • Basic operations
  • Iteration
  • Shallow copy versus deep copy
  • Merging objects
  • Destructuring
  • Optional chaining (?.)
  • Exploring functions
  • The basics
  • Arrow functions
  • Closures
  • Creating and managing classes
  • Creating a class
  • Class methods
  • Extending classes
  • Static methods
  • Getters and setters
  • Summary
  • Further reading
  • Chapter 4: Asynchronous Programming
  • Technical requirements
  • Asynchronous programming in JavaScript
  • The asynchronous mindset
  • Understanding callbacks
  • Timers and intervals
  • Error first callbacks
  • Callback hell
  • Mastering promises
  • Using promises
  • Creating promises
  • Callback hell with promises
  • Parallel promises
  • Error handling
  • Chaining promises
  • Using async and await to handle asynchronous code
  • async
  • await
  • IIFEs
  • Summary
  • Further reading
  • Part 2: Node.js Ecosystem and Architecture
  • Chapter 5: Node.js Core Libraries
  • Technical requirements
  • Modularizing your code (ESM versus CJS)
  • CommonJS (CJS)
  • ECMAScript Modules (ESM)
  • Understanding how interoperability works
  • Structuring core libraries
  • The library structure
  • Stability index
  • Other core libraries
  • Command-line options
  • Summary
  • Further reading
  • Chapter 6: External Modules and npm
  • Technical requirements
  • Managing the application with package.json.
  • Choosing the correct dependencies for your project
  • Risks
  • Good criteria
  • Installing dependencies
  • Locally or globally
  • Dependency or development dependency
  • Adding new dependency
  • Installing all the dependencies
  • Removing dependencies
  • Understanding the package-lock.json
  • Managing dependencies versions
  • Outdated dependencies
  • Building Isomorphic JavaScript
  • Using npm scripts
  • Executing packages directly with NPX
  • npm alternatives
  • Yarn
  • PNPM
  • Verdaccio
  • Publishing your first package
  • Registries
  • npm account
  • Prepare the package
  • Reviewing the package
  • Publish the package
  • Avoid the scoped packages
  • Release new versions
  • Prevent accidental publishing
  • Best practices
  • Summary
  • Further reading
  • Chapter 7: Event-Driven Architecture
  • Technical requirements
  • Introducing events
  • Watching for file changes
  • The Node.js event emitter library
  • Preventing chaos by organizing the listeners
  • Removing listeners when they are not needed
  • Your first HTTP server
  • Adding an event layer to your modules
  • Summary
  • Further reading
  • Chapter 8: Testing in Node.js
  • Technical requirements
  • Why is testing important?
  • Testing is a complex culture
  • Testing has to be a team activity
  • Take advantage now
  • Testing approach and philosophy
  • Testing is wildly used in the world
  • The test pyramid
  • How should I test my code?
  • Frameworks and libraries
  • Our first test
  • Testing principles and goals
  • Writing our first test suite
  • Utils module
  • Test core library
  • Using the Jest library
  • Mastering code coverage tooling
  • Configuration
  • Running the tests
  • Node.js report
  • TDD in action
  • Summary
  • Further reading
  • Part 3: Web Application Fundamentals
  • Chapter 9: Handling HTTP and REST APIs
  • Technical requirements
  • How the internet works under the hood.
  • History of the internet
  • Internet Infrastructure
  • Request for Comments (RFC)
  • HTTP - server and client relationship
  • Request and response
  • Server-side rendering
  • Single-Page Applications (SPAs)
  • Mastering HTTP
  • HTTP headers
  • Status codes
  • Request methods
  • HTTP payloads
  • HTTP versions
  • Using URLs in web applications
  • REST APIs in a nutshell
  • Exploring the JSON specification
  • Debugging HTTP requests
  • Summary
  • Further reading
  • Chapter 10: Building Web Applications with Express
  • Technical requirements
  • Getting familiar with the Express library
  • Installing Express
  • Hello World
  • Using the generator
  • Debugging
  • Understanding template engines
  • Choosing a template engine
  • Rendering a template
  • Understanding the process
  • Mastering requests
  • HTTP methods
  • Routes
  • Handlers
  • Mastering responses
  • Header management
  • Status codes
  • Redirects
  • Sending data
  • Sending files
  • Using the middleware pattern
  • Understanding the scope
  • Middleware anatomy
  • Adding middleware to the application
  • Adding middleware to a route
  • Common middleware used in Express
  • Using third-party middleware
  • Summary
  • Further reading
  • Part 4: Building Solid Web Applications with Node.js
  • Chapter 11: Building a Web Application Project from Scratch
  • Technical requirements
  • The project Kickoff
  • The project goal
  • Starting with the first step
  • Building a REST API
  • Adding the routes
  • Adding the stores
  • Adding the static files
  • Adding the templates
  • Testing with supertest
  • Adding stores to the server
  • Creating test utils
  • Adding server tests
  • Reviewing the final result of the project
  • The about page
  • Let's celebrate it!
  • Next steps
  • Summary
  • Chapter 12: Data Persistence with MongoDB
  • Technical requirements
  • What is MongoDB?
  • Versions
  • Setting up MongoDB.
  • Installing Docker
  • Running MongoDB with a container
  • Running MongoDB with Docker Compose
  • Adding Docker commands to package.json
  • Connecting to MongoDB
  • Other ways to install MongoDB
  • How to load secrets in Node.js
  • Environment variables
  • The .env file
  • dotenv
  • Using an ORM - Mongoose
  • Migrating a web application to MongoDB
  • Installing dependencies
  • Managing the secrets
  • Migrating the data layer
  • Testing our MongoDB integration layer
  • Update the utilities
  • Refactoring the test suite
  • Some tests must change
  • Checking the coverage
  • Summary
  • Further reading
  • Chapter 13: User Authentication and Authorization with Passport.js
  • Technical requirements
  • Understanding modern authentication and authorization
  • Authentication
  • Authorization
  • JWT in a nutshell
  • The process
  • The theory
  • Cryptography 101
  • JWT structure
  • JWT.io
  • Understanding Passport.js fundamentals
  • Adding authentication and authorization to our web application
  • Clone the base project
  • Setup
  • Run the tests
  • The UI changes
  • Added dependencies
  • Changes in the frontend
  • Added a new store for users
  • JWT utilities
  • Adding new routes
  • Improved testing utilities
  • Test case changes
  • Test coverage
  • Summary
  • Further reading
  • Chapter 14: Error Handling in Node.js
  • Technical requirements
  • Exploring the types of errors
  • Syntax errors
  • Runtime errors
  • Throwing meaningful errors
  • The error object
  • Custom errors
  • Managing errors in Express
  • Error-handling middleware
  • Custom errors
  • Gracefully shutting down the application
  • Events
  • Exit codes
  • Avoiding zombie processes
  • Summary
  • Further reading
  • Chapter 15: Securing Web Applications
  • Technical requirements
  • The importance of security
  • Social engineering
  • Risks in the supply chain
  • The business impact.
  • Where to start with security.