Skip to content

Instantly share code, notes, and snippets.

@onedebos
Created March 12, 2021 01:58
Show Gist options
  • Save onedebos/373fbbaef65720f582701cf3af8e8382 to your computer and use it in GitHub Desktop.
Save onedebos/373fbbaef65720f582701cf3af8e8382 to your computer and use it in GitHub Desktop.
import { pusher } from "../../../lib/pusher";
// presence channel handler
export default async function handler(req, res) {
const { message, username, userLocation } = req.body;
// trigger a new post event via pusher
await pusher.trigger("presence-channel", "chat-update", {
message,
username,
userLocation
});
res.json({ status: 200 });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment