Hey everyone,
I want to share a confession from years ago, back when I was just starting out with REST API design.
I thought I was being super clever and organised by designing my API endpoints around user roles. My brain went straight for /admin/...
for all things admin and /customer/...
for customer-related actions. Felt neat, right? ๐
Then came the inevitable moment when both admins and customers needed to interact with the same data (users, for example), and my perfectly segmented system crumbled fast. ๐คฆโโ๏ธ
That's when the lightbulb finally went off: resource-based RESTful design isn't about who is accessing the data, it's fundamentally about the data itself. This simple but profound shift saved me from countless headaches and taught me a crucial lesson in API architecture.
Instead of having separate, duplicated logic, focusing on resources like /users
, /products
, and /orders
, and then implementing proper authentication and authorisation to control access based on roles, made everything so much cleaner and more maintainable.
Anyone else have a similar early "a-ha!" moment in their dev journey? What's a mistake you made that ended up teaching you a valuable lesson? Share your stories below! ๐
Top comments (0)