Picture of the cover of the book
Getting Started with hapi.js

Learn to build well-structured, testable applications and APIs using hapi.js

Picture of the cover of the book

Buy it on Packt Buy it on Amazon

Contained Inside...

7 Chapters

Each chapter is carefully crafted in the right order to take you on your journey to build production ready applications with hapi.js.

30+ Code Examples

Learn by example, with more than 30 working examples you can run, modify and expand on. Each with a detailed explanation will help you get up to speed quickly.

156 Pages

Each page contains a wealth of information to give every reader an in depth knowledge of the inner workings of hapi.js and how to use it.

Topics Covered


  • Chapter One

    Introducing hapi.js

    This first chapter serves as an introduction to hapi.js and some prerequisite learning of Node.js. It explains what hapi.js is, who created it, why it needs to exist, and how to create a simple hapi.js server.

  • Chapter Two

    Adding Functionality by Routing Requests

    This the beginning of your journey of building applications with hapi.js. It will cover some basics, such as routing and building APIs, websites, and applications with hapi.js, and will also cover some differences in design compared to other Node.js-based frameworks.

  • Chapter Three

    Structuring your Codebase with Plugins

    This chapter introduces the plugin API in hapi.js, which is one of its core features. It will walk you through how to simplify an application structure gracefully using plugins and also cover server orchestration using modules from the hapi.js ecosystem.

  • Chapter Four

    Adding Tests and the Importance of 100% Code Coverage

    This chapter explores the importance of adding tests to an application. It will introduce you to some of the testing tools available in the hapi.js ecosystem and also guide you toward getting 100% code coverage with your tests.

  • Chapter Five

    Security with Authentication and Authorization

    This chapter takes a deep dive into how authentication works in hapi.js with practical examples of different authentication protocols, including social logins. It also demonstrates scopes and how to use them

  • Chapter Six

    The joi of Reusable Validation

    This chapter deals with the topic of validation in applications using the joi validation library from the hapi.js ecosystem. It covers how to validate objects and route configurations and how to reuse this to generate documentation for applications.

  • Chapter Seven

    Making Your Application Production Ready

    This chapter covers multiple topics to leave you ready to build your first application, such as integrating popular databases and adding caching and logging to applications to help scale an application as well as give it visibility when running in a production environment. It also covers a variety of other sources to continue learning more about hapi.js.

About the author


Profile image of author

John Brett is a software engineer who is passionate about new technologies, open source software, education, and travelling the world. Starting out in Ireland with a first class honours Bachelor's Degree in Computer Science and Software Engineering, he went on to join IBM through their premier internship Extreme Blue and later became part of the IBM Software Group focusing on collaboration software. There, John worked mainly with PHP, JavaScript and in his spare time with Node.js.

Later, he moved to a growing SAAS company called D4H Technologies, leading the development of tools to aid emergency response teams around world, all from a lighthouse in Dublin, Ireland. Here, John got more exposure to Node.js and led D4H's first venture into Node.js using hapi.js, later joining the hapi.js core team.