Building Enterprise JavaScript Applications
上QQ阅读APP看书,第一时间看更新

Modularizing our code

If you take a look inside the src/index.js file, you'll see that there are three top-level middleware functions—checkEmptyPayloadcheckContentTypeIsSet, and checkContentTypeIsJson—as well as an anonymous error handler function. These are prime candidates that we can extract into their own modules. So, let's get started!