🏷️ Attribute Route Blocks
Attribute route blocks provide pre-configured HTTP endpoints for attribute group management operations in Nodeblocks applications. These routes combine handlers, validators, and middleware to create complete API endpoints with proper authentication, authorization, and error handling.
🎯 Overview
Attribute route blocks are designed to:
- Provide complete API endpoints for attribute group management operations
- Combine handlers with validators for secure operations
- Include authentication and authorization checks
- Support functional composition patterns
- Handle logging and error management automatically
📋 Route Structure
Each attribute route follows a consistent pattern:
- HTTP Method: Defines the operation type (GET, POST, PATCH, DELETE)
- Path: Specifies the endpoint URL with parameters
- Handler: Composed function chain for business logic
- Validators: Authentication and authorization checks
🔧 Available Attribute Routes
createAttributeRoute
Creates a new attribute group and returns the created resource.
Purpose: Handles attribute group creation
Route Details:
- Method:
POST
- Path:
/attributes
- Authentication: Required (Bearer token)
Handlers: createAttributeGroup
, getAttributeGroupById
, createAttributeGroupTerminator
Validators: verifyAuthentication
(getBearerTokenInfo), validateResourceAccess
(['admin'], getBearerTokenInfo)
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.createAttributeRoute);
findAttributesRoute
Retrieves all attribute groups with normalized list format.
Purpose: Lists attribute groups with pagination
Route Details:
- Method:
GET
- Path:
/attributes
- Authentication: Not required
Handlers: findAttributeGroups
, normalizeAttributesListTerminator
Validators: None
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.findAttributesRoute);
getAttributeRoute
Retrieves a specific attribute group by ID.
Purpose: Fetches attribute group data
Route Details:
- Method:
GET
- Path:
/attributes/:attributeId
- Authentication: Not required
Handlers: getAttributeGroupById
, normalizeAttributeGroupTerminator
Validators: None
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.getAttributeRoute);
updateAttributeRoute
Updates an existing attribute group and returns the updated resource.
Purpose: Modifies attribute group data
Route Details:
- Method:
PATCH
- Path:
/attributes/:attributeId
- Authentication: Required (Bearer token)
Handlers: updateAttributeGroup
, getAttributeGroupById
, normalizeAttributeGroupTerminator
Validators: verifyAuthentication
(getBearerTokenInfo), validateResourceAccess
(['admin'], getBearerTokenInfo)
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.updateAttributeRoute);
deleteAttributeRoute
Deletes an attribute group by ID.
Purpose: Removes attribute group
Route Details:
- Method:
DELETE
- Path:
/attributes/:attributeId
- Authentication: Required (Bearer token)
Handlers: deleteAttributeGroup
, deleteAttributeTerminator
Validators: verifyAuthentication
(getBearerTokenInfo), validateResourceAccess
(['admin'], getBearerTokenInfo)
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteAttributeRoute);