👤 User Blocks
User blocks provide comprehensive functionality for user management in Nodeblocks applications. These blocks handle user lifecycle operations including creation, authentication, profile management, and account administration.
🎯 Overview
User blocks are designed to:
- Manage user accounts with full CRUD operations
- Handle authentication and authorization flows
- Provide profile management with validation
- Enable user administration with role-based access
📦 Block Types
🔍 Schemas
JSON Schema definitions for user data validation:
- userSchema: Base user entity structure
- createUserSchema: User registration validation
- updateUserSchema: Profile update validation
- getUserSchema: User retrieval validation
- deleteUserSchema: User deletion validation
- findUsersSchema: User search with filtering and pagination
🔧 Blocks
Pure business logic functions for user profile operations:
- getUserById: Profile retrieval from datastore
- findProfiles: Profile search with filtering and pagination
- normalizeUser: Normalize single user object
- normalizeUsers: Normalize array of user objects
- deleteAvatar: Delete user avatar files from storage
⚙️ Handlers
Core business logic for user operations:
- createUser: User account creation
- getUserById: User data retrieval
- findUsers: User search with optional filtering
- updateUser: Profile updates
- deleteUser: Account deletion
Terminator Handlers:
- normalizeUserTerminator: Normalizes user data by removing database-specific fields
- normalizeUsersListTerminator: Normalizes users list by removing database-specific fields from each item
- deleteUserTerminator: Formats successful deletion response with 204 status
🛣️ Routes
HTTP endpoint definitions for user operations:
- createUserRoute: POST
/userswith user creation handler - getUserRoute: GET
/users/:profileIdwith user retrieval handler - findUsersRoute: GET
/userswith user search and pagination - findProfilesByIdentityIdRoute: GET
/profiles/identities/:identityIdwith profile retrieval and avatar processing - updateUserRoute: PATCH
/users/:profileIdwith user update handler - deleteUserRoute: DELETE
/users/:profileIdwith user deletion handler - getAvatarUploadUrlRoute: GET
/user-profiles/:profileId/avatar-upload-urlwith signed URL generation
🚀 Features
Complete user management features combining schemas, routes, and handlers:
- createUserFeature: User registration with validation
- getUserFeatures: User profile retrieval with access control
- findUsersFeatures: User search and listing with pagination
- findProfilesByIdentityIdFeature: User profile retrieval by identity ID with avatar processing
- editUserFeatures: User profile updates with authorization
- deleteUserFeatures: User account deletion with access control
- getAvatarUploadUrlFeature: Avatar upload URL generation
✅ Validators
Validation functions for user operations:
- ownsProfile: Validates profile ownership by the authenticated identity
- validateUserProfileAccess (deprecated): Legacy access validator; replaced by
ownsProfile
🔗 Related Documentation
- User Schemas - User data validation and contracts
- User Handlers - User business logic functions
- User Routes - HTTP endpoint definitions
- User Features - Complete user management features
- User Validators - User validation functions