O'Reilly logo

Node.js 8 the Right Way by Jim Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 by its document ID and includes the title of the book.

Our app will be called Better Book Bundle ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required