hapi-init

0.5.6 • Public • Published

Hapi-Init

Synchronously call functions before other plugins, as they were some dependencies.

Options

  • tasks - an object with functions

If function returned false, then the whole process'd stop there.

Example

server.register({
	register: require('./hapi-init'),
	options: {
		tasks: {
			setConfig: function () {

				var config = {
					prod: {
						dbConnection: 'aws'
					},
					dev:
					{
						dbConnection: 'localhost'
					}
				};

				if (process.env.NODE_ENV === 'prod') {
					server.settings.app = config.prod;
				}
				else {
					server.settings.app = config.dev;
				}

			},
			sayHello: function () {
				server.log(['log'], 'hello')
			}
		}
	}
});

Install

npm install hapi-init

TODO

  • better error reporting/handling

/hapi-init/

    Package Sidebar

    Install

    npm i hapi-init

    Weekly Downloads

    2

    Version

    0.5.6

    License

    ISC

    Last publish

    Collaborators

    • mbael