Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): add external API endpoint for getting urls #2073

Merged
merged 12 commits into from
Nov 16, 2022

Conversation

halfwhole
Copy link
Collaborator

@halfwhole halfwhole commented Nov 9, 2022

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 to ApiController for getting URLs. (This is modelled after the getUrlsWithConditions method in UserController)

Improvements:

  • Query conditions allows tags to be undefined as well (as would be the case in the API controller)
  • Strengthened the query param validations in userUrlsQueryConditions compared to the one in the user controller; these query params are also now validated before hitting the API controller
    • limit: optional integer from 0 to 1000
    • offset: optional non-negative integer
    • orderBy: optional, removed updatedAt as an option, allow only createdAt and clicks. Is this ok?
    • searchText: optional, converted to lowercase by Joi before being passed to controller
    • state: optional, either active or inactive - similar to fix: restrict state to active and inactive in url search #2050
    • isFile: optional boolean

Possible future improvements:

  • Disable eslint newline-per-chained-call - it conflicts with prettier!
  • Similarly, we can strengthen query param validations in the user controller

Tests

  • Unit tests for API controller

Should write integration tests too, when we have them

@halfwhole halfwhole requested a review from thanhdatle November 15, 2022 03:09
Base automatically changed from feat/api/create-url to develop November 15, 2022 03:13
@gitguardian

This comment was marked as outdated.

@halfwhole halfwhole merged commit 81d5e20 into develop Nov 16, 2022
@halfwhole halfwhole deleted the feat/api/get-url branch November 16, 2022 03:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants