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

🚀 Chat Feature Blocks

Chat feature blocks provide complete, pre-composed functionality for chat 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

Chat feature blocks are designed to:

  • Provide complete API endpoints for chat 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

This documentation is organized into three main subsections:

  • 📺 Channel Features: Manage chat channels (create, read, update, delete, search)
  • 💬 Message Features: Handle chat messages (create, read, update, delete, search)
  • 🔔 Subscription Features: Manage user subscriptions to channels (create, read, delete, search)

📋 Feature Structure

Each chat 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 Chat Features

📺 Channel Features

createChannelFeature

Creates a new chat channel with validation and routing.

Purpose: Handles channel creation with complete validation

Composition:

Usage:

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


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

API Endpoint: POST /api/channels


getChannelFeature

Retrieves individual channel data with access control.

Purpose: Fetches channel details with proper authorization

Composition:

Usage:

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


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

API Endpoint: GET /api/channels/:channelId


findChannelsFeature

Searches and lists channels with filtering and pagination.

Purpose: Provides channel listing with search capabilities

Composition:

Usage:

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


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

API Endpoint: GET /api/channels


updateChannelFeature

Updates channel information with validation and access control.

Purpose: Modifies channel data with proper authorization

Composition:

Usage:

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


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

API Endpoint: PATCH /api/channels/:channelId


deleteChannelFeature

Deletes channels with proper authorization.

Purpose: Removes channels with access control

Composition:

Usage:

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


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

API Endpoint: DELETE /api/channels/:channelId


💬 Message Features

createChatMessageFeature

Creates a new chat message with validation and routing.

Purpose: Handles message creation with complete validation

Composition:

Usage:

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


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

API Endpoint: POST /api/messages


getChatMessageFeature

Retrieves individual message data with access control.

Purpose: Fetches message details with proper authorization

Composition:

Usage:

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


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

API Endpoint: GET /api/messages/:messageId


findChatMessagesFeature

Searches and lists messages with filtering and pagination.

Purpose: Provides message listing with search capabilities

Composition:

Usage:

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


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

API Endpoint: GET /api/messages


updateChatMessageFeature

Updates message content with validation and access control.

Purpose: Modifies message data with proper authorization

Composition:

Usage:

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


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

API Endpoint: PATCH /api/messages/:messageId


deleteChatMessageFeature

Deletes messages with proper authorization.

Purpose: Removes messages with access control

Composition:

Usage:

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


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

API Endpoint: DELETE /api/messages/:messageId


🧩 Message Template Features

createChatMessageTemplateFeature

Creates a new chat message template with validation and routing.

Purpose: Handles creation of reusable message templates

Composition:

Usage:

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

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

API Endpoint: POST /api/message-templates


getChatMessageTemplateFeature

Retrieves a chat message template by ID with access control.

Purpose: Fetches template data securely

Composition:

Usage:

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

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

API Endpoint: GET /api/message-templates/:messageTemplateId

🔔 Subscription Features

createChatSubscriptionFeature

Creates a new chat subscription with validation and routing.

Purpose: Handles subscription creation with complete validation

Composition:

Usage:

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


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

API Endpoint: POST /api/subscriptions


getChatSubscriptionFeature

Retrieves individual subscription data with access control.

Purpose: Fetches subscription details with proper authorization

Composition:

Usage:

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


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

API Endpoint: GET /api/subscriptions/:subscriptionId


findChatSubscriptionsFeature

Searches and lists subscriptions with filtering and pagination.

Purpose: Provides subscription listing with search capabilities

Composition:

Usage:

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


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

API Endpoint: GET /api/subscriptions


deleteChatSubscriptionFeature

Deletes subscriptions with proper authorization.

Purpose: Removes subscriptions with access control

Composition:

Usage:

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


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

API Endpoint: DELETE /api/subscriptions/:subscriptionId