[mirotalksfu] - add webhook
هذا الالتزام موجود في:
19
webhook/package.json
Normal file
19
webhook/package.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "mirotalk-webhook",
|
||||
"version": "1.0.0",
|
||||
"description": "MiroTalk WebHook endpoint example",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"keywords": [
|
||||
"webhook",
|
||||
"server"
|
||||
],
|
||||
"author": "Miroslav Pejic",
|
||||
"license": "AGPLv3",
|
||||
"dependencies": {
|
||||
"express": "4.21.2",
|
||||
"body-parser": "1.20.3"
|
||||
}
|
||||
}
|
||||
41
webhook/server.js
Normal file
41
webhook/server.js
Normal file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
const express = require('express');
|
||||
const bodyParser = require('body-parser');
|
||||
|
||||
const app = express();
|
||||
const port = 8888;
|
||||
|
||||
// Middleware to parse JSON bodies
|
||||
app.use(bodyParser.json());
|
||||
|
||||
// Endpoint to receive webhooks
|
||||
app.post('/webhook-endpoint', (req, res) => {
|
||||
const { event, data } = req.body;
|
||||
|
||||
// Handle different events
|
||||
switch (event) {
|
||||
case 'disconnect':
|
||||
console.log('User disconnected:', data);
|
||||
// Add your custom logic here
|
||||
break;
|
||||
case 'join':
|
||||
console.log('User joined:', data);
|
||||
// Add your custom logic here
|
||||
break;
|
||||
case 'exit':
|
||||
console.log('User exited:', data);
|
||||
// Add your custom logic here
|
||||
break;
|
||||
default:
|
||||
console.error('Unknown event type');
|
||||
break;
|
||||
}
|
||||
|
||||
res.status(200).send('Webhook received');
|
||||
});
|
||||
|
||||
// Start the server
|
||||
app.listen(port, () => {
|
||||
console.log(`Webhook server running on http://localhost:${port}`);
|
||||
});
|
||||
المرجع في مشكلة جديدة
حظر مستخدم