-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
30 lines (24 loc) · 910 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
29
30
const express = require('express');
const bodyParser = require('body-parser');
const cors = require('cors');
const morgan = require('morgan');
const mongoose = require('mongoose');
const bot = require('./bot');
const config = require('./config');
const app = express();
const dbURL = `mongodb+srv://${config.mongoUser}:${config.mongoPwd}@vacybot-jlx8w.mongodb.net/vacy_db?retryWrites=true&w=majority`;
app.use(morgan('combined'));
app.use(bodyParser.json());
app.use(cors());
mongoose.Promise = global.Promise;
mongoose.connect(dbURL, {useNewUrlParser: true});
mongoose.connection
.once('open', () => {
console.log(`Mongoose - successful connection ...`);
app.listen(process.env.PORT || config.PORT,
() => console.log(`Server start on port ${config.PORT} ...`))
})
.on('error', error => console.warn(error));
setInterval(() => {
bot.getFeed(config.MOIKRUG_URL);
}, config.REQUEST_PERIOD_TIME);