These services need to be reachable via URLs, just as with the user service. Remember that Vapor's way of addressing that is by using a router. The router compares incoming request URLs to what we have told it to do and will execute the desired function. We need to do this for every service that is serving as a Representational State Transfer (REST) API.
For this service, we will need routes that cover the following features:
- Getting categories
- Getting products
- Updating, creating, and deleting products
- Updating, creating, and deleting categories
The last two features—updating, creating, and deleting products and categories—are of course reserved for administrators and require JWT verification with the correct user level. The other two features—getting (reading) categories and products—are open to the public.
Note that we will...