Functional middleware

1 · Gleb Bahmutov · Dec. 3, 2018, 5 a.m.
I had an Express server that was processing events from a payment system. For example, if a subscription was changed by the user, the payment system would send an event, which my server would process. The first step in every controller function was to take apart the request object to extract and check input parameters. If a parameter was missing or incorrect, the middleware would print a console message and return an error HTTP code. Otherwise everything would be ok, and the server would do some...