Building a RESTful API
In this chapter, we will build upon the scaffolding structure we created in the previous chapter and dive into writing the essential parts of our application.
We will start by defining the routes of our application and then move on to connecting to data sources. We will also implement the necessary business logic and learn how to solve complex everyday tasks that we may encounter while developing a real-world Fastify application.
The chapter will be divided into several main headings, starting with defining the routes, then connecting to data sources, implementing the routes, securing the endpoints, and applying the Don’t Repeat Yourself (DRY) principle to make our code more efficient.
By the end of this chapter, we will have learned the following:
- How to declare and implement routes using Fastify plugins
- How to add JSON schemas to secure the endpoints
- How to load route schemas
- How to use decorators to implement the DRY pattern...