-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
38 lines (31 loc) · 1.04 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
const {WebClient} = require('@slack/web-api');
const Notifications = require('./utilities/Notifications');
const Sentry = require("@sentry/node");
const cron = require("node-cron");
// Configure Sentry exception logging
if (process.env.SENTRY_DSN) {
const sentryConfig = {
dsn: process.env.SENTRY_DSN,
release: `chorebot@${require("./package.json").version}`
};
if (process.env.ENVIRONMENT) sentryConfig.environment = process.env.ENVIRONMENT;
Sentry.init(sentryConfig);
}
if (!process.env.SLACK_BOT_TOKEN) {
throw 'Environment variables not properly loaded!';
}
/***
* Globals
* @type {string} TOKEN - Slack bot access token
* @type {string} CRON_SCHEDULE - When to run BirthdayBot
*/
const TOKEN = process.env.SLACK_BOT_TOKEN;
const CRON_SCHEDULE = process.env.CRON_SCHEDULE;
/***
*
* @type {WebClient} webclient
* @type {Notifications} notifications
*/
const webclient = new WebClient(TOKEN);
const notifications = new Notifications(webclient);
cron.schedule(CRON_SCHEDULE, notifications.announceBirthdays);