-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
28 lines (23 loc) · 815 Bytes
/
index.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
const express = require('express');
const cors = require('cors');
const path = require('path');
const app = express();
const port = process.env.PORT || 3000;
app.use(cors());
app.use(express.json());
// Serve static files from the 'website' directory
app.use(express.static(path.join(__dirname, 'website')));
// API endpoint to receive data from the extension
app.post('/api/track', (req, res) => {
const { platform, content } = req.body;
console.log(`Received ${platform} data:`, content);
// Here you would typically save this data to a database
res.json({ success: true });
});
// Serve the dashboard
app.get('/dashboard', (req, res) => {
res.sendFile(path.join(__dirname, 'website', 'dashboard.html'));
});
app.listen(port, () => {
console.log(`Server running at http://localhost:${port}`);
});