Wrapping Up

This chapter took us on a crash course through writing RESTful APIs with Express. You learned how to create an Express-based web service and how to modularize your endpoints into separate files. You saw how to add script commands to npm and how to use nodemon for restarting your service as you make changes.

We also dug deep into promises, a novel way for managing asynchronous code. We used the Q library to create and chain promises, and handle error cases where promises are revoked. You also saw how to convert Node.js-style functions—which expect a callback—into promise-generating functions.

Finally, we used ECMAScript Harmony’s generator functions with Q to write synchronous-looking code that’s actually asynchronous. Although ...

Get Node.js 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.