Skip to content

Instantly share code, notes, and snippets.

@onedebos
Last active March 8, 2021 21:09
Show Gist options
  • Save onedebos/0d7adec2ab1696362e13571a8191fc81 to your computer and use it in GitHub Desktop.
Save onedebos/0d7adec2ab1696362e13571a8191fc81 to your computer and use it in GitHub Desktop.
pages/api/pusher.js
import Pusher from "pusher";
export const pusher = new Pusher({
appId: process.env.app_id,
key: process.env.key,
secret: process.env.secret,
cluster: process.env.cluster,
useTLS: true,
});
export default async function handler(req, res) {
const { message, sender } = req.body;
const response = await pusher.trigger("chat", "chat-event", {
message,
sender,
});
res.json({ message: "completed" });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment