
Node Cookbook - Third Edition
- 654 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Node Cookbook - Third Edition
About this book
Over 60 high-quality recipes covering debugging, security, performance, microservices, web frameworks, databases, deployment and more; rewritten for Node.js 8, Node.js 6, and Node.js 4About This Book• Actionable recipes across the full spectrum of Node.js development• Cutting edge techniques and tools for measuring and improving performance• Best practices for creating readily-scalable production systemsWho This Book Is ForIf you have good knowledge of JavaScript and want to build fast, efficient, scalable client-server solutions, then this book is for you. Some experience with Node.js is assumed to get the most out of this book. If working from a beginner level Node Cookbook 2nd Edition is recommended as a primer for Node Cookbook 3rd Edition. What You Will Learn• Debug Node.js programs• Write and publish your own Node.js modules• Detailed coverage of Node.js core API's• Use web frameworks such as Express, Hapi and Koa for accelerated web application development• Apply Node.js streams for low-footprint data processing• Fast-track performance knowledge and optimization abilities• Persistence strategies, including database integrations with MongoDB, MySQL/MariaDB, Postgres, Redis, and LevelDB• Apply critical, essential security concepts• Use Node with best-of-breed deployment technologies: Docker, Kubernetes and AWSIn DetailToday's web demands efficient real-time applications and scalability. Asynchronous event-driven programming is ideal for this, and this is where Node.js comes in. Server-side JavaScript has been here since the 90s, but Node got it right.With Node for tooling and server-side logic, and a browser-based client-side UI, everything is JavaScript. This leads to rapid, fluid development cycles. The full-stack, single language experience means less context-switching between languages for developers, architects and whole teams.This book shows you how to build fast, efficient, and scalable client-server solutions using the latest versions of Node.The book begins with debugging tips and tricks of the trade, and how to write your own modules. Then you'll learn the fundamentals of streams in Node.js, discover I/O control, and how to implement the different web protocols.You'll find recipes for integrating databases such as MongoDB, MySQL/MariaDB, Postgres, Redis, and LevelDB. We also cover the options for building web application with Express, Hapi and Koa.You will then learn about security essentials in Node.js and advanced optimization tools and techniques.By the end of the book you will have acquired the level of expertise to build production-ready and scalable Node.js systems.The techniques and skills you will learn in this book are based on the best practices developed by nearForm, one of the leaders in Node implementations, who supported the work of the authors on this book.Style and approachThis recipe-based practical guide presents each topic with step-by-step instructions on how you can create fast and efficient server side applications using the latest features and capabilities in Node 8 whilst also supporting usage with Node 4 and 6.
Frequently asked questions
- Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
- Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app.
Information
Building Microservice Systems
- Creating a simple RESTful microservice
- Consuming a service
- Setting up a development environment
- Standardizing service boilerplate
- Using containerized infrastructure
- Service discovery with DNS
- Adding a Queue based service
Introduction
- Focus: Each service should do one thing only and do it well. This means that an individual microservice should contain a small amount of code that is easy for an individual developer to reason about.
- Decoupling: Services run in their own process space and are therefore decoupled from the rest of the system. This makes it easy to replace an individual microservice without greatly perturbing the rest of the system.
- Fine Grained Continuous Delivery/Deployment: Services are individually deployable, this leads to a model whereby deployment can be an ongoing process. thus removing the need for Big Bang deployments.
- Individually scalable: Systems may be scaled at the service level leading to more efficient use of compute resources.
- Language independent: Microservice systems may be composed of services written in multiple languages, allowing developers to select the most appropriate tool for each specific job.

- Clients: Typically, web-based or mobile applications, make HTTP connections to an API layer.
- Static assets: Such as images, style sheets, and other elements that are used to render the user interface.
- API layer: This is usually a thin layer that provides the routing between client requests and microservices that ultimately respond to these requests.
- Service Discovery: A mechanism for discovering and routing to microservices. This can be as simple as a shared configuration file or a more dynamic mechanism such as DNS.
- Direct response services: These types of services are typically reached via a point to point protocol such as HTTP or raw TCP and will usually perform a distinct action and return a result.
- Async services: These types of services are typically invoked via a bus-based technology such as RabbitMQ or Apache Kafka. These may or may not return a response to the caller.
- Data sources and External APIs: Services will usually interact with one or more data sources or external systems in order to generate responses to requests.
- Limited, focused responsibility
- Highly cohesive, tightly scoped functionality
- Independently deployable
- Small enough to be rewritten by a single developer in under two weeks
Creating a simple RESTful microservice
Getting ready
$ mkdir micro
$ cd micro
How to do it...
Table of contents
- Title Page
- Copyright
- Credits
- Foreword
- About the Authors
- About the Reviewers
- www.PacktPub.com
- Customer Feedback
- About nearForm
- Preface
- Debugging process*
- Writing Modules
- Coordinating I/O
- Using Streams
- Wielding Web Protocols
- Persisting to Databases
- Working with Web Frameworks
- Dealing with Security
- Optimizing Performance
- Building Microservice Systems
- Deploying Node.js