-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathserver.js
87 lines (77 loc) · 2.06 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
const project = require('pillars');
const GDB = require("@goblindb/goblindb");
const Scheduled = require("scheduled");
const config = require("./config");
const apiManagement = require('./api');
const twitter_task = require("./scheduled_tasks/twitter");
const meetup_task = require("./scheduled_tasks/meetup");
const slack_task = require("./scheduled_tasks/slack");
const github_task = require("./scheduled_tasks/github");
const organziation_task = require("./scheduled_tasks/organization");
// Wake up GoblinDB
const goblinDB = GDB({
fileName: 'goblin'
}, err => {
if(err) throw "GoblinDB ERROR:", err;
// Starting the project
project.services.get('http').configure({
port: config.port
}).start();
});
// Routes definition
const apiRoutes = new Route({
id: 'apiRoutes',
path: 'api/v1/*:path',
cors: true,
method: "GET"
}, function(gw) {
apiManagement(gw, goblinDB);
});
const rootRoutes = new Route({
id: 'rootRoutes',
path: '/*',
cors: true,
method: "GET",
directory: {
path: './public/index.html',
listing: true
}
});
const staticFiles = new Route({
id: 'estatics',
path: '/*:path',
directory: {
path: './public',
listing: true
}
});
// Routes addition
project.routes.add(apiRoutes);
project.routes.add(rootRoutes);
project.routes.add(staticFiles);
// Cron Jobs definition
const dailyTasks = new Scheduled({
id: "dailyTasks",
pattern: "0 9 * * * *", // 09:00 AM every day
task: () => {
slack_task.slackInfo(goblinDB);
twitter_task.twitterInfo(goblinDB);
meetup_task.meetupInfo(goblinDB);
}
});
const hourlyTask = new Scheduled({
id: "hourlyTask",
pattern: "0 * * * * *", // Every Hour
task: () => {
github_task.allData(goblinDB);
organziation_task.communities(goblinDB);
organziation_task.team(goblinDB);
organziation_task.sponsors(goblinDB);
}
});
// -- Start Jobs
dailyTasks.start();
hourlyTask.start();
// -- Autostart Jobs
dailyTasks.launch();
hourlyTask.launch();