Thesaurus

A Web Design & Development Blog

Node.js Server

Node.js as a server using Hapi framework

I have been wanting to dive into node.js for a while and I finally did this week. Using Hapi as a framework I was able to start up a simple server for static files.

After reading through a bit of the node.js documentation, I decided it would be best to start out with a framework to get an idea of what could be done. I checked out a few frameworks including node boilerplate, mean.io, and others, I found Hapi. Because, I usually do not use javascript templating languages, so I wanted a server that could serve up a simple one page index.html file. Hapi does that perfectly.

The documentation on the happy site is easy to follow and concise, so as to not regurgitate Hapi. Super simple to get started and not as complex as some other node.js server packages.

Few Tips

Don’t name your new directory hapi, or you will end up trying to make hapi a dependency or itself … woops

The documentation contains both prototype and classical javascript. I would recommend sticking with one (in my opinion classical).

You will need node.js and node package manager (npm) installed first.

This is super exciting stuff for front end developers, so try it!

Files

Here is my index.js file, that would serve up index.html on http://localhost:8080/

This page could run without my apache server, however this server does not have the google’s V8 engine installed.

So check out Hapi to get up and running with a node server quickly and easily

Leave a Reply

Your email address will not be published. Required fields are marked *