-
Notifications
You must be signed in to change notification settings - Fork 11
add pagination to list api #155
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #155 +/- ##
==========================================
+ Coverage 86.71% 87.26% +0.55%
==========================================
Files 39 40 +1
Lines 2243 2364 +121
==========================================
+ Hits 1945 2063 +118
- Misses 298 301 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/routes/list-paginated.js
Outdated
| const limit = Number.parseInt(searchParams.get('limit'), 10) ?? null; | ||
| const offset = Number.parseInt(searchParams.get('offset'), 10) ?? null; | ||
|
|
||
| function numOrUndef(num) { | ||
| return Number.isNaN(num) ? undefined : num; | ||
| } | ||
|
|
||
| return /* await */ listObjectsPaginated(env, daCtx, numOrUndef(limit), numOrUndef(offset)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The ?? null will never trigger with NaN. Assuming that 0 is an invalid param for limit and offset you could use:
const limit = Number.parseInt(searchParams.get('limit'), 10) || undefined;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. Unfortunately 0 for offset is a valid input - I'll just remove the ?? null, it's a leftover from before I realised that it parseInt returns NaN and not null.
| import { getChildRules, hasPermission } from '../utils/auth.js'; | ||
|
|
||
| export default async function getListPaginated({ req, env, daCtx }) { | ||
| if (!daCtx.org) return listBuckets(env, daCtx); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we even support listing buckets on this new API endpoint? With the infrastructure move, this shouldn't be needed anymore, as we have all sites in one bucket @auniverseaway .
|
Looks good to me. I like that there are a lot of new tests. |
Fix #150