Skip to content

Commit

Permalink
Allow changing the Slack API URL
Browse files Browse the repository at this point in the history
Configuration is available through the SLACK_API_BASE_URL environment variable and defaults to https://slack.com/api/
  • Loading branch information
cmd-johnson committed May 24, 2024
1 parent b8f2350 commit 6ff74c3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions packages/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ As obtained via https://api.slack.com/apps
```sh
# The Slack App's Bot User OAuth Token (starts with xoxb-)
SLACK_TOKEN

# The base URL of Slack's API (defaults to https://slack.com/api/)
#SLACK_API_BASE_URL
```

### Neucore configuration
Expand Down
5 changes: 4 additions & 1 deletion packages/backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ async function main() {
cacheTTL: getNumberFromEnv('CORE_GROUP_REFRESH_INTERVAL', 60) * 1000,
})

const slackClient = new SlackClient(getFromEnv('SLACK_TOKEN'))
const slackClient = new SlackClient(
getFromEnv('SLACK_TOKEN'),
getOptionalFromEnv('SLACK_API_BASE_URL')
)

const sessionTimeout = getNumberFromEnv('SESSION_TIMEOUT', 7 * 24 * 60 * 60) * 1000
const sessionRefreshInterval = getNumberFromEnv('SESSION_REFRESH_INTERVAL', 60) * 1000
Expand Down
3 changes: 2 additions & 1 deletion packages/backend/src/slack/slack-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ export class SlackRequestFailedError extends Error {
export class SlackClient {
private client: WebClient

constructor(token: string) {
constructor(token: string, apiBaseUrl?: string) {
this.client = new WebClient(token, {
logLevel: LogLevel.DEBUG,
slackApiUrl: apiBaseUrl,
})
}

Expand Down

0 comments on commit 6ff74c3

Please sign in to comment.