Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Accelerating Server-Side Development with Fastify

You're reading from   Accelerating Server-Side Development with Fastify A comprehensive guide to API development for building a scalable backend for your web apps

Arrow left icon
Product type Paperback
Published in Jun 2023
Publisher Packt
ISBN-13 9781800563582
Length 406 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Authors (3):
Arrow left icon
Maksim Sinik Maksim Sinik
Author Profile Icon Maksim Sinik
Maksim Sinik
Matteo Collina Matteo Collina
Author Profile Icon Matteo Collina
Matteo Collina
Manuel Spigolon Manuel Spigolon
Author Profile Icon Manuel Spigolon
Manuel Spigolon
Arrow right icon
View More author details
Toc

Table of Contents (21) Chapters Close

Preface 1. Part 1:Fastify Basics
2. Chapter 1: What Is Fastify? FREE CHAPTER 3. Chapter 2: The Plugin System and the Boot Process 4. Chapter 3: Working with Routes 5. Chapter 4: Exploring Hooks 6. Chapter 5: Exploring Validation and Serialization 7. Part 2:Build a Real-World Project
8. Chapter 6: Project Structure and Configuration Management 9. Chapter 7: Building a RESTful API 10. Chapter 8: Authentication, Authorization, and File Handling 11. Chapter 9: Application Testing 12. Chapter 10: Deployment and Process Monitoring for a Healthy Application 13. Chapter 11: Meaningful Application Logging 14. Part 3:Advanced Topics
15. Chapter 12: From a Monolith to Microservices 16. Chapter 13: Performance Assessment and Improvement 17. Chapter 14: Developing a GraphQL API 18. Chapter 15: Type-Safe Fastify 19. Index 20. Other Books You May Enjoy

What this book covers

Chapter 1, What Is Fastify?, introduces Fastify, its purpose, and how it can speed up the development process. It covers the basic syntax for starting an application, adding endpoints, and configuring the server.

Chapter 2, The Plugin System and the Boot Process, explains the importance of Fastify plugins for developers, highlighting their role in achieving reusability, code sharing, and proper encapsulation between Fastify instances. The chapter focuses on the declaration and implementation of a simple plugin, gradually adding more layers to explore their interaction and dependency management.

Chapter 3, Working with Routes, covers the importance of routes in applications and how to manage them effectively with Fastify. It explains how to handle URL parameters, body, and query strings and how the router works in Fastify. The chapter also highlights the significance of Fastify’s support for async/await handlers and provides tips for avoiding pitfalls when using them.

Chapter 4, Exploring Hooks, explains how Fastify is different from other web frameworks because it uses hooks instead of middleware. Mastering these hooks is essential for building stable and production-ready server applications. The chapter provides an overview of the hooks and the life cycle of Fastify applications.

Chapter 5, Exploring Validation and Serialization, focuses on implementing secure endpoints with input validation and optimizing them with the serialization process in Fastify. The chapter emphasizes the importance of using Fastify’s built-in tools to control and adapt the default setup to suit your application’s logic. You will learn how to configure and use Fastify components to create straightforward APIs that clients can easily consume.

Chapter 6, Project Structure and Configuration Management, guides you through creating a real-world RESTful cloud-native application, putting into action what you’ve learned in previous chapters. You’ll build a solid project structure that can be reused for future projects, utilizing community packages and creating custom plugins as needed.

Chapter 7, Building a RESTful API, focuses on building a real-world Fastify application by defining routes, connecting to data sources, implementing business logic, and securing endpoints. The chapter will cover essential parts of the application, including implementing routes, connecting to data sources, securing endpoints, and applying the don’t repeat yourself (DRY) principle to make code more efficient.

Chapter 8, Authentication and File Handling, covers user authentication and file handling in our application. We’ll begin by implementing a reusable JWT authentication plugin that will handle user authentication, sessions, and authorization. We’ll also explore decorators to expose authenticated user data in route handlers. Next, we’ll develop a plugin to handle file import/export in CSV format for user to-do tasks.

Chapter 9, Application Testing, focuses on testing in Fastify. It covers the integrated testing tools and how to use them. It also explains how to run tests in parallel without requiring an HTTP server.

Chapter 10, Deployment and Process Monitoring for a Healthy Application, explores different deployment options for our Fastify API, focusing on a monolith deployment using Docker, MongoDB, and Fly.io. We will also learn about Node.js metrics and how to monitor the health of our server using Prometheus and Grafana.

Chapter 11, Meaningful Application Logging, explains how to implement effective logging in your Fastify application to keep track of what’s happening and monitor its performance. You’ll discover how to set up a logging configuration that captures all the necessary information without logging sensitive data and how to interpret and analyze logs to identify and troubleshoot issues.

Chapter 12, From a Monolith to Microservices, discusses restructuring a monolithic application into multiple modules to minimize conflicts between different teams. The chapter discusses adding new routes without increasing project complexity, splitting the monolith into microservices, and using an API gateway to route relevant calls. The chapter also covers logging, monitoring, error handling, and addressing operator questions.

Chapter 13, Performance Assessment and Improvement, focuses on optimizing the performance of your Fastify application. You will learn how to measure your code’s performance to avoid slow performance, identify bottlenecks in your code, and prevent production issues. You will be introduced to an instrumentation library to help you analyze how your server reacts to high-volume traffic. Additionally, you will learn how to interpret the measurements and take action to keep your server’s performance healthy.

Chapter 14, Developing a GraphQL API, explains how to incorporate GraphQL into your Fastify application using a specialized plugin. As GraphQL becomes increasingly popular, more and more APIs are being built with this query language. By using Fastify’s unique architecture and avoiding common mistakes, you can take full advantage of GraphQL in your application.

Chapter 15, Type-Safe Fastify, explores how Fastify’s built-in TypeScript support can help developers write more robust and maintainable applications. With compile-time type safety and better code completion, type inference, and documentation, developers can catch errors early in the development process and avoid unexpected runtime errors, leading to more stable and reliable applications. Using TypeScript with Fastify can also provide an extra layer of protection to code, making deployments safer and giving developers more confidence when developing code.

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image