Adding Search APIs

With the basic structure of the web services project in place, it’s time to start adding some APIs. First we’ll add APIs for searching the books index, and then we’ll add APIs for creating and manipulating book bundles.

To begin, open a terminal to your b4 project directory and add a new subdirectory called lib. This will house the individual modules that contribute API code for the service.

Next, open a text editor and enter the following skeleton code for the search APIs.

​ ​/**​
​ ​ * Provides API endpoints for searching the books index.​
​ ​ */​
​ ​'use strict'​;
​ ​const​ request = require(​'request'​);
​ module.exports = (app, es) => {
​ 
​ 

Get Node.js 8 the Right Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.