📦 Product Feature Blocks
Product feature blocks provide complete, pre-composed functionality for product management operations in Nodeblocks applications. These features combine schemas, routes, and handlers to create ready-to-use API endpoints for product CRUD operations, batch operations, and product copying.
🎯 Overview
Product feature blocks are designed to:
- Provide complete product management with full CRUD operations
- Support batch operations for efficient bulk product handling
- Include validation and routing for secure product operations
- Support filtering and pagination for product listings
- Handle product copying and duplication workflows
📋 Feature Structure
Each product feature follows a consistent composition pattern:
- Schema: Validates product input data and parameters
- Route: Provides HTTP endpoint with product handlers
- Composition: Combines schema and route using
compose
function
🔧 Available Product Features
createProductFeature
Product creation feature with schema validation and routing.
Purpose: Handles product creation with complete validation
Composition:
- Schema:
createProductSchema
- validates name and description - Route:
createProductRoute
- POST/products
with creation handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createProductFeature, [{ dataStores: db }])));
API Endpoint: POST /api/products
createProductBatchFeature
Batch product creation feature with schema validation and routing.
Purpose: Handles batch product creation with validation
Composition:
- Schema:
createProductBatchSchema
- validates array of product objects - Route:
createProductBatchRoute
- POST/products/batch
with batch creation handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createProductBatchFeature, [{ dataStores: db }])));
API Endpoint: POST /api/products/batch
getProductFeatures
Product retrieval feature for getting individual product data.
Purpose: Fetches product information with proper validation
Composition:
- Schema:
getProductSchema
- validates path parameters - Route:
getProductRoute
- GET/products/:id
with retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getProductFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/products/:productId
findProductsFeatures
Product search feature with filtering and pagination.
Purpose: Provides product listing with search capabilities
Composition:
- Schema:
findProductsSchema
- validates query parameters for filtering - Route:
findProductsRoute
- GET/products
with search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findProductsFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/products
editProductFeatures
Product update feature with schema validation and routing.
Purpose: Modifies product information with proper validation
Composition:
- Schema:
updateProductSchema
- validates optional name and description - Route:
updateProductRoute
- PUT/products/:id
with update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.editProductFeatures, [{ dataStores: db }])));
API Endpoint: PUT /api/products/:productId
editProductBatchFeatures
Batch product update feature with schema validation and routing.
Purpose: Handles batch product updates with validation
Composition:
- Schema:
updateProductBatchSchema
- validates ids array and data object - Route:
updateProductBatchRoute
- PUT/products/batch
with batch update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.editProductBatchFeatures, [{ dataStores: db }])));
API Endpoint: PUT /api/products/batch
deleteProductFeatures
Product deletion feature with routing.
Purpose: Removes products with access control and cleanup
Composition:
- Schema:
deleteProductSchema
- validates path parameters - Route:
deleteProductRoute
- DELETE/products/:id
with deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteProductFeatures, [{ dataStores: db }])));
API Endpoint: DELETE /api/products/:productId
deleteProductBatchFeatures
Batch product deletion feature with schema validation and routing.
Purpose: Handles batch product deletion with validation
Composition:
- Schema:
deleteProductBatchSchema
- validates array of string IDs - Route:
deleteProductBatchRoute
- DELETE/products/batch
with batch deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteProductBatchFeatures, [{ dataStores: db }])));
API Endpoint: DELETE /api/products/batch
copyProductFeatures
Product copying feature with routing.
Purpose: Creates product copies with proper duplication
Composition:
- Schema:
copyProductSchema
- validates path parameters - Route:
copyProductRoute
- POST/products/:id/copy
with copy handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.copyProductFeatures, [{ dataStores: db }])));
API Endpoint: POST /api/products/:productId/copy
copyProductBatchFeatures
Batch product copying feature with schema validation and routing.
Purpose: Handles batch product copying with validation
Composition:
- Schema:
copyProductBatchSchema
- validates array of string IDs - Route:
copyProductBatchRoute
- POST/products/batch/copy
with batch copy handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.copyProductBatchFeatures, [{ dataStores: db }])));
API Endpoint: POST /api/products/batch/copy