mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-08 21:07:46 +00:00
* Add API for frameworks and examples * Adjust headers * Update frameworks list * Always use latest * Add types * Use now repo for downloading and listing * Use .existsSync * Remove unused packages * Use 307 for redirect * Add examples * Update tsconfig.json Co-Authored-By: Steven <steven@ceriously.com> * Make examples unique * Remove detectors from frameworks API * Use /api instead of Next.js * Install dependencies * Rename project * Change name * Empty * Change name * Update api/tsconfig.json Co-Authored-By: Steven <steven@ceriously.com> * Update examples Co-authored-by: Steven <steven@ceriously.com>
36 lines
644 B
JavaScript
36 lines
644 B
JavaScript
const Pusher = require('pusher');
|
|
|
|
const {
|
|
APP_ID: appId,
|
|
KEY: key,
|
|
SECRET: secret,
|
|
CLUSTER: cluster,
|
|
} = process.env;
|
|
|
|
const pusher = new Pusher({
|
|
appId,
|
|
key,
|
|
secret,
|
|
cluster,
|
|
});
|
|
|
|
module.exports = async (req, res) => {
|
|
const { x0, x1, y0, y1, color } = req.body;
|
|
try {
|
|
await new Promise((resolve, reject) => {
|
|
pusher.trigger(
|
|
'drawing-events',
|
|
'drawing',
|
|
{ x0, x1, y0, y1, color },
|
|
err => {
|
|
if (err) return reject(err);
|
|
resolve();
|
|
}
|
|
);
|
|
});
|
|
res.status(200).end('sent event succesfully');
|
|
} catch (e) {
|
|
console.log(e.message);
|
|
}
|
|
};
|