Hello, I'm in the process of writing a REST API with Node.js, Express, PostgreSQL, and the MVC design pattern.
I have three tables with for each of them a corresponding model:
users
users
lists
lists
tasks
tasks
users
users
has a
role
role
column (
admin
admin
or
user
user
)
I was wondering whether I should have
/api/v1/admin/users/:id/ban
/api/v1/admin/users/:id/ban
or
/api/v1/users/:id/ban
/api/v1/users/:id/ban
The first route has 'admin' in it to make it explicit it's only used by users with
admin
admin
as
role
role
while the second uses a more generic
users
users
route.
It's a design thing, and I'd like to know which one is more conventional. In any case, a middleware will check the roles, but it's more about the route naming itself.