メインコンテンツまでスキップ
バージョン: 0.6.0 (Latest)

🚀 User Feature Blocks

User feature blocks provide complete, pre-composed functionality for user management operations in Nodeblocks applications. These features combine schemas, routes, and handlers to create ready-to-use API endpoints with proper validation, authentication, and error handling.


🎯 Overview

User feature blocks are designed to:

  • Provide complete API endpoints for user 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 user feature follows a consistent composition pattern:

  • Schema: Validates input data and parameters
  • Route: Provides HTTP endpoint with handlers
  • Composition: Combines schema and route using compose function

🔧 Available User Features

createUserFeature

Creates a new user account with validation and routing.

Purpose: Handles user registration with complete validation

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.createUserFeature, [{ dataStores: db }])));

API Endpoint: POST /api/users


getUserFeatures

Retrieves individual user data with access control.

Purpose: Fetches user profile data with proper authorization

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.getUserFeatures, [{ dataStores: db }])));

API Endpoint: GET /api/users/:profileId


findUsersFeatures

Searches and lists users with filtering and pagination.

Purpose: Provides user listing with search capabilities

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.findUsersFeatures, [{ dataStores: db }])));

API Endpoint: GET /api/users


editUserFeatures

Updates user profile data with validation and access control.

Purpose: Modifies user data with proper authorization

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.editUserFeatures, [{ dataStores: db }])));

API Endpoint: PATCH /api/users/:profileId


deleteUserFeatures

Deletes user accounts with proper authorization.

Purpose: Removes user accounts with access control

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.deleteUserFeatures, [{ dataStores: db }])));

API Endpoint: DELETE /api/users/:profileId


lockUserFeatures

Locks user accounts to prevent access (admin only).

Purpose: Disables user account access for security

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.lockUserFeatures, [{ dataStores: db }])));

API Endpoint: POST /api/identities/:identityId/lock


unlockUserFeatures

Unlocks user accounts to restore access (admin only).

Purpose: Enables user account access after locking

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With database configuration
app.use('/api', defService(partial(features.unlockUserFeatures, [{ dataStores: db }])));

API Endpoint: POST /api/identities/:identityId/unlock


getAvatarUploadUrlFeature

User avatar upload URL generation feature with schema validation and routing.

Purpose: Generates pre-signed URLs for secure avatar file uploads with automatic UUID filename generation

Composition:

Usage:

import { features } from '@nodeblocks/backend-sdk';


// With file storage service in configuration:
app.use('/api', defService(partial(features.getAvatarUploadUrlFeature, [{ configuration: { fileStorageDriver } }])));

API Endpoint: GET /api/user-profiles/:profileId/avatar-upload-url