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

Bed 5258 #1111

Merged
merged 5 commits into from
Jan 29, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions cmd/api/src/api/v2/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ func ParseLimitQueryParameter(params url.Values, defaultValue int) (int, error)
}
}

// ParseOptionalLimitQueryParameter should only be used if the endpoint is safe to return all results for a given query
// This will allow the user to submit an API call with `limit=-1` which will in turn allow the database to return unlimited
// results.
func ParseOptionalLimitQueryParameter(params url.Values, defaultValue int) (int, error) {
if param := params.Get(model.PaginationQueryParameterLimit); param == "" {
return defaultValue, nil
} else if limit, err := strconv.Atoi(param); err != nil {
return 0, fmt.Errorf("error converting limit value %v to int: %v", param, err)
} else if limit < -1 {
return 0, fmt.Errorf(utils.ErrorInvalidLimit, limit)
} else {
return limit, nil
}
}

func ParseTimeQueryParameter(params url.Values, key string, defaultValue time.Time) (time.Time, error) {
if param := params.Get(key); param != "" {
return time.Parse(time.RFC3339Nano, param)
Expand Down
2 changes: 2 additions & 0 deletions packages/javascript/js-client-library/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ class BHEAPIClient {
) => {
const params = new URLSearchParams();
params.append('finding', finding);

params.append('skip', skip.toString());
params.append('limit', limit.toString());
if (sortBy) {
Expand All @@ -556,6 +557,7 @@ class BHEAPIClient {
Object.assign(
{
params: params,
headers: options?.headers,
},
options
)
Expand Down
Loading