-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
32 lines (24 loc) · 778 Bytes
/
Copy pathindex.js
File metadata and controls
32 lines (24 loc) · 778 Bytes
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
const express = require('express');
const path = require('path');
const app = express();
const port = 3000;
const router = express.Router();
app.use(express.json());
app.use(express.static(__dirname + '/public'));
router.get('/', function(req, res) {
const { indexUpdated } = req.query;
if (indexUpdated) {
// TODO: show message indicating index was updated
console.log({ indexUpdated });
}
return res.sendFile(path.join(__dirname + '/public/html/index.html'));
});
router.post('/search', function(req, res) {
const { query = '' } = req.body;
return res.json({ results: [] });
});
router.post('/create-index', (req, res) => {
return res.send();
});
app.use('/', router);
app.listen(port, () => console.log(`TBC search running in port: ${port}!`));