Collections
In the api
directory, nested folders are normally mapped to URL paths. However, you can mark a folder as a collection
to prevent the folder from being included in the route's URL path.
This helps to organize APIs in logical groups without affecting the URL path structure. Collections are also useful for:
Convention
A collection can be created by wrapping a folder with round brackets: (colletionName)
.
Example
An example on grouping related APIs:
> api
> (authentication)
> login
+ route.post.ts
> signup
+ route.post.ts
> forgot
+ route.post.ts