-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot.js
29 lines (20 loc) · 972 Bytes
/
bot.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
const mongoose = require('mongoose');
const credentials = require('./credentials');
const getTweets = require('./getTweets');
const colors = require('colors/safe');
const twitterUsers = require('./db/models/twitterUsers');
const userSearch = twitterUsers.getTwitterUser();
const userTweets = require('./db/models/userTweets');
const tweetSearch = userTweets.getTwitterUser();
const r = require('./results')
//stores mongodb credentials
const username = process.env.USERNAME_ENV || credentials.username;
const password = process.env.PASSWORD || credentials.password;
const dbHost = process.env.DBHOST || credentials.host;
const db = process.env.DB || credentials.database;
//mongodb connection string
const dbUrl = 'mongodb+srv://' + username +
':' + password + '@' + dbHost + '/' + db +
'?retryWrites=true&w=majority';
mongoose.connect(dbUrl, { useNewUrlParser: true, useUnifiedTopology: true });
getTweets.searchByHashtag('starbucks').then(r.saveTweets)