-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.ts
109 lines (96 loc) · 3.13 KB
/
app.ts
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
import { App } from '@slack/bolt';
import { LogLevel } from '@slack/logger';
import { config } from '@/config';
import { healthEndpoint } from '@/lib/routes/health';
import { withNamespace } from '@/logger';
import '@/lib/stringExtensions';
import '@/lib/dateExtensions';
import '@/lib/numberExtensions';
// messages
import { register as messagesCryptoRegister } from '@/messages.crypto';
import { register as messagesScoreboardRegister } from '@/messages.scoreboard';
import { register as messagesHelpRegister } from '@/messages.help';
import { register as messagesPlusPlusRegister } from '@/messages.plusplus';
// etc
import { register as migrationsRegister } from '@/migrations';
// cron job
import './src/monthlyScoreboardCron';
// event handlers
import './src/events';
// hometab
import { register as hometabRegister } from '@/hometab';
import { register as hometabActionsRegister } from '@/hometab.actions';
import { register as hometabViewsRegister } from '@/hometab.views';
//shortcuts
import { register as shortcutsRegister } from '@/shortcuts';
import { installService } from '@/lib/services';
import { pointdPalInstallationStore } from '@/lib/installationStore';
const appLogger = withNamespace('pointd-pal');
const app = new App({
signingSecret: config.get('slack.signingSecret'),
clientId: config.get('slack.clientId'),
clientSecret: config.get('slack.clientSecret'),
stateSecret: config.get('slack.stateSecret'),
appToken: config.get('slack.appToken'),
logLevel: config.get('logLevel') as LogLevel,
socketMode: true,
installationStore: pointdPalInstallationStore,
tokenVerificationEnabled: true,
redirectUri: `${config.get('baseUrl')}/slack/oauth_redirect`,
installerOptions: {
directInstall: true,
// stateVerification: false,
redirectUriPath: '/slack/oauth_redirect',
},
scopes: [
'app_mentions:read',
'channels:history',
'channels:manage',
'channels:read',
'channels:join',
'chat:write',
'commands',
'groups:history',
'groups:read',
'groups:write',
'im:history',
'im:read',
'im:write',
'mpim:history',
'mpim:read',
'mpim:write',
'users.profile:read',
'users:read',
'users:read.email',
'usergroups:read',
],
customRoutes: [healthEndpoint],
logger: {
getLevel: () => config.get('logLevel') as LogLevel,
setLevel: (level: LogLevel) => config.set('logLevel', level),
debug: (...msg) => appLogger.debug(msg),
info: (...msg) => appLogger.info(msg),
warn: (...msg) => appLogger.warn(msg),
error: (...msg) => appLogger.error(msg),
setName: (name: string) => appLogger.label(name),
},
});
void (async () => {
appLogger.info(
'Before we start the apps we will validate that all installations are up to date by running migrations. Please hold on...',
);
await installService.migrateAll();
// Start your app
await app.start({ port: config.get('port') });
appLogger.info(`⚡️ Bolt app is running at localhost:${config.get('port')}!`);
})();
messagesCryptoRegister(app);
messagesScoreboardRegister(app);
messagesHelpRegister(app);
messagesPlusPlusRegister(app);
migrationsRegister(app);
shortcutsRegister(app);
hometabRegister(app);
hometabActionsRegister(app);
hometabViewsRegister(app);
export { app };