You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current SDK API does not let middlewares/handlers access the server request/response that initiated the workflow.
Many frameworks, especially Express/Connect-like frameworks, rely on access to the req/res objects instead of globals. For example, attaching a DB connector or user info to the req object. Being able to access these objects will make integration with other frameworks significantly easier.
A few examples:
I use Pino for logging, with pino-http middleware that attaches req.log. Bolt's Logger API requires a global function that only has access to the msg argument and not the req/res context so I can't integrate my current logging solution.
I use Next.js and much of my code for API routes relies on being able to access req/res from the handler. Having access to req/res will allow me to reuse existing code.
The only workaround at the moment is to implement a custom receiver that wraps the Bolt app with AsyncLocalStorage, so that they can be accessed from inside the Bolt handlers.
I suggest providing access to req/res in Bolt middleware (app.use(...)), so that the user can use them to attach anything they'd like to the context object that Bolt passes around anyway.
What type of issue is this? (place an x in one of the [ ])
bug
enhancement (feature request)
question
documentation related
example code related
testing related
discussion
Requirements (place an x in each of the [ ])
I've read and understood the Contributing guidelines and have done my best effort to follow them.
We are planning to add custom properties to the receiver events: #759 With this change, you can relay any custom data as part of context object in App middleware/listeners. We don't have a pull request for it but I did a prototyping a few days ago here (the name customRequestProperties is too long, I will change it when making a pull request 😸 ).
We cannot tell when the new feature will be available but if everything goes well, the change can be merged with a few weeks and be included in v3.8 (the version after the next).
… Context objets (#1177)
* Fix#759#1109#1110 by adding custom properties in ReceiverEvent and Context objects
* Add AWS receiver implementation
* Fix bugs in SocketModeReceiver and add more tests
Description
The current SDK API does not let middlewares/handlers access the server request/response that initiated the workflow.
Many frameworks, especially Express/Connect-like frameworks, rely on access to the
req
/res
objects instead of globals. For example, attaching a DB connector or user info to thereq
object. Being able to access these objects will make integration with other frameworks significantly easier.A few examples:
pino-http
middleware that attachesreq.log
. Bolt's Logger API requires a global function that only has access to themsg
argument and not the req/res context so I can't integrate my current logging solution.The only workaround at the moment is to implement a custom receiver that wraps the Bolt app with
AsyncLocalStorage
, so that they can be accessed from inside the Bolt handlers.I suggest providing access to req/res in Bolt middleware (
app.use(...)
), so that the user can use them to attach anything they'd like to thecontext
object that Bolt passes around anyway.What type of issue is this? (place an
x
in one of the[ ]
)Requirements (place an
x
in each of the[ ]
)The text was updated successfully, but these errors were encountered: