feat: add public search controls
Quality / test (push) Canceled after 0s

Add public category lookup options, allowlisted sort ordering, URL-backed catalog controls, and strict search route validation with regression tests.
This commit is contained in:
2026-09-09 01:44:28 -04:00
parent 67ce29a93e
commit f4e4685ecc
10 changed files with 71 additions and 12 deletions
@@ -23,6 +23,7 @@ export function createSearchQuery({
page = 1,
limit = 20,
includeSold = false,
sort = 'recent',
}) {
const text = normalizeSearchQuery(query);
@@ -50,6 +51,10 @@ export function createSearchQuery({
throw new Error('minPriceMinor must be <= maxPriceMinor');
}
if (!['recent', 'price_low', 'price_high'].includes(sort)) {
throw new Error('sort must be recent, price_low, or price_high');
}
return {
text,
...(typeof category === 'string' && category.trim().length > 0 ? { category: category.trim() } : {}),
@@ -58,6 +63,7 @@ export function createSearchQuery({
page,
limit,
includeSold,
...(sort !== 'recent' ? { sort } : {}),
};
}