Kanika Sud
Kanika, Chandigarh, India
Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the books product page, located at www.apress.com/9781484258040 . For more detailed information, please visit http://www.apress.com/source-code .
ISBN 978-1-4842-5804-0 e-ISBN 978-1-4842-5805-7
https://doi.org/10.1007/978-1-4842-5805-7
Kanika Sud 2020
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.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective laws and regulations and therefore free for general use.
The publisher, the authors and the editors are safe to assume that the advice and information in this book are believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza, New York, NY 10004. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
Introduction
Research thats what brought me to hapi. Flexibility, maintainability, and scalability are core areas when choosing a framework. I was new to Node.js, and I thought any framework I chose would be a huge learning curve. hapi was a pleasant surprise, because it gets you up and running in no time. If youre new to JavaScript, worry not weve covered the ground well. This book is to make sure that you work from the ground up and have a solid foundation in hapi, and if youre familiar with JavaScript, you can always revisit the language and take a walk through advanced concepts like promises and others. We havent covered any concepts like introducing SSL , node inspector, CORS, and so on. These are independent topics, and various informative articles about these are found on the Internet. What weve focused on is building a story out of a framework, getting all the major corners secured, so that the eager developer is confident enough to explore more and has his fundamentals right.
Before you step into code and make apps, services, and/or your next big project, be sure of why you wish to learn coding. That might not seem the right fit for an introduction to a technical book, but to all my learners, the joy of coding can really be assessed if youre sure of why youre learning, and before you get caught in an industry where timelines can get the better of you, its only fair to yourself to keep the spark of research alive.
Acknowledgments
I am indebted to my parents for the kind of support Ive received all my life. Its a privilege to be supported by members of the family when youre busy working on your dreams.
This is in loving memory of my mother, who wanted me to live my dreams, all my life. Ive also had the privilege to work with some of the best in the industry, whose collaboration and inspiration laid the road ahead for my learning. This book, and hopefully many more to come, is because of the best in business Apress, and their wonderful team including, but not limited to, James, Nancy, Louise, and Alexander. Their patience, guidance, and step-by-step feedback for the narrative and technical assessment were invaluable.
About the Author and About the Technical Reviewer
About the Author
Kanika Sud
has been working on the Web for over 10 years now. Her work spans enterprise CMSs in Java and backend technologies in LAMP stack and MEAN stack. She has also worked on open source ecommerce CMSs and UX strategy. Solution design remains her key favorite, while market research on mobile apps and plugins led her to experiment with a bootstrapped startup in technology, called Codnostic Solutions. Find her on LinkedIn: www.linkedin.com/in/kanikasud .
About the Technical Reviewer
Alexander Chinedu Nnakwue
has a background in mechanical engineering from the University of Ibadan, Nigeria, and has been a front-end developer for over 3 years working on both web and mobile technologies. He also has experience as a technical author, writer, and reviewer. He enjoys programming for the Web, and occasionally, you can also find him playing soccer. He was born in Benin City and is currently based in Lagos, Nigeria.
Kanika Sud 2020
K. Sud Practical hapi https://doi.org/10.1007/978-1-4842-5805-7_1
1. Understanding REST APIs
Kanika Sud
(1)
Kanika, Chandigarh, India
This chapter throws light on building representational state transfer (REST)-based services. Since well be learning RESTful Web Services through our chosen language, Node.js, and using an awesome framework like hapi, its first necessary to introduce ourselves to REST APIs and then understand how hapi makes the process easy. Along the ride, well learn about HTTP verbs, resource handling, stateless constraints, and tying it all into representational state transfer.
First Steps
If you really need to know why were all talking about APIs in the early twenty-first century, you need to understand that while developed software is what the end user sees, at the back end, its really data exchange. And who is exchanging that data? Two or multiple entities and layers of software. What is the format of such data? XML was a very popular data exchange format in the early stages of data talk and while we look into the reasons of using JSON as a data exchange format in our capstone project later, we need to understand how typical data exchange looks and how its different from the presentation layer.