🚀 Identity Features
Identity features provide complete, pre-composed functionality for identity 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
Identity features are designed to:
- Provide complete API endpoints for identity 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
📋 Feature Structure
Each identity 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 Identity Features
getIdentityFeatures
Identity retrieval feature with schema validation and routing.
Purpose: Fetches identity data with proper authorization
Composition:
- Schema:
getIdentitySchema- validates identity ID parameter - Route:
getIdentityRoute- GET/identities/:identityIdwith retrieval handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.getIdentityFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/identities/:identityId
findIdentitiesFeatures
Identity listing feature with schema validation and routing.
Purpose: Provides identity listing with search capabilities
Composition:
- Schema:
findIdentitySchema- validates query parameters for filtering - Route:
findIdentitiesRoute- GET/identitieswith search and pagination
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.findIdentitiesFeatures, [{ dataStores: db }])));
API Endpoint: GET /api/identities
updateIdentityFeatures
Identity update feature with schema validation and routing.
Purpose: Modifies identity data with proper authorization
Composition:
- Schema:
updateIdentitySchema- validates identity update data - Route:
updateIdentityRoute- PATCH/identities/:identityIdwith update handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.updateIdentityFeatures, [{ dataStores: db }])));
API Endpoint: PATCH /api/identities/:identityId
deleteIdentityFeatures
Identity deletion feature with schema validation and routing.
Purpose: Removes identities with access control
Composition:
- Schema:
deleteIdentitySchema- validates identity ID parameter - Route:
deleteIdentityRoute- DELETE/identities/:identityIdwith deletion handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.deleteIdentityFeatures, [{ dataStores: db }])));
API Endpoint: DELETE /api/identities/:identityId
lockIdentityFeature
Identity locking feature with schema validation and routing.
Purpose: Locks identities for security purposes with proper authorization.
Composition:
- Schema:
lockIdentitySchema- validates identity ID parameter - Route:
lockIdentityRoute- POST/identities/:identityId/lockwith locking handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.lockIdentityFeature, [{ dataStores: db }])));
API Endpoint: POST /api/identities/:identityId/lock
Response (204 No Content):
{}
Key Features:
- Authorization Control: Restricts access to admin users
- Atomic Operations: Uses MongoDB atomic update operations
- Error Handling: Comprehensive error handling for validation and database failures
Authorization:
- Requires authentication
- Accessible only by admin users
Error Responses:
401: Unauthorized - Invalid or missing authentication403: Forbidden - User lacks admin privileges404: Not Found - Identity does not exist500: Internal Server Error - Database operation failed
unlockIdentityFeature
Identity unlocking feature with schema validation and routing.
Purpose: Unlocks previously locked identities with proper authorization.
Composition:
- Schema:
unlockIdentitySchema- validates identity ID parameter - Route:
unlockIdentityRoute- POST/identities/:identityId/unlockwith unlocking handler
Usage:
import { features } from '@nodeblocks/backend-sdk';
// With database configuration
app.use('/api', defService(partial(features.unlockIdentityFeature, [{ dataStores: db }])));
API Endpoint: POST /api/identities/:identityId/unlock
Response (204 No Content):
{}
Key Features:
- Authorization Control: Restricts access to admin users
- Atomic Operations: Uses MongoDB atomic update operations
- Error Handling: Comprehensive error handling for validation and database failures
Authorization:
- Requires authentication
- Accessible only by admin users
Error Responses:
401: Unauthorized - Invalid or missing authentication403: Forbidden - User lacks admin privileges404: Not Found - Identity does not exist500: Internal Server Error - Database operation failed
🔗 Related Documentation
- Identity Schemas - Identity data validation and contracts
- Identity Blocks - Identity business logic functions
- Identity Routes - HTTP endpoint definitions