pollo/src/server/ably.ts

18 lines
430 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
const ablyRest = new Ably.Rest(env.ABLY_PRIVATE_KEY);
export const publishToChannel = (
2023-04-20 04:20:00 -06:00
channel: string,
event: EventType,
message: string
) => {
try {
ablyRest.channels.get(`${env.APP_ENV}-${channel}`).publish(event, message);
} catch (error) {
console.log(`❌❌❌ Failed to send message!`);
}
2023-04-20 04:20:00 -06:00
};