mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-08 21:07:46 +00:00
Add API for frameworks and examples (#3514)
* 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>
This commit is contained in:
35
examples/vanilla-pusher-functions/api/push-draw-data.js
Normal file
35
examples/vanilla-pusher-functions/api/push-draw-data.js
Normal file
@@ -0,0 +1,35 @@
|
||||
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);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user