Skip to content

Commit

Permalink
Use Slack SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
ekzyis committed Sep 13, 2023
1 parent 5b6fefa commit 0810dad
Show file tree
Hide file tree
Showing 4 changed files with 290 additions and 13 deletions.
17 changes: 17 additions & 0 deletions api/slack/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { WebClient, LogLevel } from '@slack/web-api'

const slackClient = global.slackClient || (() => {
if (!process.env.SLACK_BOT_TOKEN && !process.env.SLACK_CHANNEL_ID) {
console.warn('SLACK_* env vars not set, skipping slack setup')
return null
}
console.log('initing slack client')
const client = new WebClient(process.env.SLACK_BOT_TOKEN, {
logLevel: LogLevel.INFO
})
return client
})()

if (process.env.NODE_ENV === 'development') global.slackClient = slackClient

export default slackClient
Loading

0 comments on commit 0810dad

Please sign in to comment.