bolt-js
bolt-js copied to clipboard
[beta] Add app.function support
Summary
:wave: I am primarily looking for feedback on the approach to app.function support described below. I have been thinking of handling functions the way we handle Slack Events. app.function()
providing helpful sugar and gives access to utility methods success
and error
.
Secondarily, if the approach feels okay for now, I would propose to merge into main:feat-hermes
and do a beta release.
Formatting fixes are because of an aggressive format-on-save setting that I have been playing around with. 😞
This approach:
-
Piggy-backs off existing event handling:
- The
function_executed
payload is similar to other events. - Extended the
SlackEvent
to include a newFunctionExecutedEvent
(base-event.ts
) - ack() is done under the hood the way events are typically handed.
- The
-
Doesn't (yet) support multiple middlewares:
- I held off because I see this as a more advanced use case. I didn't see the point in implementing support for this at this early stage of beta testing and I have made a note to review this.
- Also, I'm struggling with the sense that there's tension conceptually between Bolt-land where we have middleware chains and 2.0 land where there are multiple Functions. It's certainly not mutually exclusive, but I want to iron out when/why someone would use mutiple middlewares vs. write multiple functions and I'd like to poll the group on how you're all thinking about this.
Testing
- Symlink - (
npm link
) - Clone the
bolt-functions
app template which should hopefully speed things up a little - Symlink -
cd bolt-functions && npm link @slack/bolt
- Follow the instructions in the bolt-functions/README
Requirements (place an x
in each [ ]
)
- [x] I've read and understood the Contributing Guidelines and have done my best effort to follow them.
- [x] I've read and agree to the Code of Conduct.
Codecov Report
:exclamation: No coverage uploaded for pull request base (
feat-hermes@fdac330
). Click here to learn what that means. The diff coverage isn/a
.
@@ Coverage Diff @@
## feat-hermes #1383 +/- ##
==============================================
Coverage ? 71.25%
==============================================
Files ? 19
Lines ? 1590
Branches ? 462
==============================================
Hits ? 1133
Misses ? 357
Partials ? 100
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update fdac330...6336823. Read the comment docs.
Closing this PR as feedback for changes including test coverage have been incorporated into https://github.com/slackapi/bolt-js/pull/1567