Reflecting on REST API best practices
Now, it’s time to reflect on what we’ve done so far. While coding, we may have forgotten a couple of best practices we already know from previous chapters. So, let’s go back and see where we didn’t do well and appreciate things we did well:
- Consistent and resource-oriented URL design:- Best practice: REST APIs should have clear, logical, and resource-oriented URLs. Each URL should consistently represent a specific resource or collection of resources.
- Implementation in our API:- Our user management API uses RESTful routes such as /usersto access the user collection and/users/:idfor specific user operations
- Here’s an example code snippet:
 @Controller('users') export class UsersController { Â Â @Get() findAll() { /*...*/ } Â Â @Get(':id') findOne(@Param('id') id: string) { Â Â Â Â /*...*/ Â Â } Â Â // ...other methods }
- Our user management API uses RESTful routes such as 
 
- Use of HTTP...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                