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

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.5.6
    2
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.5.6
    2
  • 0.5.5
    1

Package Sidebar

Install

npm i hapi-init

Weekly Downloads

2

Version

0.5.6

License

ISC

Last publish

Collaborators

  • mbael