diff --git a/backend/src/routes/items.ts b/backend/src/routes/items.ts index c94064b..6cb826c 100755 --- a/backend/src/routes/items.ts +++ b/backend/src/routes/items.ts @@ -93,6 +93,14 @@ router.get('/', asyncRoute(async (req: Request, res: Response) => { })); router.get('/:id', asyncRoute(async (req: Request, res: Response) => { + // Number() rather than readId(), and that is deliberate rather than an + // oversight. readId would be stricter and would match every other id-taking + // route (#207) — but errorHandling.integration.test.ts drives this exact + // route with a non-numeric id to prove that asyncRoute plus the error + // middleware answer 500 rather than leaving the request hanging, and a + // stricter parse here would leave that test green while removing the thing + // it tests. Switching this over means giving that test another trigger in + // the same change. See #307. const rows = await publicItemQuery() .where('i.id', '=', Number(req.params.id)) .where((eb) => notPending(eb)) diff --git a/backend/tests/unit/itemFilters.test.ts b/backend/tests/unit/itemFilters.test.ts index 4986357..eda7a28 100644 --- a/backend/tests/unit/itemFilters.test.ts +++ b/backend/tests/unit/itemFilters.test.ts @@ -1,6 +1,5 @@ -import { parseItemFilters, FilterError } from '../../src/itemFilters'; +import { parseItemFilters, FilterError, itemFilterExpressions, ItemFilters } from '../../src/itemFilters'; import { db } from '../../src/db'; -import { itemFilterExpressions, ItemFilters } from '../../src/itemFilters'; describe('parseItemFilters', () => { it('returns empty filters for an empty query', () => {