JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q20544F
  • License ISC

Auto load hapi modules

Package Exports

  • hapiboot

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (hapiboot) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

HapiBoot

HapiBoot is a small helper library to load modules when you have a large and structured Api.

HapiBoot loads your modules from a given path and registers them as plugins. So you can easily structure your api and manage dependencies.

Install

npm install hapiboot --save

Setup

Modify your hapi start

//Load HAPI
let Hapi = require('hapi');


//Load HapiBoot
let Boot = require('hapiboot');

//Create server
const server = new Hapi.Server();

//Instantiate hapiBoot
let hapiBoot = new Boot(server, require('./config/boot.json'));

// start hapiBoot
hapiBoot.boot();

// Default hapi config and startup
server.connection({
    host: 'localhost',
    port: process.env.PORT || 3000
});

server.on('log', (event, tags) => {
    console.log(event.data);
});

// Start the server
server.start((err) => {
    if (err) throw err;
    server.log(['info', 'debug'],'Server running at: '+server.info.uri);
});

Config

Create the config file boot.json

{
  "api" : {
    "root" : "api/modules", //Define where your modules are located
  },
  "modules":[ //Define which modules should be loaded
      "helloWorldModule"
  ]
}