concept recipe in category hapi

This is an excerpt from Manning's book hapi.js in Action.
Hey there, Developer. I’ve just gotten word that I’ve been hired to work on a new project. Our client Mrs. Bigbucks has an idea for a startup called DinDin. She says it’s going to be the next Pinterest and wants us to build a prototype for the API. So far, all I’ve heard is the elevator pitch: DinDin is a social network for food. Users can create a profile and upload their own recipes. Users can also search for recipes that match their favorite ingredients. When a user likes a recipe they can award a star. Collect enough stars and amateur chefs can become mini-celebs!
Listing 2.10. routes.js: using this.db to access database object
'use strict'; module.exports = [{ method: 'GET', path: '/api/recipes', handler: function (request, reply) { let sql = 'SELECT * FROM recipes'; const params = []; if (request.query.cuisine) { sql += ' WHERE cuisine = ?'; params.push(request.query.cuisine); } this.db.all(sql, params, (err, results) => { if (err) { throw err; } reply(results); }); } }, { method: 'GET', path: '/api/recipes/{id}', handler: function (request, reply) { this.db.get('SELECT * FROM recipes WHERE id = ?', [request.params.id], (err, result) => { if (err) { throw err; } if (typeof result !== 'undefined') { reply(result); } else { reply('Not found').code(404); } }); } }];
To create a recipe using the DinDin API, a user sends a POST request to endpoint C, along with a JSON payload (see figure 2.11). For example: