Category: Hapijs

  • Hapijs – views

    There are two ways for rendering a view by using reply.view()interface, or by using view handler. – reply.view() [cc lang=”javascript”]server.route({ method: ‘GET’, path: ‘/’, handler: function (request, reply) { reply.view(‘index’); } });[/cc]   if you want to pass context to reply.view(), pass an object as the second parameter, for example: [cc lang=”javascript”]server.route({ method: ‘GET’, path: […]

  • Hapijs – Adding Routes in HapiJs

    In this blog, we will learn how to Adding routes in Hapi. Steps. – Define the path. – Define the method. – Define the handler. let’s see an example of it [cc lang=”javascript”] var Hapi = require(‘hapi’); var server = new Hapi.Server(); server.connection({ port: 3000 }); server.route({ method: ‘GET’, // define the method path: ‘/’, […]

  • Hapijs – Plugins

    hapi has dozens of plugin system. like , Authentication, Documentation, Localization/Internationalization, Logging/Metrics, Messaging, Security, Session, Templating, Utility, Validation…. – you can write your own plugin. – plugins are objects with a register function, and has a signature function (server, options, next). – register function has an attributes object. – this object provides some additional information […]