You are previewing RESTful Web API Design with Node.js - Second Edition.
O'Reilly logo
RESTful Web API Design with Node.js - Second Edition

Book Description

Design and implement efficient RESTful solutions with this practical hands-on guide

About This Book

  • Create a fully featured RESTful API solution from scratch.

  • Learn how to leverage Node.JS, Express, MongoDB and NoSQL datastores to give an extra edge to your REST API design.

  • Use this practical guide to integrate MongoDB in your Node.js application.

  • Who This Book Is For

    The ideal target audience for this book is web developers who have some experience with RESTful services. Familiarity with basic JavaScript programming techniques is required. No prior experience with Node.JS or Express.js is required.

    What You Will Learn

  • Install, develop, and test your own Node.js user modules

  • Comprehend the differences between an HTTP and a RESTful application

  • Optimize RESTful service URI routing with best practices

  • Eliminate third-party dependencies in your tests with mocking

  • Learn about NoSQL data stores and integrate MongoDB in your Node.js application with Mongoose

  • Secure your services with NoSQL database integration within Node.js applications

  • Enrich your development skills to create scalable, server-side, RESTful applications based on the Node.js platform

  • 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 for the underlying platform is vital. Node.js, with its asynchronous, event-driven architecture, is exactly the right choice to build RESTful APIs.

    This book will help you enrich your development skills to create scalable, server-side, RESTful applications based on the Node.js platform.

    Starting with the fundamentals of REST, you will understand why RESTful web services are better data provisioning solution than other technologies. You will start setting up a development environment by installing Node.js, Express.js, and other modules. Next, you will write a simple HTTP request handler and create and test Node.js modules using automated tests and mock objects. You will then have to choose the most appropriate data storage type, having options between a key/value or document data store, and also you will implement automated tests for it. This module will evolve chapter by chapter until it turns into a full-fledged and secure Restful service.

    Style and approach

    Create state of the art RESTful API solutions leveraging Node.JS 4.x.

    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 code file.

    Table of Contents

    1. RESTful Web API Design with Node.js - Second Edition
      1. RESTful Web API Design with Node.js - Second Edition
      2. Credits
      3. About the Author
      4. About the Reviewer
      5. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      6. 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
      7. 1. REST – What You Did Not Know
        1. REST fundamentals
          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
          1. Taking advantage of the existing infrastructure
        4. Summary
      8. 2. Getting Started with Node.js
        1. Installing Node.js
        2. Node Package Manager
          1. Installing the Express framework and other modules
          2. Setting up a development environment
          3. Handling HTTP requests
          4. Modularizing code
          5. Testing Node.js
          6. Working with mock objects
        3. Deploying an application
        4. Microsoft Azure
          1. Nodejitsu
        5. Self-test questions
        6. Summary
      9. 3. Building a Typical Web API
        1. Specifying the API
        2. Implementing routes
        3. Querying the API
        4. Content negotiation
        5. Cross-origin resource sharing
        6. API versioning
        7. Self-test questions
        8. Summary
      10. 4. Using NoSQL Databases
        1. Key/value store - LevelDB
        2. Document store - MongoDB
        3. Database modeling with Mongoose
        4. Testing a Mongoose model with Mocha
        5. Creating a user-defined model around a Mongoose model
        6. Wiring up a NoSQL database module to Express
        7. Content delivery network
        8. Self-test questions
        9. Summary
      11. 5. Implementing a Fully-Fledged RESTful Service
        1. Extensibility and versioning
        2. Working with arbitrary data
        3. Linking
        4. Implementing paging and filtering
        5. Caching
        6. Supplying the Cache-Control header in Express applications
        7. Discovering and exploring RESTful services
        8. Self-test questions
        9. Summary
      12. 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