concept handler in category hapi

This is an excerpt from Manning's book hapi.js in Action.
hapi is a full-featured framework, and there will be parts of it that you’ll probably never use in your applications. A few key components, however, underpin every single hapi app. This section introduces you to servers, connections, routes, handlers, and plugins, illustrated in figure 1.5.
You saw in chapter 1 that hapi apps are constructed by working with servers, routes, handlers, plugins, and your own business logic. In this chapter, you’ll see how those pieces come together. First I introduce a fictional brief for an API project that I’m going to build. Next I figure out the technical requirements and plan the API endpoints. Then I move on to implementing this in hapi step-by-step.
A further step I can take toward creating a clean and scalable application structure is to modularize the handlers for each of my routes. Because there’s no official way to organize your code in hapi, it’s up to you how to do this. Some people like to place each handler in a new module, and that can be a good approach for very large applications.
I like to group related handlers into a single module. In the case of the DinDin API, I only have one object that users work with: recipes. I place my handlers inside a directory called handlers. Inside handlers, I will create a single file called recipes.js. Here’s the directory tree (excluding node_modules) of the project at this point:
├── handlers │ └── recipes.js ├── index.js ├── package.json └── routes.jsThe recipes.js file will be the module where I keep my handlers for all the routes that interact with recipes. Each handler is an exported function that is identical to the handler previously in my routes module.