🚀 Location Features
Location features provide complete, pre-composed functionality for location 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
Location features are designed to:
- Provide complete API endpoints for location management operations
- Combine schemas with routes for validated operations
- Include authentication and authorization checks automatically
- Support functional composition patterns
- Handle logging and error management seamlessly
- Support hierarchical relationships with parent-child and ancestor tracking
📋 Feature Structure
Each location feature follows a consistent composition pattern:
- Schema: Validates input data and parameters
- Route: Provides HTTP endpoint with blocks
- Composition: Combines schema and route using
composefunction
🔧 Available Location Features
createLocationFeature
Location creation feature with schema validation and hierarchical routing.
Purpose: Provides complete location creation functionality with automatic hierarchical relationship management, validation, and proper error handling.
Composition:
- Schema:
createLocationSchema- validates location creation request data with required fields and hierarchical parent support - Route:
createLocationRoute- POST/locationswith hierarchical parent support and ancestor building
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.createLocationFeature, [{ dataStores: db }])));
API Endpoint: POST /api/locations
getLocationFeature
Location retrieval feature with schema validation and public routing.
Purpose: Provides location retrieval functionality with proper validation and error handling for public access to location data.
Composition:
- Schema:
getLocationSchema- validates locationId path parameter for location retrieval - Route:
getLocationRoute- GET/locations/:locationIdwith public access and location lookup
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getLocationFeature, [{ dataStores: db }])));
API Endpoint: GET /api/locations/:locationId
updateLocationFeature
Location update feature with schema validation and admin routing.
Purpose: Provides location update functionality with partial field modifications, proper validation, and admin-only access control.
Composition:
- Schema:
updateLocationSchema- validates optional location fields for partial updates and locationId path parameter - Route:
updateLocationRoute- PATCH/locations/:locationIdwith admin authentication and update handling
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.updateLocationFeature, [{ dataStores: db }])));
API Endpoint: PATCH /api/locations/:locationId
deleteLocationFeature
Location deletion feature with schema validation and hierarchy validation routing.
Purpose: Provides location deletion functionality with comprehensive hierarchy validation to prevent orphaned child locations and ensure data integrity.
Composition:
- Schema:
deleteLocationSchema- validates locationId path parameter for deletion requests - Route:
deleteLocationRoute- DELETE/locations/:locationIdwith hierarchy validation and admin authentication
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteLocationFeature, [{ dataStores: db }])));
API Endpoint: DELETE /api/locations/:locationId
findLocationsFeature
Location search feature with schema validation and pagination routing.
Purpose: Provides location search and listing functionality with pagination support, enabling efficient browsing and discovery of location data through public access.
Composition:
- Schema:
findLocationsSchema- validates pagination query parameters for location search requests - Route:
findLocationsRoute- GET/locationswith pagination support and public access
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findLocationsFeature, [{ dataStores: db }])));
API Endpoint: GET /api/locations
🔗 Related Documentation
- Location Schemas - Location data validation and contracts
- Location Blocks - Location business logic functions
- Location Routes - HTTP endpoint definitions