After our Slack discussion I had an alternative idea I wanted to consider. Given that static typing in a distributed system is a major benefit of Temporal, maybe the runtime check for whether the signal is malformed or not belongs in the API layer, rather than the Workflow? This PR provides a way to do that using a handy useValidator() function that stores a map from signals to validator functions, and executes that validator function in the Express route.
Why not Express middleware? Primarily because I don't want users of temporal-rest to have to add middleware to the routes manually. Also because adding middleware would be tricky with the way temporal-rest is currently implemented.
After our Slack discussion I had an alternative idea I wanted to consider. Given that static typing in a distributed system is a major benefit of Temporal, maybe the runtime check for whether the signal is malformed or not belongs in the API layer, rather than the Workflow? This PR provides a way to do that using a handy
useValidator()
function that stores a map from signals to validator functions, and executes that validator function in the Express route.Why not Express middleware? Primarily because I don't want users of temporal-rest to have to add middleware to the routes manually. Also because adding middleware would be tricky with the way temporal-rest is currently implemented.