# slack-bolt-http-runner

> Bolt for JavaScript Extension - HTTP Runnner

Latest version **0.3.1** (published 2022-03-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install slack-bolt-http-runner
pnpm add slack-bolt-http-runner
yarn add slack-bolt-http-runner
bun add slack-bolt-http-runner
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.3.1 |
| Published | 2022-03-31 |
| First published | 2022-03-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 138.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Kazuhiro Sera |
| Maintainers | seratch |
| Keywords | Bolt, Slack, Slack Platform, Slack Bot, Slack API |

## Links

- npm: https://www.npmjs.com/package/slack-bolt-http-runner
- Repository: https://github.com/seratch/slack-bolt-extensions
- Homepage: https://github.com/seratch/slack-bolt-extensions#readme
- Issues: https://github.com/seratch/slack-bolt-extensions/issues
- npm.io page: https://npm.io/package/slack-bolt-http-runner

## Dependencies (4)

- [@slack/bolt](https://npm.io/package/@slack/bolt.md) ^3.11.0
- [@types/node](https://npm.io/package/@types/node.md) ^17.0.16
- [@slack/oauth](https://npm.io/package/@slack/oauth.md) ^2.5.1
- [@slack/logger](https://npm.io/package/@slack/logger.md) ^3.0.0

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 0.3.1 (latest) — 2022-03-31

## README

## Bolt for JavaScript Extension

### Getting Started

#### Create a new project

##### package.json

```json
{
  "name": "bolt-app-runner-example",
  "version": "0.1.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "rm -rf dist/ && tsc && npx ts-node src/index.ts"
  },
  "author": "Kazuhiro Sera",
  "license": "MIT",
  "dependencies": {
    "@slack/bolt": "^3.11.0",
    "@koa/router": "^10.1.1",
    "slack-bolt-http-runner": "^0.3.1"
  },
  "devDependencies": {
    "ts-node": "^10.5.0",
    "typescript": "^4.5.5"
  }
}
```

##### tsconfig.json

```json
{
  "compilerOptions": {
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowJs": true,
    "esModuleInterop": true,
    "outDir": "dist",
  },
  "include": ["src/**/*"]
}
```

##### Create a new Slack app at api.slack.com/apps

You can use the following App Manifest configuration for setting up a new app!

```yaml
display_information:
  name: bolt-oauth-test-app
features:
  bot_user:
    display_name: bolt-oauth-test-app
oauth_config:
  redirect_urls:
    - https://xxx.ngrok.io/slack/oauth_redirect
  scopes:
    bot:
      - commands
      - chat:write
      - app_mentions:read
settings:
  event_subscriptions:
    bot_events:
      - app_mention
  interactivity:
    is_enabled: true
  socket_mode_enabled: true
```

##### src/index.ts

```typescript
import http, { IncomingMessage, ServerResponse } from 'http';
import { URL } from 'url';
import { App, FileInstallationStore, LogLevel } from '@slack/bolt';
import { FileStateStore } from '@slack/oauth';
import { AppRunner } from 'slack-bolt-http-runner';

const runner = new AppRunner({
  logLevel: LogLevel.DEBUG,
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
  signingSecret: process.env.SLACK_SIGNING_SECRET!,
  clientId: process.env.SLACK_CLIENT_ID,
  clientSecret: process.env.SLACK_CLIENT_SECRET,
  scopes: ['commands', 'chat:write', 'app_mentions:read'],
  installationStore: new FileInstallationStore(),
  installerOptions: {
    directInstall: true,
    stateStore: new FileStateStore({}),
  },
});

const app = new App(runner.appOptions());

app.event('app_mention', async ({ say }) => {
  await say('Hi there!');
});

runner.setup(app);

(async () => {
  http.createServer((req: IncomingMessage, res: ServerResponse) => {
    const { pathname: path } = new URL(req.url as string, 'http://localhost');
    if (req.method === 'POST' && path === '/slack/events') {
      runner.handleEvents(req, res);
    } else if (req.method === 'GET' && path === '/slack/install') {
      runner.handleInstallPath(req, res);
    } else if (req.method === 'GET' && path === '/slack/oauth_redirect') {
      runner.handleCallback(req, res);
    } else {
      res.writeHead(404);
      res.end();
    }
  }).listen(3000);
  // eslint-disable-next-line no-console
  console.log('⚡️ Bolt app is running!');
})();
```

#### Run the app

```
export SLACK_CLIENT_ID=
export SLACK_CLIENT_SECRET=
export SLACK_SIGNING_SECRET=
export SLACK_STATE_SECRET=secret
npm start
# Visit https://{your public domain}/slack/install
```

---
_Source: https://npm.io/package/slack-bolt-http-runner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
