-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
35 lines (25 loc) · 1018 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
import express from 'express';
import { fileURLToPath } from 'url';
import { dirname, join } from 'path';
import fs from 'fs';
const __filename = fileURLToPath(new URL(import.meta.url));
const __dirname = dirname(__filename);
const app = express();
const port = process.env.PORT || 3000;
app.set('view engine', 'ejs');
app.use(express.static(join(__dirname, 'public')));
app.get('/meetingtimer', (req, res) => {
const { agenda, times } = req.query;
if (!agenda || !times) {
return res.status(400).send('Missing agenda or times parameters');
}
const agendaItems = agenda.split(',');
const timeItems = times.split(',').map(Number);
if (agendaItems.length !== timeItems.length || agendaItems.length > 10 || agendaItems.length < 1) {
return res.status(400).send('Invalid number of agenda items or times');
}
res.render('timer', { agendaItems, timeItems });
});
app.listen(port, () => {
console.log(`AgendaControl running at http://localhost:${port}`);
});