I need to build an API where most of the routes are prefixed with a common URL part which also has a parameter.
In my specific case, my routes need to look like:
/accounts/:account/resource1/:someParam
/accounts/:account/resource2/:someParam/whatever
/accounts/:account/resource3/
/accounts/:account/resource4/subResource/
and so on..
So ideally I would create a parent route /accounts/:account/
which will contain the children routes (resource1
, resource2
, resource3
, resource4
, etc...).
I also need the :account
parameter to be accessible from all the children routes.
What is the best way to achieve this with NestJS ?