Quantcast
Channel: Iflexion Web Development Blog » rich applications
Viewing all articles
Browse latest Browse all 4

Application Development: Hapi.js is a professional node.js server framework

0
0

This month we created REST service as a project. Technical requirements were to use Hapi.js architecture [http://hapijs.com] to implement a solution. It’s a better alternative for well-known express framework. The problem with express is its simplicity in design. One of the goals of its authors was to make it as simple as possible. But in real life it’s not a criteria. You have to spend a lot of time to configure all components you need for your application. E.g., getting raw HTTP request content needs particular middleware attached into some point of HTTP request/response chain. That’s why a lot of teams and projects choose something more robust. Hapi provides very good balance between simplicity and power.

Beyond express framework

Hapi was created by Walmart software development team to hold under control their black-friday storm. By the way, this fact shows us one more time that node.js platform has both high performance and robust Application Development approaches. All standard tasks are done by Hapi in the same easy way as express or other server framework. If you already have some experience with building HTTP server by express, it doesn’t force you to learn anything special to start using Hapi. On the other hand, it doesn’t need to spend a lot of time for neither configuration, nor coding, to have any custom solution. Hapi uses standard points in request/response workflow and its extensions. It’s a bit more complicated structure at line of architecture development. But all such things are hidden on implementation side. We don’t need to spend a lot of time to look into all implementation details to use a plugin in the application.

 Plugins

There are a lot of plugins to support all features for building regular web site or REST service. For authentication and authorization you can register and configure any scheme Basic, JWT, OAuth, or even several ones for different resources in terms of the same project. E.g., JWT for public area and Basic auth for administration interface or online test and documentation of REST service. There is hapi-swagger plugin for that. There are more plugins for logging, input validation, HTTP reply helpers, integration with modern technologies like react.js framework and AMQP messaging broker, stateful sessions and internationalization, caching, etc. Plugins in express architecture are called middleware. To use them you need add it globally for all endpoints or insert before each handler it’s actually used. It’s too much routine work to implement and support last case. And it has no sense, actually, in case of real big project with plethora of endpoints. Hapi needs just to register the plugin once. The configuration of the plugin may be provided right in the registration point.

 Platform

As express looks sexy as a node.js world as a whole, hapi is rather pragmatic professional tool without extra hype. There are tutorials, videos, gists and examples and even 2 books about hapi and its features and approaches you can use to learn hapi in classic way: hapi.js in Action and Developing a hapi Edge.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images