The address management for our service is a traditional REST API. Addresses can be read, added, edited, and deleted. All of this needs to be done only for the user who is logged in and, therefore, in the JWT.
The following routes will be covered:
- Get addresses (GET /*/users/addresses:) This route is merely returning all addresses belonging to the user.
- Create addresses (POST /*/users/addresses): This route creates a new address for the user.
- Update addresses (PATCH /*/users/addresses/:id): This route updates addresses with a specific ID.
- Delete addresses (DELETE /*/users/addresses/:id): This route deletes addresses with a specific ID.
We will cover the following sections:
- Preparing the controller and routes
- Getting addresses
- Creating addresses
- Updating addresses
- Deleting addresses
Let's go through each one.