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

Hands-On Microservices with Node.js

Book Description

Understand microservice concepts while learning to develop with Express, deploy with Docker, and scale with Swarm and Kubernetes using Node 10

About This Book
  • Write clean and maintainable code with JavaScript for better microservices development
  • Build Cloud Native microservices using just Node and Express
  • Develop smart, efficient, and fast enterprise-grade microservices implementation
Who This Book Is For

Hands-On Microservices with Node.js is for anyone who knows the basics of Node.js, wants to enter the world of microservices, and learn why they're so popular. It is also useful if you're a microservices developer using other languages.

What You Will Learn
  • Learn microservice concepts
  • Explore different service architectures, such as Hydra and Seneca
  • Understand how to use containers and the process of testing
  • Use Docker and Swarm for continuous deployment and scaling
  • Learn how to geographically spread your microservices
  • Deploy a cloud-native microservice to an online provider
  • Keep your microservice independent of online providers
In Detail

Microservices enable us to develop software in small pieces that work together but can be developed separately; this is one reason why enterprises have started embracing them. For the past few years, Node.js has emerged as a strong candidate for developing microservices because of its ability to increase your productivity and the performance of your applications.

Hands-On Microservices with Node.js is an end-to-end guide on how to dismantle your monolithic application and embrace the microservice architecture - right from architecting your services and modeling them to integrating them into your application. We'll develop and deploy these microservices using Docker. Scalability is an important factor to consider when adding more functionality to your application, and so we delve into various solutions, such as Docker Swarm and Kubernetes, to scale our microservices. Testing and deploying these services while scaling is a real challenge; we'll overcome this challenge by setting up deployment pipelines that break up application build processes in several stages. Later on, we'll take a look at serverless architecture for our microservices and its benefits against traditional architecture. Finally, we share best practices and several design patterns for creating efficient microservices.

Style and approach

This end-to-end guide will help readers understand the concepts of microservices by picking a microservice example and developing it from start to finish.

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 files e-mailed directly to you.

Table of Contents

  1. Title Page
  2. Copyright and Credits
    1. Hands-On Microservices with Node.js
  3. PacktPub.com
    1. Why subscribe?
    2. PacktPub.com
  4. Contributors
    1. About the author
    2. About the reviewer
    3. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Conventions used
    4. Get in touch
      1. Reviews
  6. The Age of Microservices
    1. Introducing microservices
    2. Introducing Node.js
      1. Modules
      2. Arrow functions
      3. Classes
      4. Promises and async/await
      5. Spread and rest syntax
      6. Default function parameters
      7. Destructuring
      8. Template literals
    3. Advantages of using Node.js
      1. Node.js Package Manager
      2. Asynchronous I/O
      3. Community
    4. From monolith to microservices
    5. Patterns of microservices
      1. Decomposable
      2. Autonomous
      3. Scalable
      4. Communicable
    6. Disadvantages of microservices
    7. Summary
  7. Modules and Toolkits
    1. Express
    2. Micro
    3. Seneca
    4. Hydra
    5. Summary
  8. Building a Microservice
    1. Using Express
      1. Uploading images
      2. Checking an image exists in the folder
      3. Downloading images
      4. Using route parameters
      5. Generating thumbnails
      6. Playing around with colors
      7. Refactor routes
      8. Manipulating images
    2. Using Hydra
    3. Using Seneca
      1. Plugins
    4. Summary
  9. State and Security
    1. State
      1. Storing state
      2. MySQL
      3. RethinkDB
      4. Redis
      5. Conclusion
    2. Security
    3. Summary
  10. Testing
    1. Types of testing methodologies
    2. Using frameworks
    3. Integrating tests
      1. Using chai
      2. Adding code coverage
      3. Covering all code
    4. Mocking our services
    5. Summary
  11. Deploying Microservices
    1. Using virtual machines
    2. Using containers
    3. Deploying using Docker
      1. Creating images
      2. Defining a Dockerfile
      3. Managing containers
      4. Cleaning containers
    4. Deploying MySQL
    5. Using Docker Compose
      1. Mastering Docker Compose
    6. Summary
  12. Scaling, Sharding, and Replicating
    1. Scaling your network
    2. Replicating our microservice
    3. Deploying to swarm
    4. Creating services
      1. Running our service
      2. Sharding approach
      3. Replicating approach
      4. Sharding and replicating
    5. Moving to Kubernetes
      1. Deploying with Kubernetes
    6. Summary
  13. Cloud-Native Microservices
    1. Preparing for cloud-native
    2. Going cloud-native
      1. Creating a new project
      2. Deploying a database service
      3. Creating a Kubernetes cluster
      4. Creating our microservice
      5. Deploying our microservice
    3. Summary
  14. Design Patterns
    1. Choosing patterns
      1. Architectural patterns
        1. Front Controller
        2. Layered
        3. Service Locator
        4. Observer
        5. Publish-Subscribe
    2. Using patterns
      1. Planning your microservice
      2. Obstacles when developing
    3. Summary
  15. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think