🛣️ Category routes
Category routes are SDK composers, not Express middleware. Public reads use HTTP; mutations require authentication followed by the configured administrator identity check.
Inventory
| Route | Method / protocol | Path | Schema | Validators | Success status |
|---|---|---|---|---|---|
createCategoryRoute | POST / HTTP | /categories | createCategorySchema | isAuthenticated(), checkIdentityType(['admin']) | 200 |
getCategoryRoute | GET / HTTP | /categories/:categoryId | getCategorySchema | doesCategoryExist | 200 |
findCategoriesRoute | GET / HTTP | /categories | findCategoriesSchema | None | 200 |
updateCategoryRoute | PATCH / HTTP | /categories/:categoryId | updateCategorySchema | isAuthenticated(), checkIdentityType(['admin']), doesCategoryExist | 200 |
deleteCategoryRoute | DELETE / HTTP | /categories/:categoryId | deleteCategorySchema | isAuthenticated(), checkIdentityType(['admin']), doesCategoryExist | 204 |
enableCategoryRoute | POST / HTTP | /categories/:categoryId/enable | enableCategorySchema | isAuthenticated(), checkIdentityType(['admin']), doesCategoryExist | 204 |
disableCategoryRoute | POST / HTTP | /categories/:categoryId/disable | disableCategorySchema | isAuthenticated(), checkIdentityType(['admin']), doesCategoryExist | 204 |
Details
createCategoryRoute
Implementation
Endpoint: POST /categories
Access: Administrator; validators execute isAuthenticated() then checkIdentityType(['admin']).
Request: Required application/json create body, plus the configured auth transport.
Pipeline: createCategory → getCategoryById → normalizeCategoryTerminator.
Success: 200 with the created category after _id removal; the service uses its ordinary res.json(result) branch.
Failure: Schema/body errors and the handler's 400/500 failures; authentication/authorization failures are documented in validators.View complete source
getCategoryRoute
Implementation
Endpoint: GET /categories/:categoryId
Access: Public; direct doesCategoryExist runs first.
Request: Required string categoryId path value in the get schema.
Pipeline: getCategoryById → normalizeCategoryTerminator.
Success: 200 with one category without MongoDB _id; the service uses its ordinary res.json(result) branch.
Failure: doesCategoryExist returns 404 when absent; its uncaught database rejection is converted by the service to 500. Lookup can also return the handler's 400, 404, or 500 errors.View complete source
findCategoriesRoute
Implementation
Endpoint: GET /categories
Access: Public.
Request: Optional description, name, parent, and status filters plus page and limit from the find schema. Pagination defaults to page 1 and limit 10.
Pipeline: withPagination(findCategories) → normalizeCategoriesListTerminator.
Success: 200 through the service's ordinary res.json(result) branch with { data, metadata: { pagination } }. data contains categories without _id; pagination includes page, limit, total, totalPages, hasNext, and hasPrev.
Failure: Database lookup failures return 500.View complete source
updateCategoryRoute
Implementation
Endpoint: PATCH /categories/:categoryId
Access: Administrator; validators execute isAuthenticated(), checkIdentityType(['admin']), then doesCategoryExist.
Request: categoryId, configured auth transport, and required application/json partial update body from the update schema.
Pipeline: updateCategory → getCategoryById → normalizeCategoryTerminator.
Success: 200 with the normalized category fetched after update; the service uses its ordinary res.json(result) branch.
Failure: Empty/missing body is 400; missing category is rejected as 404; unchanged update is 400; see shared access failures in validators.View complete source
deleteCategoryRoute
Implementation
Endpoint: DELETE /categories/:categoryId
Access: Administrator; isAuthenticated(), checkIdentityType(['admin']), then doesCategoryExist.
Request: categoryId and configured auth transport; the delete schema defines no body.
Pipeline: deleteCategory → deleteCategoryTerminator.
Success: empty 204 response.
Failure: Missing category is 404; deletion failures are 500; access failures are described in validators.View complete source
enableCategoryRoute
Implementation
Endpoint: POST /categories/:categoryId/enable
Access: Administrator; isAuthenticated(), checkIdentityType(['admin']), then doesCategoryExist.
Request: categoryId and configured auth transport; the enable schema defines no body.
Pipeline: enableCategory → enableCategoryTerminator.
Success: empty 204 response after status is set to 'active'.
Failure: Missing category is 404; a non-modifying update or database error is 500.View complete source
disableCategoryRoute
Implementation
Endpoint: POST /categories/:categoryId/disable
Access: Administrator; isAuthenticated(), checkIdentityType(['admin']), then doesCategoryExist.
Request: categoryId and configured auth transport; the disable schema defines no body.
Pipeline: disableCategory → disableCategoryTerminator.
Success: empty 204 response after status is set to 'inactive'.
Failure: Missing category is 404; a non-modifying update or database error is 500.View complete source