-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserver.js
51 lines (37 loc) · 1.42 KB
/
server.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
46
47
48
49
50
51
if ( !process.env.PROJECT_NAME || !process.env.PROJECT_ID ){
require( 'dotenv' ).config();
}
const fs = require('fs'),
imgPath = './.data/img';
if ( !fs.existsSync( imgPath ) ){
fs.mkdirSync( imgPath );
}
const app = require(__dirname + "/app.js"),
db = require(__dirname + "/helpers/db.js"),
bot = require(__dirname + "/bot/bot.js"),
CronJob = require("cron").CronJob,
cronSchedules = require(__dirname + "/helpers/cron-schedules.js");
db.init();
/*********************************************/
/* FOR DEBUGGING */
// db.dropTable( 'Posts' );
// db.dropTable( 'Followers' );
// db.dropTable( 'Events' );
db.getFollowers( function( err, data ){
console.log( 'Followers:', data );
} );
// db.getPosts( function( err, data ){
// console.log( 'Posts:', data );
// } );
// db.getEvents( function( err, data ){
// console.log( 'Events:', data );
// } );
// bot.script();
/* DEBUGGING END */
/*********************************************/
/* Schedule your bot. See helpers/cron-schedules.js for common schedules, or the cron package documentation at https://www.npmjs.com/package/cron to create your own.*/
// ( new CronJob( cronSchedules.EVERY_SIX_HOURS, function() { bot.script() } ) ).start();
// ( new CronJob( cronSchedules.EVERY_THIRTY_SECONDS, function() { bot.script() } ) ).start();
const listener = app.listen(process.env.PORT, function() {
console.log(`app is running on port ${listener.address().port}...`);
});