O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Node Craftsman Book

Book Description

Become a Node.js craftsman.

About This Book

  • This book will help readers to dive deeper into software development with Node.js and JavaScript
  • Takes a craftsman approach to Node.js and object-orientation and test-driven development
  • Crafts many of the small details of Node.js and through to fully-fledged web applications with REST

Who This Book Is For

This book is written to help you if you’re working with Node.js already, but you want to move your craft to the next level with Node.js, so some working knowledge of Node.js is of course already assumed, so that we can look at the work of crafting applications with Node.

What You Will Learn

  • How to connect to databases like MongoDB and MySQL from your Node.js application
  • How to unit tests and end-to-end tests for your code
  • When and how to leverage migrations for setting up a continuous deployment workflow
  • Detailed insight into how the Node Package Manager, NPM works
  • How object-orientation actually works in JavaScript
  • Ways to keep your code fast and efficient using asynchronous and non-blocking operations
  • How to use and create event emitters
  • How to use REST frameworks to write full-fledged web applications
  • How to integrate Node.js with Angular

In Detail

The Node Craftsman Book helps JavaScript programmers with basic Node.js knowledge to now thoroughly master Node.js and JavaScript. This book dives you deeper into the craft of software development with Node.js and JavaScript, incuding object-orientation, test-driven development, database handling, web frameworks, and much more.

The Node Craftsman Book shows you how to work with Node.js and how to think deeply about how you build your Node projects. You'll master how to build a complete Node.js application across six crafting milestones, and you'll learn many specific skills to achieve that mastery. These skills include how to work with the Node Package Manager in depth, how to connect your Node applications to databases, and how to write unit tests and end-to-end tests for your code. You'll experience the full Node.js development picture, and learn how to craft and control your Node.js applications - right through to fully-fledged web applications using REST, and integration with Angular applications.

Style and approach

This book builds on your early knowledge and experience of Node.js and takes a craftsman approach to understanding the whole picture more deeply and shaping your Node applications to perform the way a craftsman would want. So, we take a thoughtful and broad thinking and coding approach to work with Node.js in this book.

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

Table of Contents

  1. Preface
    1. Status
    2. Notes on code formatting
    3. Intended audience
  2. Part 1: Node.js Basics in Detail
    1. Introduction to Part 1
  3. Working with NPM and Packages
  4. Test-driven Node.js Development
  5. Object-oriented JavaScript
    1. Blueprints versus finger-pointing
    2. A classless society
    3. Creating objects
      1. Using a simple function to create plain objects
      2. Using a constructor function to create objects
      3. Using prototyping to efficiently share behaviour between objects
    4. Object-orientation, prototyping, and inheritance
      1. A classless society, revisited
    5. Summary
  6. Synchronous and Asynchronous Operations Explained
    1. Visualizing the Node.js execution model
    2. Blocking and non-blocking operations
  7. Using and Creating Event Emitters
    1. Introduction
    2. Creating your own event emitter object
    3. Summary
  8. Optimizing Code Performance and Control Flow Management Using the Async Library
    1. Executing expensive asynchronous background tasks in parallel
    2. Optimizing code structure with async
  9. Node.js and MySQL
    1. Using the mysql library
    2. A first database application
    3. Using the Streaming API
    4. Making SQL queries secure against attacks
    5. Summary
  10. Node.js and MongoDB
    1. Some MongoDB basics
    2. Applying CRUD operations with the low-level mongodb driver
    3. Retrieving specific documents using filters
    4. More complex update operations
    5. Working with indexes
    6. Querying collections efficiently
    7. Summary
  11. Part 2: Building a Complete Web Application with Node.js and Angular
    1. Introduction
    2. The requirements from a user's perspective
    3. High level architecture overview
    4. Setting up the development environment
  12. Milestone 1 – A First Passing Test Against the Server
  13. Milestone 2 – The API Responds with Actual Database Content
    1. Abstracting database access
    2. Ensuring a clean slate for test runs
    3. Completing the first spec
  14. Milestone 3 – Setting the Stage for a Continuous Delivery Workflow
    1. Introducing automatic database migrations
  15. Milestone 4 – Giving Users a Frontend
    1. Setting up frontend dependencies through bower
    2. Serving the frontend through the backend server
    3. Adding the frontend code
    4. Adding AngularJS view templates
  16. Milestone 5 – More Work on the Backend
    1. Adding a route for retrieving categories
    2. Making the backend recognize different environments
  17. Milestone 6 – Completing the Backend and Finalizing the Application
    1. Creating the route for adding new keywords
    2. Creating the route for updating keywords
    3. Creating the route for deleting keywords
    4. Summary