📦 Order Feature Blocks
Order feature blocks provide complete, pre-composed functionality for order management operations in Nodeblocks applications. These features combine schemas, routes, and handlers to create ready-to-use API endpoints for order CRUD operations, search, and lifecycle management.
🎯 Overview
Order feature blocks are designed to:
- Provide complete order management with full CRUD operations
- Support order lifecycle management from creation to completion
- Include validation and routing for secure order operations
- Support filtering and pagination for order listings
- Handle order items and total calculations
📋 Feature Structure
Each order feature follows a consistent composition pattern:
- Schema: Validates order input data and parameters
- Route: Provides HTTP endpoint with order handlers
- Composition: Combines schema and route using
compose
function
🔧 Available Order Features
createOrderFeature
Order creation feature with schema validation and routing.
Purpose: Handles order creation with complete validation
Composition:
- Schema:
createOrderSchema
- validates items array, total, and optional fields - Route:
createOrderRoute
- POST/orders
with creation handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createOrderFeature, [{ dataStores: db }])));
API Endpoint: POST /api/orders
updateOrderFeature
Order update feature with schema validation and routing.
Purpose: Modifies order information with proper validation
Composition:
- Schema:
updateOrderSchema
- validates partial order properties - Route:
updateOrderRoute
- PUT/orders/:id
with update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.updateOrderFeature, [{ dataStores: db }])));
API Endpoint: PUT /api/orders/:orderId
getOrderFeature
Order retrieval feature for getting individual order data.
Purpose: Fetches order information with proper validation
Composition:
- Schema:
getOrderSchema
- validates path parameters - Route:
getOrderRoute
- GET/orders/:id
with retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getOrderFeature, [{ dataStores: db }])));
API Endpoint: GET /api/orders/:orderId
findOrdersFeature
Order search feature with filtering and pagination.
Purpose: Provides order listing with search capabilities
Composition:
- Schema:
findOrdersSchema
- validates query parameters for filtering - Route:
findOrdersRoute
- GET/orders
with search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findOrdersFeature, [{ dataStores: db }])));
API Endpoint: GET /api/orders
deleteOrderFeature
Order deletion feature with routing.
Purpose: Removes orders with access control and cleanup
Composition:
- Schema:
deleteOrderSchema
- validates path parameters - Route:
deleteOrderRoute
- DELETE/orders/:id
with deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteOrderFeature, [{ dataStores: db }])));
API Endpoint: DELETE /api/orders/:orderId