1 of 20

Hapi-Together

@DealerTire

Conquering the Monolithic Application

2 of 20

Sean Grasso

Senior Web Developer

sgrasso

@spgrasso

sgrasso@dealertire.com

3 of 20

Manages replacement-tire and maintenance-parts programs for more than 10,000 car dealers, spanning two dozen automotive brands.

Uses a refined mix of old-fashioned salesmanship and newfangled technology.

Dealer Tire revs up long-vacant Victory Center

-- cleveland.com

4 of 20

Two Primary Sites

B2B order portal and tools for car dealerships

dealertire.com

B2C website

rightturn.com

5 of 20

6 of 20

project/config/� routes.js� settings.js� index.js� controllers/� index.js� movies.js� models/� index.js� movie.js� repositories/� index.js� movie.js� views/� index.jade� movies/� index.jade� tests/ controllers/� index.js� models/� index.js� repositories/� index.js� index.js� package.json

7 of 20

8 of 20

Hapi enables developers to focus on writing reusable application

logic instead of spending time building infrastructure.

9 of 20

Hapi was created around the idea that configuration is better than code, that business logic must be isolated from the transport layer, and that native node constructs like buffers and stream should be supported as first class objects. But most importantly, it was created to provide a modern, comprehensive environment in which as much of the effort is spent delivering business value.

- Eran Hammer

https://hueniverse.com/hapi-a-prologue-842e166fdd08

10 of 20

Hold onto your butts!

Logical groups of web application sections handled as plugins.

Essentially, decoupling individual pieces of application logic and managing them as typical dependencies with a Private NPM.

By modularizing in this way, each plugin could be per team, and in its own repository that the team owns and works on.

11 of 20

Hapi plugins can be thought of as isolated sandboxes communicating

to each other but not

knowing anything about

the other.

12 of 20

Take over the World!

Discover the ability to control logic through configuration.

Hapi route config, pre methods, extension methods and request lifecycle as a whole.

Tip

You also can decorate the server, request and reply objects with your own functions.

Tip

Hapi lets you extend any of the request’s lifecycle phases.

Tip

Hapi modules like Glue and Rejoice allow us to run a server completely through configuration.

Tip

You have the ability to define settings at an application or plugin level.

13 of 20

What does this isolation look like?

  • Clone Repogithub.com/sgrasso/hapi-together-tutorial.git
  • npm install
  • Go!Follow the instructions for Step 1 within the README.md file.

Example #1

14 of 20

Theory of Everything

What if it was simple and scalable and FAST! Anything and Everything can be a module and served independent of the other.

15 of 20

Built out of private and public modules (plugins), then deployed as a single entity knowing of it’s own dependencies to operate.

Micro Services? �How about Micro Applications?

APP

Private Modules

Public Modules

Micro Application

16 of 20

So wait I can serve a different route version on the fly?

  • WhatModifying a request to serve different handlers.
  • HowThis can be based on a configuration object with permissions.
  • Where

Look at the request lifecycle and extending that behavior.

Example #2

17 of 20

Request Life Cycle

Let’s Plugins extend functionality of the current request.

Be Careful! Ext. points are executed in the order plugins are registered, which is asynchronous...

18 of 20

  • WhatModifying a request to serve different handlers.
  • HowThis can be based on a configuration object with permissions.
  • Where

Look at the request lifecycle and extending that behavior.

Example #3

19 of 20

What’s Left?

Host your modules and micro applications privately.

  • Private NPM Enterprise
  • Artifactory

Deploy using a container environment

  • Scallability
  • Isolate changes

20 of 20

Thanks For Coming!

  • Questions?
  • Special Thanks!
    • Kyle McKee
    • Cleveland Javascript User Group

sgrasso�@spgrasso�sgrasso@dealertire.com

www.seangrasso.com

Slides - http://bit.ly/2onH3HD