Caio Ribeiro Pereira
Caio Ribeiro Pereira
São Vicente - SP, São Paulo, Brazil
Any source code or other supplementary materials referenced by the author in this text is available to readers at www.apress.com . For detailed information about how to locate your book’s source code, go to www.apress.com/source-code/ .
ISBN 978-1-4842-2441-0
e-ISBN 978-1-4842-2442-7
DOI 10.1007/978-1-4842-2442-7
Library of Congress Control Number: 2016961314
© Caio Ribeiro Pereira 2016
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein.
Printed on acid-free paper
I dedicate this book to my family who always supports me and has motivated me since the beginning of my life.
We live in a time in which the majority of users use different types of devices to connect to the Internet. The most popular devices are smartphones, tablets, and notebooks. Developing systems for different types of devices requires the work of building web services, also known by the name of application program interfaces (APIs).
Basically, the APIs are back-end systems that are designed to work only with data in a centralized manner, allowing client-side applications to be developed separately, to have a unique interface to the final user. These client-side applications are typically mobile apps, desktop applications, or web apps.
Since 2010 Node.js has increasingly proven to be an excellent platform to solve many problems, especially for building REST APIs. The single-thread architecture that performs nonblocking I/O running on top of JavaScript, which is a ubiquitous language in all current browsers, showed good performance in the processing of many kinds of applications. Some large companies, such as LinkedIn and PayPal, have significantly reduced expenses with servers migrating some of their projects to Node.js.
In addition, another advantage of using Node.js, which captivated many developers, is the short learning curve. After all, anyone who has worked with web development already has at least a basic understanding of the JavaScript language.
This book is intended for developers who have at least a basic knowledge of JavaScript and, especially, those who understand object-oriented programming (OOP), a little bit of client-server architecture, and those with an understanding of the main characteristics of REST APIs.
Mastering these concepts, or at minimum a basic knowledge of them, is essential to fully understand this book.
All the code in this book is written using the latest JavaScript implementation, the ECMAScript 2015 (also called ECMAScript 6, or ES6).
Throughout the book, many concepts and codes are going to be presented for you to learn through practice all the theoretical parts of this book. It will guide you in a didactic way in the development of two projects (an API and a web client application), which in the end are both integrated to work as a single project.
It is highly recommended that you follow the book’s instructions step by step, so in the end you can complete the project correctly.
Special thanks go to Mrs. Charlotte Bento de Carvalho, my cousin Cláudio Souza, my friends Leandro Alvares da Costa and Bruno Alvares da Costa, Paulo Silveira, and Adriano Almeida. They have had an important role in my life, influencing me to be who I am today, and consequently, to write this book.
Thanks to all the readers from Underground WebDev ( https://udgwebdev.com ); after all, the essence of this book is based on many posts from this blog.
Finally, thank you, dear reader, for purchasing this book.
Caio Ribeiro Pereira is a software engineer from Brazil who love works with Node.js, JavaScript, Meteor, Ruby On Rails, DevOps, and front-end stuffs. He has a bacharelor’s degree in Information Systems, author of the blog https://udgwebdev.com , creator of the DevFreeBooks ( https://devfreebooks.github.io ) and DevFreeCasts ( https://devfreecasts.github.io ), and is actively engaged in many local meet-ups including NodeBr, DevInSantos, Meteor Brazil and JavaScript Brazil.
Massimo Nardone has more than 22 years of experience in security, Web/ and mobile development, and cloud and IT architecture. His true IT passions are security and Android.
He has been programming and teaching how to program with Android, Perl, PHP, Java, VB, Python, C/C++, and MySQL for more than 20 years. He holds a master’s of science degree in Computing Science from the University of Salerno, Italy.
He has worked as a project manager, software engineer, research engineer, chief security architect, information security manager, PCI/SCADA auditor, and senior lead IT security/cloud/SCADA architect for many years.
His technical skills include: security, Android, cloud, Java, MySQL, Drupal, Cobol, Perl, Web and mobile development, MongoDB, D3, Joomla, Couchbase, C/C++, WebGL, Python, Pro Rails, Django CMS, Jekyll, Scratch, and more.
He currently works as Chief Information Security Officer for Cargotec Oyj.
He worked as visiting lecturer and supervisor for exercises at the Networking Laboratory of the Helsinki University of Technology (Aalto University). He holds four international patents (PKI, SIP, SAML, and Proxy areas).
Massimo has reviewed more than 40 IT books for different publishing companies and he is the coauthor of Pro Android Games (Apress, 2015).