O'Reilly logo

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

RESTful Web API Design with Node.js

Book Description

Design and implement comprehensive RESTful solutions in Node.js

In Detail

In this era of cloud computing, every data provisioning solution is built in a scalable and fail-safe way. Thus, when building RESTful services, the right choice of the underlying platform is vital. Node.js, with its asynchronous, event-driven architecture, is just the right choice to build RESTful APIs.

This book will be your step-by-step guide in the RESTful world of Node.js. It starts with the implementation of a simple HTTP handler application and follows its evolution to a completed RESTful service solution, which introduces you to the best practices in developing RESTful services.

What You Will Learn

  • Learn about NoSQL data stores and integrate MongoDB in your Node.js application with Mongoose
  • Install, develop, and test your own Node.js user modules
  • Eliminate third-party dependencies in your tests with mocking
  • Comprehend the differences between an HTTP and RESTful application
  • Optimize RESTful service URI routing with best practices
  • Secure your services with NoSQL database integration within Node.js applications

Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

Table of Contents

  1. RESTful Web API Design with Node.js
    1. Table of Contents
    2. RESTful Web API Design with Node.js
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers, and more
        1. Why subscribe?
        2. Free access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the example code
        2. Errata
        3. Piracy
        4. Questions
    8. 1. REST – What You Didn't Know
      1. A brief history of REST
        1. Principle 1 – everything is a resource
        2. Principle 2 – each resource is identifiable by a unique identifier
        3. Principle 3 – use the standard HTTP methods
        4. Principle 4 – resources can have multiple representations
        5. Principle 5 – communicate statelessly
      2. The REST goals
        1. Separation of the representation and the resource
        2. Visibility
        3. Reliability
        4. Scalability and performance
      3. Working with WADL
      4. Taking advantage of the existing infrastructure
      5. Summary
    9. 2. Getting Started with Node.js
      1. Installing Node.js
        1. Node Package Manager
      2. Installing the Express framework and other modules
      3. Setting up a development environment
      4. Handling HTTP requests
      5. Modularizing code
      6. Testing Node.js
        1. Working with mock objects
      7. Deploying an application
        1. Nodejitsu
        2. Microsoft Azure
      8. Self-test questions
      9. Summary
    10. 3. Building a Typical Web API
      1. Specifying the API
      2. Implementing routes
      3. Testing the API
      4. Content negotiation
      5. Cross-origin resource sharing
      6. API versioning
      7. Self-test questions
      8. Summary
    11. 4. Using NoSQL Databases
      1. Key/value store – LevelDB
      2. Document store – MongoDB
      3. Database modeling with Mongoose
      4. Testing a NoSQL database solution
      5. Content delivery network
      6. Self-test questions
      7. Summary
    12. 5. Implementing a Full-fledged RESTful Service
      1. Extensibility and versioning
      2. Working with arbitrary data
      3. Linking
      4. Implementing paging and filtering
      5. Caching
      6. Discovering and exploring RESTful services
      7. Self-test questions
      8. Summary
    13. 6. Keeping the Bad Guys Out
      1. Authentication
        1. Basic authentication
        2. Passport
          1. Passport's basic authentication strategy
          2. Passport's third-party authentication strategies
      2. Authorization
      3. Transport Layer Security
      4. Self-test questions
      5. Summary
    14. Index