Skip to content

Commit

Permalink
added migration guide for v3
Browse files Browse the repository at this point in the history
  • Loading branch information
stevengill committed Jan 12, 2021
1 parent d4d7709 commit d20a942
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

strategy:
matrix:
node-version: [10.x, 12.x, 14.x]
node-version: [12.x, 14.x]

steps:
- uses: actions/checkout@v2
Expand Down
117 changes: 117 additions & 0 deletions docs/_tutorials/migration_v3.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
---
title: Migrating to V3
order: 2
slug: migration-v3
lang: en
layout: tutorial
permalink: /tutorial/migration-v3
---
# Migrating to v3.x

<div class="section-content">
This guide will walk you through the process of updating your app from using `@slack/[email protected]` to `@slack/[email protected]`. There are a few changes you'll need to make but for most apps, these changes can be applied in 5 - 15 minutes.

*Note: Make sure to checkout our [support schedule](#slackbolt1x-support-schedule) for `@slack/[email protected]` if you don't plan on upgrading right away*
</div>

---

### Org Wide App Installation Changes to InstallationStore & orgAuthorize

In [Bolt for JavaScript 2.5.0](https://github.com/slackapi/bolt-js/releases/tag/%40slack%2Fbolt%402.5.0), we introduced support for [org wide app installations](https://api.slack.com/enterprise/apps). To add support to your applications, two new methods were introduced to the Installation Store used during OAuth, `fetchOrgInstallation` & `storeOrgInstallation`. With `@slack/[email protected]`, we have dropped support for these two new methods to better align with Bolt for Python and Bolt for Java. See the code samples below for the recommended changes to migrate.

Before:

```javascript
installationStore: {
storeInstallation: async (installation) => {
// change the line below so it saves to your database
return await database.set(installation.team.id, installation);
},
fetchInstallation: async (InstallQuery) => {
// change the line below so it fetches from your database
return await database.get(InstallQuery.teamId);
},
storeOrgInstallation: async (installation) => {
// include this method if you want your app to support org wide installations
// change the line below so it saves to your database
return await database.set(installation.enterprise.id, installation);
},
fetchOrgInstallation: async (InstallQuery) => {
// include this method if you want your app to support org wide installations
// change the line below so it fetches from your database
return await database.get(InstallQuery.enterpriseId);
},
},
```

After:

```javascript
installationStore: {
storeInstallation: async (installation) => {
if (installation.isEnterpriseInstall) {
// support for org wide app installation
return await database.set(installation.enterprise.id, installation);
} else {
// single team app installation
return await database.set(installation.team.id, installation);
}
throw new Error('Failed saving installation data to installationStore');
},
fetchInstallation: async (InstallQuery) => {
// replace database.get so it fetches from your database
if (InstallQuery.isEnterpriseInstall && InstallQuery.enterpriseId !== undefined) {
// org wide app installation lookup
return await database.get(InstallQuery.enterpriseId);
}
if (InstallQuery.teamId !== undefined) {
// single team app installation lookup
return await database.get(InstallQuery.teamId);
}
throw new Error('Failed fetching installation');
},
},
```

Along with this change, we have also dropped support for `orgAuthorize`, and instead recommend developers to use `authorize` for both the single workspace installs and org wide app installs (if you are not using the built-in OAuth or providing a token when initializing App). See the code sample below for migration steps:

Before:

```javascript
const app = new App({ authorize: authorizeFn, orgAuthorize: orgAuthorizeFn, signingSecret: process.env.SLACK_SIGNING_SECRET });

const authorizeFn = async ({ teamId, enterpriseId}) => {
// Use teamId to fetch installation details from database
}

const orgAuthorizeFn = async ({ teamId, enterpriseId }) => {
// Use enterpriseId to fetch installation details from database
}
```

After:
```javascript
const app = new App({ authorize: authorizeFn, signingSecret: process.env.SLACK_SIGNING_SECRET });

const authorizeFn = async ({ teamId, enterpriseId, isEnterpriseInstall}) => {
// if isEnterpriseInstall is true, use enterpriseId to fetch installation details from database
// else, use teamId to fetch installation details from database
}
```

### HTTP Receiver as default

In `@slack/[email protected]`, we have introduced a new default [`HTTPReceiver`](https://github.com/slackapi/bolt-js/issues/670) which replaces the previous default `ExpressReceiver`. This will allow Bolt for JavaScript apps to easily work with other popular web frameworks (Hapi.js, Koa, etc). `ExpressReceiver` is still being shipped with Bolt for JavaScript and their may be some usecases that aren't supported by the new `HTTPReceiver` that `ExpressReceiver` supported. One usecase that isn't supported by `HTTPReceiver` is creating custom routes (ex: create a route to do a health check). For these usecases, we recommend continuing to use `ExpressReceiver` by importing it and create your own instance of it to pass into `App`. See [our documentation on adding custom http routes](https://slack.dev/bolt-js/concepts#custom-routes) for a code sample.

### @slack/bolt@2.x support schedule

`@slack/[email protected]` will be deprecated on **January 12th, 2020**. We will only implement **critical bug fixes** until the official end of life date and close non critical issues and pull requests, which is slated for **May 31st, 2021**. At this time, development will fully stop for `@slack/[email protected]` and all remaining open issues and pull requests will be closed.

### Minimum Node Version

`@slack/[email protected]` requires a minimum Node version of `12.13.0` and minimum npm version of `6.12.0` .

### Minimum TypeScript Version

As outlined in our [using TypeScript guide](https://slack.dev/bolt/tutorial/using-typescript), `@slack/[email protected]` requires a minimum TypeScript version of `4.1`.
2 changes: 1 addition & 1 deletion docs/_tutorials/using-typescript.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ This page helps describe how to use this package from a project that also uses T

### Minimum version

The latest major version of `@slack/bolt` is supported to build against a minimum TypeScript version of v3.7.
The latest major version of `@slack/bolt` is supported to build against a minimum TypeScript version of v4.1.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
"dist/**/*"
],
"engines": {
"node": ">=10.13.0",
"npm": ">=6.4.1"
"node": ">=12.13.0",
"npm": ">=6.12.0"
},
"scripts": {
"prepare": "npm run build",
Expand Down

0 comments on commit d20a942

Please sign in to comment.