-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.js
More file actions
41 lines (25 loc) · 770 Bytes
/
server.js
File metadata and controls
41 lines (25 loc) · 770 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
33
34
35
36
37
38
39
40
41
const express = require('express')
const app = express()
const mongoose = require('mongoose')
const nodeCron = require('node-cron')
const impactsAnalysis = require('./datascraper/analysis')
const scraper = require('./datascraper/scraper')
const mainRoutes = require('./routes/routesMain')
scraper()
.then(data=> impactsAnalysis(data))
.catch(console.error())
// DO NOT FORGET SPACES BETWEEN ASTRISKS
nodeCron.schedule('*/15 * * * *', () => {
scraper()
.then(data => {impactsAnalysis(data)
})
.catch(console.error())
})
app.set('view engine', 'ejs')
app.use(express.static('public'))
app.use('/', mainRoutes)
app.use('/resources/', mainRoutes)
console.log(process.env.PORT)
app.listen(process.env.PORT, ()=> {
console.log(`Server is running!`)
})