11# Routes Folder
22
3- Routes define endpoints within your application. Fastify provides an
4- easy path to a microservice architecture, in the future you might want
5- to independently deploy some of those.
3+ Routes define the pathways within your application.
4+ Fastify's structure supports the modular monolith approach, where your
5+ application is organized into distinct, self-contained modules.
6+ This facilitates easier scaling and future transition to a microservice architecture.
7+ In the future you might want to independently deploy some of those.
68
79In this folder you should define all the routes that define the endpoints
810of your web application.
@@ -13,7 +15,7 @@ typically stored in a file; be careful to group your routes logically,
1315e.g. all ` /users ` routes in a ` users.js ` file. We have added
1416a ` root.js ` file for you with a '/' root added.
1517
16- If a single file become too large, create a folder and add a ` index.js ` file there:
18+ If a single file becomes too large, create a folder and add a ` index.js ` file there:
1719this file must be a Fastify plugin, and it will be loaded automatically
1820by the application. You can now add as many files as you want inside that folder.
1921In this way you can create complex routes within a single monolith,
@@ -22,3 +24,6 @@ and eventually extract them.
2224If you need to share functionality between routes, place that
2325functionality into the ` plugins ` folder, and share it via
2426[ decorators] ( https://fastify.dev/docs/latest/Reference/Decorators/ ) .
27+
28+ If you're a bit confused about using ` async/await ` to write routes, you would
29+ better take a look at [ Promise resolution] ( https://fastify.dev/docs/latest/Reference/Routes/#promise-resolution ) for more details.
0 commit comments