@directus/api
Version:
Directus is a real-time API and App dashboard for managing SQL database content
39 lines (38 loc) • 1.3 kB
JavaScript
import { useEnv } from '@directus/env';
import { toBoolean } from '@directus/utils';
import { CollabHandler } from '../collab/collab.js';
import { HeartbeatHandler } from './heartbeat.js';
import { ItemsHandler } from './items.js';
import { LogsHandler } from './logs.js';
import { SubscribeHandler } from './subscribe.js';
let collabHandler;
export function startWebSocketHandlers() {
const env = useEnv();
const heartbeatEnabled = toBoolean(env['WEBSOCKETS_HEARTBEAT_ENABLED']);
const restEnabled = toBoolean(env['WEBSOCKETS_REST_ENABLED']);
const graphqlEnabled = toBoolean(env['WEBSOCKETS_GRAPHQL_ENABLED']);
const logsEnabled = toBoolean(env['WEBSOCKETS_LOGS_ENABLED']);
const collabEnabled = toBoolean(env['WEBSOCKETS_COLLAB_ENABLED']);
if (restEnabled && heartbeatEnabled) {
new HeartbeatHandler();
}
if (restEnabled || graphqlEnabled) {
new ItemsHandler();
}
if (restEnabled) {
new SubscribeHandler();
}
if (logsEnabled) {
new LogsHandler();
}
if (collabEnabled) {
collabHandler = new CollabHandler();
}
}
export function getCollabHandler() {
return collabHandler;
}
export * from './heartbeat.js';
export * from './items.js';
export * from './logs.js';
export * from './subscribe.js';