-
Notifications
You must be signed in to change notification settings - Fork 50
/
app.js
56 lines (48 loc) · 1.34 KB
/
app.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
require('dotenv').config();
const { App, LogLevel } = require('@slack/bolt');
const { Sequelize } = require('sequelize');
const sequelize = new Sequelize(process.env.DB_URI);
const { registerListeners } = require('./listeners');
let logLevel;
switch (process.env.LOG_LEVEL) {
case 'debug':
logLevel = LogLevel.DEBUG;
break;
case 'info':
logLevel = LogLevel.INFO;
break;
case 'warn':
logLevel = LogLevel.WARN;
break;
case 'error':
logLevel = LogLevel.ERROR;
break;
default:
logLevel = LogLevel.INFO;
}
// Initializes your app with your bot token and signing secret
const app = new App({
token: process.env.SLACK_BOT_TOKEN,
socketMode: true,
appToken: process.env.SLACK_APP_TOKEN,
logLevel,
});
registerListeners(app);
(async () => {
try {
await sequelize.authenticate();
await sequelize.sync({ force: true });
// eslint-disable-next-line no-console
console.log('All models were synchronized successfully.');
// eslint-disable-next-line no-console
console.log('Connection has been established successfully.');
// Start your app
await app.start();
// eslint-disable-next-line no-console
console.log('⚡️ Tasks app is running!');
} catch (error) {
// eslint-disable-next-line no-console
console.error('Unable to start App', error);
process.exit(1);
}
})();