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 this ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access