Writing Modular Express Services

Throughout the remainder of the chapter, we’re going to build a RESTful web service with Express for creating and managing book bundles. These are basically named reading lists. Here’s an example of a book bundle:

​ {
​  ​"name"​: ​"light reading"​,
​  ​"books"​: [{
​  ​"id"​: ​"pg132"​,
​  ​"title"​: ​"The Art of War"​
​  },{
​  ​"id"​: ​"pg2680"​,
​  ​"title"​: ​"Meditations"​,
​  },{
​  ​"id"​: ​"pg6456"​,
​  ​"title"​: ​"Public Opinion"​
​  }]
​ }

The name field is a user-defined string to identify the list. Names do not have to be unique. The books field contains a list of the books in that bundle. Each book is identified ...

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.