Skip to main content
Version: 0.14.0 (Latest)

🛣️ Attribute routes

Attribute routes are SDK composers, not Express middleware. Public reads need no authentication; mutations require an authenticated administrator.

Inventory

RouteMethod / protocolPathSchemaValidatorsSuccess status
createAttributeRoutePOST / HTTP/attributescreateAttributesSchemaisAuthenticated(), checkIdentityType(['admin'])201
findAttributesRouteGET / HTTP/attributesfindAttributesSchemaNone200
getAttributeRouteGET / HTTP/attributes/:attributeIdgetAttributeSchemaNone200
updateAttributeRoutePATCH / HTTP/attributes/:attributeIdupdateAttributesSchemaisAuthenticated(), checkIdentityType(['admin'])200
deleteAttributeRouteDELETE / HTTP/attributes/:attributeIddeleteAttributeSchemaisAuthenticated(), checkIdentityType(['admin'])204

Details

createAttributeRoute

Implementation

Endpoint: POST /attributes

Access: Authenticated administrator: isAuthenticated() then checkIdentityType(['admin']).

Request: Required JSON create body.

Pipeline: createAttributeGroupgetAttributeGroupByIdcreateAttributeGroupTerminator.

Success: 201 and the created group without MongoDB _id.

Failure: Missing/empty body or missing insert result is 400; a failed post-create lookup/terminator is 404; thrown persistence work is 500. Authentication and administrator validation run first.

View complete source
export const createAttributeRoute = withRoute({
handler: compose(
withLogging(createAttributeGroup),
flatMapAsync(withLogging(getAttributeGroupById)),
lift(withLogging(createAttributeGroupTerminator))
),
method: 'POST',
path: '/attributes',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

findAttributesRoute

Implementation

Endpoint: GET /attributes

Access: Public.

Request: Optional name and pagination query.

Pipeline: findAttributeGroups through withPaginationnormalizeAttributesListTerminator.

Success: 200; returns normalized groups, or { data, metadata: { pagination } } when pagination supplies a paginated result.

Failure: Query/database failure or an unexpected list result shape is 500.

View complete source
export const findAttributesRoute = withRoute({
handler: compose(
withPagination(withLogging(findAttributeGroups)),
lift(withLogging(normalizeAttributesListTerminator))
),
method: 'GET',
path: '/attributes',
validators: [],
});

getAttributeRoute

Implementation

Endpoint: GET /attributes/:attributeId

Access: Public.

Request: Required string attributeId path parameter.

Pipeline: getAttributeGroupByIdnormalizeAttributeGroupTerminator.

Success: 200 and the group without MongoDB _id.

Failure: A missing ID is 400, a missing group is 404, and a thrown query is 500.

View complete source
export const getAttributeRoute = withRoute({
handler: compose(
withLogging(getAttributeGroupById),
lift(withLogging(normalizeAttributeGroupTerminator))
),
method: 'GET',
path: '/attributes/:attributeId',
validators: [],
});

updateAttributeRoute

Implementation

Endpoint: PATCH /attributes/:attributeId

Access: Authenticated administrator: isAuthenticated() then checkIdentityType(['admin']).

Request: Required path/body contract. Only name is schema-supported; the handler also rejects {}.

Pipeline: updateAttributeGroupgetAttributeGroupByIdnormalizeAttributeGroupTerminator.

Success: 200 and the reloaded normalized group.

Failure: Missing ID/body or an unchanged update is 400; a missing group is 404; a thrown update/reload is 500. Authentication and administrator validation run first.

View complete source
export const updateAttributeRoute = withRoute({
handler: compose(
withLogging(updateAttributeGroup),
flatMapAsync(withLogging(getAttributeGroupById)),
lift(withLogging(normalizeAttributeGroupTerminator))
),
method: 'PATCH',
path: '/attributes/:attributeId',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});

deleteAttributeRoute

Implementation

Endpoint: DELETE /attributes/:attributeId

Access: Authenticated administrator: isAuthenticated() then checkIdentityType(['admin']).

Request: Required string attributeId path parameter.

Pipeline: deleteAttributeGroupdeleteAttributeTerminator.

Success: 204 with no response data.

Failure: A missing ID is 400, no matching group is 404, and a false/thrown deletion or missing terminator flag is 500. Authentication and administrator validation run first.

View complete source
export const deleteAttributeRoute = withRoute({
handler: compose(
withLogging(deleteAttributeGroup),
lift(withLogging(deleteAttributeTerminator))
),
method: 'DELETE',
path: '/attributes/:attributeId',
validators: [isAuthenticated(), checkIdentityType(['admin'])],
});