bolt-js icon indicating copy to clipboard operation
bolt-js copied to clipboard

[beta] Add app.function support

Open srajiang opened this issue 2 years ago • 1 comments

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 new FunctionExecutedEvent (base-event.ts)
    • ack() is done under the hood the way events are typically handed.
  • 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

  1. Symlink - (npm link)
  2. Clone the bolt-functions app template which should hopefully speed things up a little
  3. Symlink - cd bolt-functions && npm link @slack/bolt
  4. Follow the instructions in the bolt-functions/README

Requirements (place an x in each [ ])

srajiang avatar Mar 23 '22 00:03 srajiang

Codecov Report

:exclamation: No coverage uploaded for pull request base (feat-hermes@fdac330). Click here to learn what that means. The diff coverage is n/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.

codecov[bot] avatar Mar 23 '22 00:03 codecov[bot]

Closing this PR as feedback for changes including test coverage have been incorporated into https://github.com/slackapi/bolt-js/pull/1567

srajiang avatar Aug 30 '22 18:08 srajiang