🚀 Attribute Feature Blocks
Attribute feature blocks provide complete, pre-composed functionality for attribute group management operations in Nodeblocks applications. These features combine schemas and routes to create ready-to-use API endpoints with proper validation, authentication, and error handling.
🎯 Overview
Attribute feature blocks are designed to:
- Provide complete API endpoints for attribute group management operations
- Combine schemas with routes for validated operations
- Include authentication and authorization checks (for mutating operations)
- Support functional composition patterns
- Handle logging and error management seamlessly
📋 Feature Structure
Each attribute feature follows a consistent composition pattern:
- Schema: Validates input data and parameters
- Route: Provides HTTP endpoint with handlers
- Composition: Combines schema and route using
compose
function
🔧 Available Attribute Features
createAttributeFeature
Creates a new attribute set with validation and routing.
Purpose: Handles attribute group creation with complete validation
Composition:
- Schema:
createAttributesSchema
- validates name and items array - Route:
createAttributeRoute
- POST/attributes
with creation handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createAttributeFeature, [{ dataStores: db }])));
API Endpoint: POST /api/attributes
(auth: Bearer, admin)
getAttributeFeature
Retrieves individual attribute set data with access control.
Purpose: Fetches attribute group data
Composition:
- Schema:
getAttributeSchema
- validates path parameters - Route:
getAttributeRoute
- GET/attributes/:attributeId
with retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getAttributeFeature, [{ dataStores: db }])));
API Endpoint: GET /api/attributes/:attributeId
findAttributesFeature
Searches and lists attribute sets with filtering and pagination.
Purpose: Provides attribute group listing with search and pagination
Composition:
- Schema:
findAttributesSchema
- validates query parameters for filtering - Route:
findAttributesRoute
- GET/attributes
with search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findAttributesFeature, [{ dataStores: db }])));
API Endpoint: GET /api/attributes
updateAttributeFeature
Updates attribute set data with validation and access control.
Purpose: Modifies attribute group data (auth required)
Composition:
- Schema:
updateAttributesSchema
- validates optional name field - Route:
updateAttributeRoute
- PATCH/attributes/:attributeId
with update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.updateAttributeFeature, [{ dataStores: db }])));
API Endpoint: PATCH /api/attributes/:attributeId
(auth: Bearer, admin)
deleteAttributeFeature
Deletes attribute sets with proper authorization.
Purpose: Removes attribute groups (auth required)
Composition:
- Schema:
deleteAttributeSchema
- validates path parameters - Route:
deleteAttributeRoute
- DELETE/attributes/:attributeId
with deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteAttributeFeature, [{ dataStores: db }])));
API Endpoint: DELETE /api/attributes/:attributeId
(auth: Bearer, admin)