-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (34 loc) · 1.01 KB
/
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Express npm module for requests
const express = require('express');
// Express instance
const app = express();
// Bodyparser npm module
const bodyParser = require("body-parser");
/**
* BodyParser URL encoded parsing function.
*/
app.use(bodyParser.urlencoded({
extended: true,
}));
/**
* BodyParser JSON parsing function.
*/
app.use(bodyParser.json());
// Path module for managing directory access
const path = require('path');
// Scrape function from utilities
const scraper = require('./utilities/utils.js').scrapeHandler;
app.use(express.static(path.join(__dirname, '/public')));
// "/search" endpoint uses inventory.js
app.use('/data', require('./routes/inventory.js'));
// Base endpoint uses view.js
app.use("/", require('./routes/view.js'));
// Listens for server running.
app.listen(process.env.PORT || 5000, () => {
console.log("Server up and running on port: " + (process.env.PORT || 5000));
try {
(setInterval(scraper, 60000));
} catch (err) {
console.log("Error: " + err);
}
});