Skip to main content
Version: 0.14.0 (Latest)

🛣️ 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

RouteMethod / protocolPathSchemaValidatorsSuccess status
createCategoryRoutePOST / HTTP/categoriescreateCategorySchemaisAuthenticated(), checkIdentityType(['admin'])200
getCategoryRouteGET / HTTP/categories/:categoryIdgetCategorySchemadoesCategoryExist200
findCategoriesRouteGET / HTTP/categoriesfindCategoriesSchemaNone200
updateCategoryRoutePATCH / HTTP/categories/:categoryIdupdateCategorySchemaisAuthenticated(), checkIdentityType(['admin']), doesCategoryExist200
deleteCategoryRouteDELETE / HTTP/categories/:categoryIddeleteCategorySchemaisAuthenticated(), checkIdentityType(['admin']), doesCategoryExist204
enableCategoryRoutePOST / HTTP/categories/:categoryId/enableenableCategorySchemaisAuthenticated(), checkIdentityType(['admin']), doesCategoryExist204
disableCategoryRoutePOST / HTTP/categories/:categoryId/disabledisableCategorySchemaisAuthenticated(), checkIdentityType(['admin']), doesCategoryExist204

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: createCategorygetCategoryByIdnormalizeCategoryTerminator.

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
export const createCategoryRoute = withRoute({
handler: compose(
withLogging(createCategory),
flatMapAsync(withLogging(getCategoryById)),
lift(withLogging(normalizeCategoryTerminator))
),
method: 'POST',
path: '/categories',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

getCategoryRoute

Implementation

Endpoint: GET /categories/:categoryId

Access: Public; direct doesCategoryExist runs first.

Request: Required string categoryId path value in the get schema.

Pipeline: getCategoryByIdnormalizeCategoryTerminator.

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
export const getCategoryRoute = withRoute({
handler: compose(
withLogging(getCategoryById),
lift(withLogging(normalizeCategoryTerminator))
),
method: 'GET',
path: '/categories/:categoryId',
validators: [doesCategoryExist],
});

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
export const findCategoriesRoute = withRoute({
handler: compose(
withPagination(withLogging(findCategories)),
lift(withLogging(normalizeCategoriesListTerminator))
),
method: 'GET',
path: '/categories',
validators: [],
});

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: updateCategorygetCategoryByIdnormalizeCategoryTerminator.

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
export const updateCategoryRoute = withRoute({
handler: compose(
withLogging(updateCategory),
flatMapAsync(withLogging(getCategoryById)),
lift(withLogging(normalizeCategoryTerminator))
),
method: 'PATCH',
path: '/categories/:categoryId',
validators: [
isAuthenticated(),
checkIdentityType(['admin']),
doesCategoryExist,
],
});

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: deleteCategorydeleteCategoryTerminator.

Success: empty 204 response.

Failure: Missing category is 404; deletion failures are 500; access failures are described in validators.

View complete source
export const deleteCategoryRoute = withRoute({
handler: compose(
withLogging(deleteCategory),
lift(withLogging(deleteCategoryTerminator))
),
method: 'DELETE',
path: '/categories/:categoryId',
validators: [
isAuthenticated(),
checkIdentityType(['admin']),
doesCategoryExist,
],
});

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: enableCategoryenableCategoryTerminator.

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
export const enableCategoryRoute = withRoute({
handler: compose(
withLogging(enableCategory),
lift(withLogging(enableCategoryTerminator))
),
method: 'POST',
path: '/categories/:categoryId/enable',
validators: [
isAuthenticated(),
checkIdentityType(['admin']),
doesCategoryExist,
],
});

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: disableCategorydisableCategoryTerminator.

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
export const disableCategoryRoute = withRoute({
handler: compose(
withLogging(disableCategory),
lift(withLogging(disableCategoryTerminator))
),
method: 'POST',
path: '/categories/:categoryId/disable',
validators: [
isAuthenticated(),
checkIdentityType(['admin']),
doesCategoryExist,
],
});