0.2.2 • Published 8 years ago

hapiboot v0.2.2

Weekly downloads
1
License
ISC
Repository
github
Last release
8 years ago

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"
  ]
}
0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago