Code Log 062616 — Oh, Hapi Day

Code Log

Currently on my web development journey, I am investigating JavaScript and attempting to get into the mind of someone who willingly uses this language regularly, and maybe even the ones who actually prefer it. (Crazy thought, I know.)

Last we left, I ran through a course and learned a lot about structuring a web app with Meteor. Today, I’m going to be delving into Hapi: a configuration-centric framework, and Joi: an object schema description language and validator for JavaScript objects. (Yeah, I’m not entirely sure what that means, either.)

I’ll be using the Hapi.js course on Nodecasts.io and the Make Me Hapi NodeSchool module.

My goal for the day is to not dream too wistfully about Rails routes and controllers. If that works out, my secondary goal is to get an app built.

Hapi Coding.

Update #1 — npm understands

spelling is hard

So, in order to use Hapi, I had to include it in my project. I’ve used node and npm (node package manager) plenty before, but for some reason I usually forget to use the save flag.

That save flag is used to track what dependencies the app uses, although it may not be enough for a production level app. Food for thought.

Update #2 — nodemon

Every time I would change the server side code (which is ALL THE TIME in a course about changing the server code), I would have to restart the web server. Since I’m not about the “work harder, not smarter” life, I installed the nodemon package.

To use, instead of typing

node .

to start the app, type

nodemon .

and nodemon automatically restarts the server if it notes any changes in the app.

Smart work.

Update #3: It’s Over

…it’s finally done.

Well, almost. Make Me Hapi got the best of me. I couldn’t wrap my head around the last exercise, so I’ll dig into it later this week.

I can reword the earlier definitions though. Hapi: It’s a router that can handle dynamic data. Joi: Validations — makes sure the app has the right information before it shows a requested page.

So, success.