hapi-bootstrap

0.0.8 • Public • Published

Hapi bootstrap helper

Requires a project to be in a following setup

- project root
    - server
        - plugins
            hapi-plugin-1.plugin.js
            ...
        - jobs
            job-1.job.js
            ...
        - startup
            startup-1.onstartup.js

To initialize a hapi server use

const bootstrap = require('hapi-bootstrap').bootstrap
const server = new Hapi.Server()

...

bootstrap(server).then(server => {
    ...
    server.start(...)
})

Bootstrap process attaches a variable to the server instance determining the startup state o the server server.bootstrap.finished. If this variable is true then the server is fully initialized and all startup scripts have finished their execution. Additionally to this variable an event is emitted when initialization is finished:

server.bootstrap.on('finished', () => {})

Authentication

If default authentication is used, please provide the selected strategy as a server variable:

server.decorate('server', 'defaultAuth', '[INSERT DEFAULT STRATEGY NAME HERE]')

This information will be used for adding OPTIONS routes and determining whether a route is authorized or not

Readme

Keywords

none

Package Sidebar

Install

npm i hapi-bootstrap

Weekly Downloads

0

Version

0.0.8

License

ISC

Last publish

Collaborators

  • tresmo