-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
40 lines (29 loc) · 972 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import express from 'express';
import { InitVenomClient } from './index.js';
const app = express();
app.use(express.json())
const port = 5000;
const sessionName = 'test-session';
const initVenomClient = new InitVenomClient(sessionName);
await initVenomClient.init();
app.get('/', (_, res) => {
res.send('Hello World!')
})
app.post('/send-text', async (req, res) => {
const { to, text } = req.body
const response = await initVenomClient.sendText(to, text);
res.send(response)
})
app.post('/send-buttons', async (req, res) => {
const { to, buttons } = req.body
const response = await initVenomClient.sendButtons(to, buttons)
res.send(response)
})
app.post('/send-image', async (req, res) => {
const { to, imageRoute, imageName, captionText } = req.body;
const response = await initVenomClient.sendImage(to, imageRoute, imageName, captionText)
res.send(response)
})
app.listen(port, () => {
console.log(`Server listening on port ${port}!`)
})