🏷️ Attribute Route Blocks
Attribute route blocks provide pre-configured HTTP endpoints for attribute group management in Nodeblocks applications. These routes combine handlers, validators, logging, and pagination to create complete API endpoints with proper authentication, authorization, and error handling where applicable.
🎯 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 on mutating endpoints
- Support functional composition patterns
- Handle logging and error management automatically
- Support pagination for lists
📋 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, admin)
Handlers: with logging and composition — createAttributeGroup
→ getAttributeGroupById
→ createAttributeGroupTerminator
Validators: isAuthenticated()
, checkIdentityType(['admin'])
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: with pagination and logging — findAttributeGroups
→ normalizeAttributesListTerminator
Validators: None
Query Parameters
name?: string
— optional filter by namepage?: number
— pagination (1–1000)limit?: number
— pagination (1–50)
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: with logging — 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, admin)
Handlers: with logging — updateAttributeGroup
→ getAttributeGroupById
→ normalizeAttributeGroupTerminator
Validators: isAuthenticated()
, checkIdentityType(['admin'])
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, admin)
Handlers: with logging — deleteAttributeGroup
→ deleteAttributeTerminator
Validators: isAuthenticated()
, checkIdentityType(['admin'])
Usage:
import { routes } from '@nodeblocks/backend-sdk';
// Register route with Express app
app.use('/api', routes.deleteAttributeRoute);