forked from slackapi/bolt-js
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix slackapi#1358 Expose common utilities for building HTTP module ba…
…sed receivers
- Loading branch information
Showing
20 changed files
with
963 additions
and
335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.env | ||
dist/ | ||
node_modules/ | ||
package-lock.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Bolt for JavaScript Koa Receiver Example App | ||
|
||
This is a quick example app to demonstrate how to implement a custom receiver to integrate `App` with 3rd party web framework, which allows developers to directly access Node.js http package interface. | ||
|
||
## Install Dependencies | ||
|
||
To link to latest source code, you can run the following script: | ||
|
||
``` | ||
./link.sh | ||
``` | ||
|
||
## Setup Environment Variables | ||
|
||
This app requires you setup a few environment variables. You can find these values in your [app configuration](https://api.slack.com/apps). | ||
|
||
```bash | ||
export SLACK_CLIENT_ID=YOUR_SLACK_CLIENT_ID | ||
export SLACK_CLIENT_SECRET=YOUR_SLACK_CLIENT_SECRET | ||
export SLACK_SIGNING_SECRET=YOUR_SLACK_SIGNING_SECRET | ||
``` | ||
|
||
## Run the App | ||
|
||
Start the app with the following command: | ||
|
||
``` | ||
npm start | ||
``` | ||
|
||
### Running with OAuth | ||
|
||
Only implement OAuth if you plan to distribute your application across multiple workspaces. Uncomment out the OAuth specific comments in the code. If you are on dev instance, you will have to uncomment out those options as well. | ||
|
||
Start `ngrok` so we can access the app on an external network and create a redirect URL for OAuth. | ||
|
||
``` | ||
ngrok http 3000 | ||
``` | ||
|
||
This output should include a forwarding address for `http` and `https` (we'll use the `https` one). It should look something like the following: | ||
|
||
``` | ||
Forwarding https://3cb89939.ngrok.io -> http://localhost:3000 | ||
``` | ||
|
||
Then navigate to **OAuth & Permissions** in your app configuration and click **Add a Redirect URL**. The redirect URL should be set to your `ngrok` forwarding address with the `slack/oauth_redirect` path appended. ex: | ||
|
||
``` | ||
https://3cb89939.ngrok.io/slack/oauth_redirect | ||
``` | ||
|
||
Start the OAuth flow from https://{your own subdomain}.ngrok.io/slack/install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/bin/bash | ||
|
||
current_dir=`dirname $0` | ||
cd ${current_dir} | ||
npm unlink @slack/bolt \ | ||
&& npm i \ | ||
&& cd ../.. \ | ||
&& npm link \ | ||
&& cd - \ | ||
&& npm i \ | ||
&& npm link @slack/bolt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"name": "bolt-oauth-example", | ||
"version": "1.0.0", | ||
"description": "Example app using OAuth", | ||
"main": "app.js", | ||
"scripts": { | ||
"lint": "eslint --fix --ext .ts src", | ||
"build": "npm run lint && tsc -p .", | ||
"build:watch": "npm run lint && tsc -w -p .", | ||
"start": "npm run build && node dist/app.js" | ||
}, | ||
"license": "MIT", | ||
"dependencies": { | ||
"@koa/router": "^10.1.1", | ||
"@slack/logger": "^3.0.0", | ||
"@slack/oauth": "^2.5.0-rc.1", | ||
"dotenv": "^8.2.0", | ||
"koa": "^2.13.4" | ||
}, | ||
"devDependencies": { | ||
"@types/koa__router": "^8.0.11", | ||
"@types/node": "^14.14.35", | ||
"ts-node": "^9.1.1", | ||
"typescript": "^4.2.3" | ||
} | ||
} |
Oops, something went wrong.