Skip to content

Function: channelSubject()

Makaio Framework


Makaio Framework / bus-core / channelSubject

channelSubject<T>(schema): ChannelSubjectSchema<T>

Defined in: ../../../packages/bus-core/src/utils/channel-schema.ts:54

Create a channel-only subject schema wrapper.

Channel subjects are rejected by public bus methods and are only routable through the DirectChannel encrypted point-to-point transport. Use this for subjects that must never travel over the public bus.

T extends EventSchema | RequestSchema

T

The event or request schema to mark as channel-only

ChannelSubjectSchema<T>

A ChannelSubjectSchema wrapper

import { channelSubject } from '@makaio/bus-core';
const DirectSchemas = {
// Channel event - encrypted, point-to-point only
message: channelSubject(z.object({ text: z.string() })),
// Channel request - encrypted request-response pair
ping: channelSubject({
request: z.object({ ts: z.number() }),
response: z.object({ ts: z.number() }),
}),
};