learning_ai_invt_trdg/shared/realtime.ts

13 lines
456 B
TypeScript

export function buildTradingSocketOptions(token: string, socketPath?: string) {
return {
transports: ['polling', 'websocket'] as ('polling' | 'websocket')[],
auth: { token },
...(socketPath ? { path: socketPath } : {}),
};
}
export function isUnauthorizedSocketError(message: string) {
const normalizedMessage = message.toLowerCase();
return normalizedMessage.includes('unauthorized') || normalizedMessage.includes('invalid token');
}