pollo/src/server/ably.ts

14 lines
382 B
TypeScript
Raw Normal View History

2023-04-20 04:20:00 -06:00
import Ably from "ably";
import { env } from "~/env.mjs";
2023-07-11 17:22:54 -06:00
import type { EventType } from "../utils/types";
2023-04-20 04:20:00 -06:00
export const publishToChannel = async (
2023-07-12 18:15:19 -06:00
ablyInstance: Ably.Types.RealtimePromise,
2023-04-20 04:20:00 -06:00
channel: string,
event: EventType,
message: string
) => {
2023-07-12 18:15:19 -06:00
const channelName = ablyInstance.channels.get(`${env.APP_ENV}-${channel}`);
2023-04-20 04:20:00 -06:00
await channelName.publish(event, message);
};