feat(api): add external API endpoint for getting urls #2073
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
We want to add an external API endpoint for getting URLs (
GET /api/v1/urls
)See Notion page on external API
Solution
Added the
getUrlsWithConditions
method toApiController
for getting URLs. (This is modelled after thegetUrlsWithConditions
method inUserController
)Improvements:
tags
to be undefined as well (as would be the case in the API controller)userUrlsQueryConditions
compared to the one in the user controller; these query params are also now validated before hitting the API controllerlimit
: optional integer from 0 to 1000offset
: optional non-negative integerorderBy
: optional, removedupdatedAt
as an option, allow onlycreatedAt
andclicks
. Is this ok?searchText
: optional, converted to lowercase by Joi before being passed to controllerstate
: optional, either active or inactive - similar to fix: restrict state to active and inactive in url search #2050isFile
: optional booleanPossible future improvements:
newline-per-chained-call
- it conflicts with prettier!Tests
Should write integration tests too, when we have them