Giter Site home page Giter Site logo

Comments (5)

curtisallen avatar curtisallen commented on May 17, 2024 1

It would be useful to define middleware on a per matcher basis similar to express.js

router.METHOD(path, [callback, ...] callback)
You can provide multiple callbacks, and all are treated equally, and behave just like middleware

This way you could

slapp.command('/foo', myMiddleware, (msg) => {
  // do stuff
})

slapp.action('someaction', 'answer', myMiddleware, (msg) => {
 // do stuff
})

function myMiddleware(msg, next} {
  // do stuff
  next()
}

from bolt-js.

mbrevoort avatar mbrevoort commented on May 17, 2024

If we would add middleware for outgoing messages, how would we distinguish from incoming middleware which is currently slapp.use.

Something like this?

slapp.useIn and slapp.useOut
or
slapp.useIncoming and slapp.useOutgoing

from bolt-js.

mbrevoort avatar mbrevoort commented on May 17, 2024

Also, would this be triggered off of msg.say and msg.respond or a wrapper around slapp.client so that any call would proxy through the middleware allowing you to match in any criteria that matches certain API calls like chat.postMessage or reactions.add. If it was a proxy to slapp.client it would be a good way to capture and track metrics. Also, incoming middleware has access everything incoming as well.

from bolt-js.

selfcontained avatar selfcontained commented on May 17, 2024

more options: slapp.in() and slapp.out() - might be too vague?

from bolt-js.

shaydewael avatar shaydewael commented on May 17, 2024

In Bolt v1, we added the ability to pass a post-processing function into next() (which must call done()). Post-processing functions are called after all of the listener middleware on the way back up the execution chain (to do things like handle propagated errors)

from bolt-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.