connect-api-mocker
connect-api-mocker copied to clipboard
Catch all nested paths
To have a chance to define a mock that will catch all requests that starts with a path could be great.
For example, lets say we have 2 endpoints like below:
/api/users/3123123/messages/321
/api/users/4343/messages
/api/users/213
For now there is no chance to catch all these 3 endpoints with a single custom middleware. Maybe to have a mock definition in a path like below could be useful:
mocks/api/users/__user_id*__/ANY.js
Notice the star char in the wildcard name. That could mean, that wildcard will match all of this paths and nested paths.
Let's think about this...
the correct path would be mocks/api/users/__user_id__/*/ANY.js
so the * indicated to use all nested paths, but a user id is still required.
mocks/api/users/*/ANY.js
would match all even without user id