forked from nearform/zoom-shuffle-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
39 lines (33 loc) · 941 Bytes
/
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
import Fastify from 'fastify'
export default function buildServer(config) {
const fastify = Fastify({
logger: {
level: config.LOG_LEVEL,
...(config.PRETTY_PRINT && {
transport: {
target: 'pino-pretty',
},
}),
},
})
fastify.register(import('@fastify/postgres'), {
user: config.DB_USER,
password: config.DB_PASSWORD,
host: config.DB_HOST,
port: config.DB_PORT || 5432,
database: config.DB_NAME,
ssl: false,
})
fastify.register(import('./plugins/zoom.js'), {
clientId: config.CLIENT_ID,
clientSecret: config.CLIENT_SECRET,
botJid: config.BOT_JID,
secretToken: config.SECRET_TOKEN,
redirectUri: config.REDIRECT_URL,
})
fastify.get('/healthcheck', async () => 'ok')
fastify.register(import('./routes/authorize.js'))
fastify.register(import('./routes/hook.js'))
fastify.register(import('./routes/bot.js'))
return fastify
}