-
Notifications
You must be signed in to change notification settings - Fork 3
/
server.js
41 lines (32 loc) · 1.15 KB
/
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
41
const express = require('express');
const bodyParser = require('body-parser');
const { handleBotEvent } = require('./zoom/chatbot/sendMessage');
const path = require('path');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 4000;
app.use(bodyParser.json());
app.use((req, res, next) => {
console.log(`${new Date().toISOString()} - ${req.method} ${req.url}`);
next();
});
app.get('/', (req, res) => {
res.send('OK');
});
app.post('/datastax', (req, res) => {
console.log('Received POST request to /datastax');
console.log('Request body:', JSON.stringify(req.body, null, 2));
handleBotEvent(req, res);
});
app.listen(port, () => console.log(`Listening at http://localhost:${port}`));
process.on('uncaughtException', (error) => {
console.error('Uncaught Exception:', error);
// Instead of exiting, we'll keep the server running
// process.exit(1);
});
process.on('unhandledRejection', (reason, promise) => {
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
// Instead of exiting, we'll keep the server running
// process.exit(1);
});
console.log('Server started. Waiting for requests...');