メインコンテンツまでスキップ
バージョン: 🚧 Canary

🚀 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 compose function

🔧 Available Identity Features

getIdentityFeatures

Identity retrieval feature with schema validation and routing.

Purpose: Fetches identity data with proper authorization

Composition:

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:

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:

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:

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:

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 authentication
  • 403: Forbidden - User lacks admin privileges
  • 404: Not Found - Identity does not exist
  • 500: Internal Server Error - Database operation failed

unlockIdentityFeature

Identity unlocking feature with schema validation and routing.

Purpose: Unlocks previously locked identities with proper authorization.

Composition:

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 authentication
  • 403: Forbidden - User lacks admin privileges
  • 404: Not Found - Identity does not exist
  • 500: Internal Server Error - Database operation failed