🔍 Chat Schemas
Chat schemas provide JSON Schema definitions for chat data validation in Nodeblocks applications. These schemas ensure data integrity and provide clear contracts for chat-related API endpoints.
🎯 Overview
Chat schemas are designed to:
- Validate chat data before processing
- Support real-time messaging between users
- Handle channel management and user subscriptions
- Enable message search and filtering capabilities
- Provide channel permissions and access control
- Support real-time notifications and updates
📋 Chat Schema Types
ChatChannelIcon
TypeScript type for chat channel icon metadata.
Purpose: Defines the structure for channel icon file information stored in the database.
Type Definition:
type ChatChannelIcon = {
objectId: string; // Unique identifier for the file in storage
type: string; // MIME type of the icon file (e.g., 'image/png')
}
Usage:
import { ChatChannelIcon } from '@nodeblocks/backend-sdk';
const channelIcon: ChatChannelIcon = {
objectId: 'icon-uuid-123',
type: 'image/png'
};
Channel Schemas
Core chat channel structures for channel management.
Message Schemas
Chat message structures for real-time communication.
Subscription Schemas
User subscription structures for channel access control.
🔧 Available Chat Schemas
📺 Channel Schemas
chatChannelSchema
Base chat channel schema with core channel fields.
Purpose: Defines basic channel structure for chat functionality
Schema Details:
- Type:
object - Required Fields: None (base schema)
- Additional Properties:
false(strict validation) - Properties:
name?: string- Channel nameownerId?: string- Channel owner identity IDicon?: ChatChannelIcon | null- Channel icon file metadata (objectId and type) or null
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatChannelSchema } = schemas;
const validate = ajv.compile(chatChannelSchema as SchemaDefinition);
const isValid = validate({
name: 'General Chat',
ownerId: 'identity123'
});
createChatChannelSchema
Chat channel creation schema with required name and owner.
Purpose: Validates channel data during creation
Schema Details:
- Type:
object - Required Fields:
name,ownerId - Optional Fields:
icon - Additional Properties:
false(strict validation) - Content-Type:
application/json - Request Body:
required
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatChannelSchema } = schemas;
const schema = createChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
name: 'General Chat',
ownerId: 'user123'
});
updateChatChannelSchema
Chat channel update schema with optional fields for channel modifications.
Purpose: Validates partial channel data updates
Schema Details:
- Type:
object - Required Fields: None (all fields optional)
- Additional Properties:
false(strict validation) - Content-Type:
application/json - Parameters:
channelId(path parameter) - Request Body:
required - Optional Properties:
name?: string- Updated channel nameicon?: ChatChannelIcon | null- Updated channel icon or null to remove icon
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatChannelSchema } = schemas;
const schema = updateChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ name: 'Updated Channel Name' });
getChatChannelSchema
Chat channel retrieval schema for getting single channels.
Purpose: Validates requests for retrieving specific chat channels
Schema Details:
- Parameters:
channelId(path parameter) - Purpose: Validates requests for retrieving specific chat channels
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatChannelSchema } = schemas;
const schema = getChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ channelId: 'channel123' });
deleteChatChannelSchema
Chat channel deletion schema for removing channels.
Purpose: Validates requests for deleting specific chat channels
Schema Details:
- Parameters:
channelId(path parameter) - Purpose: Validates requests for deleting specific chat channels
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatChannelSchema } = schemas;
const schema = deleteChatChannelSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ channelId: 'channel123' });
findChatChannelsSchema
Chat channels search schema for finding channels with filtering and pagination.
Purpose: Validates requests for searching and paginating chat channels
Schema Details:
- Query Parameters:
name?: string- Filter by channel nameownerId?: string- Filter by owner identitypage?: number- Pagination page numberlimit?: number- Pagination limit
- Purpose: Validates requests for searching and paginating chat channels
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatChannelsSchema } = schemas;
const schema = findChatChannelsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ name: 'General', page: 1, limit: 10 });
getChannelMessagesSchema
Channel messages retrieval schema with path parameter validation.
Purpose: Validates GET requests for retrieving all messages in a specific channel
Schema Structure:
{
channelId: string; // required - channel identifier from URL path
}
Schema Details:
- Parameters:
channelId(path parameter, required) - Purpose: Validates channel ID presence in path for message retrieval
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChannelMessagesSchema } = schemas;
// Apply to feature composition:
export const getChannelMessagesFeature = compose(
getChannelMessagesSchema,
getChannelMessagesRoute
);
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Channel identifier |
💬 Message Schemas
chatMessageSchema
Base chat message schema with core message fields.
Purpose: Defines basic message structure for chat functionality
Schema Details:
- Type:
object - Required Fields: None (base schema)
- Additional Properties:
false(strict validation) - Properties:
content?: string- Message contentsenderId?: string- Message sender identity IDtitle?: string- Message title
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatMessageSchema } = schemas;
const validate = ajv.compile(chatMessageSchema as SchemaDefinition);
const isValid = validate({
content: 'Hello world!',
senderId: 'identity123',
title: 'Greeting'
});
chatMessageAttachmentSchema
Chat message attachment schema with file reference and type validation.
Purpose: Validates individual attachment objects in chat messages
Schema Details:
- Type:
object - Required Fields:
objectId(UUID format),type(string) - Additional Properties:
false(strict validation)
Properties:
objectId: string- UUID reference to the attached file in storagetype: string- MIME type or file category
TypeScript Types:
type ChatMessageAttachment = {
objectId: string;
type: string;
};
type NormalizedChatMessageAttachment = {
url: string; // Signed URL after normalization
type: string;
};
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const attachment: ChatMessageAttachment = {
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
};
createChatMessageAttachmentSchema
Chat message attachment creation schema with required file reference and type validation.
Purpose: Validates attachment creation requests when adding files to existing messages
Schema Details:
- Type:
object - Required Fields:
objectId(UUID format),type(string) - Additional Properties:
false(strict validation) - Content-Type:
application/json - Request Body:
required
Properties:
objectId: string- UUID reference to the uploaded file in storagetype: string- MIME type or file category
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatMessageAttachmentSchema } = schemas;
const schema = createChatMessageAttachmentSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
objectId: '550e8400-e29b-41d4-a716-446655440000',
type: 'image/png'
});
Example Request:
POST /messages/:messageId/attachments
Content-Type: application/json
{
"objectId": "550e8400-e29b-41d4-a716-446655440000",
"type": "image/png"
}
Key Features:
- Validates objectId is a valid UUID
- Requires both objectId and type fields
- Used with
createChatMessageAttachmentblock function - Attachment automatically receives base entity fields upon creation
deleteChatMessageAttachmentSchema
Chat message attachment deletion schema with path parameter validation.
Purpose: Validates attachment deletion requests with message and attachment IDs
Schema Details:
- Type: Path parameters
- Required Parameters:
messageId(string),attachmentId(string) - Method: DELETE
Path Parameters:
messageId: string- UUID of the chat message containing the attachmentattachmentId: string- UUID of the attachment to delete
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageAttachmentSchema } = schemas;
// Schema validates path parameters
const schema = deleteChatMessageAttachmentSchema({});
Example Request:
DELETE /messages/550e8400-e29b-41d4-a716-446655440000/attachments/660e8400-e29b-41d4-a716-446655440001
Key Features:
- Validates both messageId and attachmentId path parameters
- Used with
deleteChatMessageAttachmentblock function - Removes attachment from database and deletes file from storage
- Returns 204 No Content on success
createChatMessageSchema
Chat message creation schema with required content, sender, and channel.
Purpose: Validates message data during creation
Schema Details:
- Type:
object - Required Fields:
content,senderId,channelId - Optional Fields:
title - Additional Properties:
false(strict validation) - Content-Type:
application/json - Request Body:
required
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatMessageSchema } = schemas;
const schema = createChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
content: 'Hello world!',
senderId: 'user123',
channelId: 'channel456'
});
updateChatMessageSchema
Chat message update schema with optional fields for message modifications.
Purpose: Validates partial message data updates
Schema Details:
- Type:
object - Required Fields: None (all fields optional)
- Additional Properties:
false(strict validation) - Content-Type:
application/json - Parameters:
messageId(path parameter) - Request Body:
required
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatMessageSchema } = schemas;
const schema = updateChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ content: 'Updated message content' });
getChatMessageSchema
Chat message retrieval schema for getting single messages.
Purpose: Validates requests for retrieving specific chat messages
Schema Details:
- Parameters:
messageId(path parameter) - Purpose: Validates requests for retrieving specific chat messages
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatMessageSchema } = schemas;
const schema = getChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageId: 'message123' });
deleteChatMessageSchema
Chat message deletion schema for removing messages.
Purpose: Validates requests for deleting specific chat messages
Schema Details:
- Parameters:
messageId(path parameter) - Purpose: Validates requests for deleting specific chat messages
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageSchema } = schemas;
const schema = deleteChatMessageSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageId: 'message123' });
findChatMessagesSchema
Chat messages search schema for finding messages with filtering and pagination.
Purpose: Validates requests for searching and paginating chat messages within a specific channel
Schema Details:
- Query Parameters:
channelId: string- Required filter by channelcontent?: string- Optional filter by message contentsenderId?: string- Optional filter by sendertitle?: string- Optional filter by message titlepage?: number- Pagination page numberlimit?: number- Pagination limit
- Purpose: Validates requests for searching and paginating chat messages
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessagesSchema } = schemas;
const schema = findChatMessagesSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
senderId: 'user123',
page: 1,
limit: 10
});
channelIdQueryParameter
Channel ID query parameter for WebSocket chat message routing.
Purpose: Defines the channelId query parameter used in WebSocket connections for real-time message streaming
Parameter Details:
- Location:
query(URL query string) - Name:
channelId - Required:
true - Type:
string
Usage:
// Used in WebSocket schema composition:
export const streamChatMessagesSchema = withSchema({
parameters: [channelIdQueryParameter]
});
// Client WebSocket connection:
// ws://localhost:3000/messages/listen?channelId=channel123
Example Query String:
?channelId=550e8400-e29b-41d4-a716-446655440000
streamChatMessagesSchema
Chat message streaming schema with channelId query parameter validation for WebSocket connections.
Purpose: Validates WebSocket connection requests for real-time chat message streaming
Schema Details:
- Protocol: WebSocket (ws)
- Parameters:
channelId(query parameter, required) - Purpose: Ensures channelId is provided when establishing WebSocket connection for message streaming
Query Parameters:
| Field | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Channel ID for streaming messages |
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { streamChatMessagesSchema } = schemas;
// Applied in feature composition:
export const streamChatMessagesFeature = compose(
streamChatMessagesSchema,
streamChatMessagesRoute
);
// Client establishes WebSocket connection:
const ws = new WebSocket('ws://localhost:3000/messages/listen?channelId=channel123');
WebSocket Flow:
- Client connects with
channelIdin query string - Schema validates
channelIdpresence - Server establishes MongoDB change stream for the channel
- New messages are streamed to client in real-time
Error Handling:
- Missing
channelId: Returns validation error with 400 status - Invalid
channelIdformat: Returns validation error
📝 Message Template Schemas
Message template structures for reusable chat content and standardized messaging.
chatMessageTemplateSchema
Base chat message template schema defining the structure for reusable message templates.
Purpose: Defines the core structure for chat message templates used across the application
Schema Details:
- Type:
object - Required Fields: None (base schema)
- Additional Properties:
false(strict validation) - Properties:
content?: string- Template message contentorganizationId?: string- Organization identifier for template scopepermissions?: string[]- Array of permission strings for access controltitle?: string- Template title/description
Usage:
// Use as base for other schemas:
export const createSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...chatMessageTemplateSchema,
required: ['content', 'title']
}
}
}
}
});
createChatMessageTemplateSchema
Chat message template creation schema with required fields validation for template creation requests.
Purpose: Validates message template data during creation with required content and title fields
Schema Details:
- Content-Type:
application/json - Request Body:
required - Required Fields:
content,title - Optional Fields:
organizationId,permissions - Additional Properties:
false(strict validation)
Request Body Structure:
| Field | Type | Required | Description |
|---|---|---|---|
content | string | ✅ | Template message content |
title | string | ✅ | Template title/description |
organizationId | string | ❌ | Organization identifier for template scope |
permissions | string[] | ❌ | Array of permission strings for access control |
Usage:
// Use as base for other schemas:
export const createSchema = withSchema({
requestBody: {
content: {
'application/json': {
schema: {
...chatMessageTemplateSchema,
required: ['content', 'title']
}
}
}
}
});
getChatMessageTemplateSchema
Chat message template retrieval schema with path parameter validation.
Purpose: Validates requests for retrieving a chat message template by ID
Schema Details:
- Parameters:
messageTemplateId(path parameter) - Purpose: Validates requests for retrieving a chat message template by ID
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatMessageTemplateSchema } = schemas;
const schema = getChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ messageTemplateId: 'template123' });
updateChatMessageTemplateSchema
Chat message template update schema with path parameter and partial body validation.
Purpose: Validates requests for updating existing chat message templates with partial data support
Schema Details:
- Content-Type:
application/json - Request Body:
required - Parameters:
messageTemplateId(path parameter) - Required Fields: None (partial updates)
- Optional Fields:
content,title - Additional Properties:
false(strict validation)
Request Body Structure:
| Field | Type | Required | Description |
|---|---|---|---|
content | string | ❌ | Updated template message content |
title | string | ❌ | Updated template title/description |
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { updateChatMessageTemplateSchema } = schemas;
const schema = updateChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
messageTemplateId: 'template123',
content: 'Updated message content',
title: 'Updated title'
});
deleteChatMessageTemplateSchema
Chat message template deletion schema with path parameter validation.
Purpose: Validates requests for deleting existing chat message templates by ID.
Schema Details:
- Content-Type: Not applicable (no request body)
- Request Body: None
- Parameters:
messageTemplateId(path parameter) - Required Fields:
messageTemplateId - Additional Properties:
false(strict validation)
Request Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
messageTemplateId | string | ✅ | Unique identifier of the message template to delete |
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatMessageTemplateSchema } = schemas;
const schema = deleteChatMessageTemplateSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
messageTemplateId: 'template123'
});
findChatMessageTemplatesSchema
Chat message templates listing schema with pagination validation.
Purpose: Validates requests for listing chat message templates with pagination support.
Schema Structure:
{
page?: number; // optional - page number (1-1000)
limit?: number; // optional - records per page (1-50)
}
Schema Details:
- Content-Type: Not applicable (query parameters only)
- Request Body: None
- Parameters: Uses common pagination query parameters
- Required Fields: None
- Additional Properties:
false(strict validation)
Query Parameters:
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
page | number | ❌ | 1 | 1-1000 | Page number for pagination |
limit | number | ❌ | 10 | 1-50 | Number of templates per page |
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessageTemplatesSchema } = schemas;
const schema = findChatMessageTemplatesSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
page: 1,
limit: 10
});
// Apply to feature composition:
export const findChatMessageTemplatesFeature = compose(
findChatMessageTemplatesSchema,
findChatMessageTemplatesRoute
);
Validation Rules:
page: Optional integer, minimum value 1, maximum value 1000limit: Optional integer, minimum value 1, maximum value 50- Both parameters are validated against common pagination schema
findChatMessageTemplatesForOrganizationSchema
Chat message template retrieval schema with organization-scoped pagination.
Purpose: Validates requests for retrieving chat message templates scoped to a specific organization with pagination support.
Schema Structure:
{
organizationId: string; // required - organization identifier for scoped retrieval
page?: number; // optional - page number for pagination
limit?: number; // optional - items per page for pagination
}
Schema Details:
- Content-Type: Not applicable (path and query parameters only)
- Request Body: None
- Parameters: Organization ID path parameter plus pagination query parameters
- Required Fields:
organizationId(path parameter) - Additional Properties:
false(strict validation)
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
organizationId | string | ✅ | Unique identifier of the organization to retrieve templates for |
Query Parameters:
| Parameter | Type | Required | Default | Range | Description |
|---|---|---|---|---|---|
page | number | ❌ | 1 | 1-1000 | Page number for pagination |
limit | number | ❌ | 10 | 1-50 | Number of templates per page |
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatMessageTemplatesForOrganizationSchema } = schemas;
const schema = findChatMessageTemplatesForOrganizationSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
organizationId: 'org-123',
page: 1,
limit: 10
});
// Apply to feature composition:
export const findChatMessageTemplatesForOrganizationFeature = compose(
findChatMessageTemplatesForOrganizationSchema,
findChatMessageTemplatesForOrganizationRoute
);
Validation Rules:
organizationId: Required string identifierpage: Optional integer, minimum value 1, maximum value 1000limit: Optional integer, minimum value 1, maximum value 50- Path parameter validation ensures organization scoping
- Pagination parameters validated against common schema
🔔 Subscription Schemas
chatSubscriptionSchema
Base chat subscription schema with core subscription fields.
Purpose: Defines basic subscription structure for chat channels
Schema Details:
- Type:
object - Required Fields: None (base schema)
- Additional Properties:
false(strict validation) - Properties:
approved?: boolean- Subscription approval statuspermissions?: string[]- User permissions arraysubscribedAt?: string- Subscription date (date-time format)subscribedId?: string- Subscriber identity IDchannelId?: string- Channel ID
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatSubscriptionSchema } = schemas;
const validate = ajv.compile(chatSubscriptionSchema as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
subscribedId: 'identity456',
approved: true,
permissions: ['read', 'write']
});
createChatSubscriptionSchema
Chat subscription creation schema with required channel ID.
Purpose: Validates subscription data during creation
Schema Details:
- Type:
object - Required Fields:
channelId,subscribedId - Optional Fields:
approved,permissions,subscribedAt - Additional Properties:
false(strict validation) - Content-Type:
application/json - Request Body:
required
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { createChatSubscriptionSchema } = schemas;
const schema = createChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
channelId: 'channel123',
subscribedId: 'user456',
approved: true
});
getChatSubscriptionSchema
Chat subscription retrieval schema for getting single subscriptions.
Purpose: Validates requests for retrieving specific chat subscriptions
Schema Details:
- Parameters:
subscriptionId(path parameter)
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { getChatSubscriptionSchema } = schemas;
const schema = getChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ subscriptionId: 'sub123' });
deleteChatSubscriptionSchema
Chat subscription deletion schema for removing subscriptions.
Purpose: Validates requests for deleting specific chat subscriptions
Schema Details:
- Parameters:
subscriptionId(path parameter) - Purpose: Validates requests for deleting specific chat subscriptions
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { deleteChatSubscriptionSchema } = schemas;
const schema = deleteChatSubscriptionSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({ subscriptionId: 'sub123' });
findChatSubscriptionsSchema
Chat subscriptions search schema for finding subscriptions with filtering and pagination.
Purpose: Validates requests for searching and paginating chat subscriptions
Schema Details:
- Query Parameters:
approved?: boolean- Filter by approval statuschannelId?: string- Filter by channelsubscribedAt?: string- Filter by subscription date (date-time format)subscribedId?: string- Filter by subscriberpage?: number- Pagination page numberlimit?: number- Pagination limit
- Purpose: Validates requests for searching and paginating chat subscriptions
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { findChatSubscriptionsSchema } = schemas;
const schema = findChatSubscriptionsSchema({});
const validate = ajv.compile(schema.schemas as SchemaDefinition);
const isValid = validate({
approved: true,
page: 1,
limit: 10
});
Chat Channel Read State Schemas
chatChannelReadStateSchema
Chat channel read state schema with required fields for read state tracking.
Purpose: Validates chat channel read state data with required identityId and lastReadMessageId
Schema Structure:
{
identityId: string; // required - unique identifier for the user
lastReadMessageId: string; // required - unique identifier for the last read message
}
Schema Details:
- Type:
object - Required Fields: None (fields become required in upsertChatChannelReadStateSchema)
- Additional Properties:
false(strict validation)
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { chatChannelReadStateSchema } = schemas;
// Use as base schema for read state validation
const validate = ajv.compile(chatChannelReadStateSchema);
const isValid = validate({
identityId: '00000000-0000-1000-a000-111111111111',
lastReadMessageId: '00000000-0000-1000-a000-222222222222'
});
upsertChatChannelReadStateSchema
Chat channel read state upsert schema with path parameter and request body validation.
Purpose: Validates PUT requests for upserting channel read states
Schema Structure:
{
// Path parameters
channelId: string; // required - unique identifier for the chat channel
// Request body
identityId: string; // required - unique identifier for the user
lastReadMessageId: string; // required - unique identifier for the last read message
}
Schema Details:
- Parameters:
channelId(path parameter, required) - Request Body:
identityId,lastReadMessageId(both required) - Content-Type:
application/json - Additional Properties:
false(strict validation)
Usage:
import { schemas } from '@nodeblocks/backend-sdk';
const { upsertChatChannelReadStateSchema } = schemas;
// Apply to feature composition:
export const upsertChatChannelReadStateFeature = compose(
upsertChatChannelReadStateSchema,
upsertChatChannelReadStateRoute
);
Request Body Requirements:
| Field | Type | Required | Description |
|---|---|---|---|
identityId | string | ✅ | User identity ID |
lastReadMessageId | string | ✅ | Last read message ID |
Path Parameters:
| Parameter | Type | Required | Description |
|---|---|---|---|
channelId | string | ✅ | Chat channel ID |
🔗 Related Documentation
- Chat Domain Overview - Chat domain overview