Book Image

Getting Started with hapi.js

Book Image

Getting Started with hapi.js

Overview of this book

This book will introduce hapi.js and walk you through the creation of your first working application using the out-of-the-box features hapi.js provides. Packed with real-world problems and examples, this book introduces some of the basic concepts of hapi.js and Node.js and takes you through the typical journey you'll face when developing an application. Starting with easier concepts such as routing requests, building APIs serving JSON, using templates to build websites and applications, and connecting databases, we then move on to more complex problems such as authentication, model validation, caching, and techniques for structuring your codebase to scale gracefully. You will also develop skills to ensure your application's reliability through testing, code coverage, and logging. By the end of this book, you'll be equipped with all the skills you need to build your first fully featured application. This book will be invaluable if you are investigating Node.js frameworks or planning on using hapi.js in your next project.
Table of Contents (15 chapters)
Getting Started with hapi.js
Credits
Foreword
About the Author
About the Reviewer
www.PacktPub.com
Preface
5
Securing Applications with Authentication and Authorization
Index

Structuring applications


The way to structure an application is sometimes ignored when initially evaluating a framework in favor of how quickly we can get a 'hello world' example working, or the ability to quickly add features. In my opinion, this is a huge mistake as this borrows time later on in an application's life cycle; this is often known as technical debt. It leads to frustration, poor developer experience, and to a lot of required refactors that often degrade code quality. Furthermore, as teams scale, poor application infrastructure leads to much slower progress—adding features, longer time in getting new developers up-to-speed, and a higher tendency to create bugs with unknown side effects with every addition, change, or deletion of code. It is a well-documented fact that the number of bugs climbs linearly with the lines of code in a codebase, and it's understandably so—more the lines of code, more the opportunities a developer gets to make a mistake or create what I like to call...