hapijs / glue

Server composer for hapi.js
Other
245 stars 62 forks source link

allow plugin options #76

Closed simlevesque closed 8 years ago

simlevesque commented 8 years ago

This fixes my issue here: https://github.com/hapijs/glue/issues/75

I use it like this:

{
    registrations: [
        {
            plugin: {
                register: 'k7',
                options: { // server.register({register, OPTIONS}, options)
                    {
                        connectionString: 'mongodb://localhost:27017/xxx',
                        adapter: MongooseK7,
                        models: 'models/*.js'
                    }
                }
            },
            options: { // server.register(plugin, OPTIONS)
                routes: {
                    prefix: '/v1'
                }
            }
        }
    ]
}
simlevesque commented 8 years ago

I didn't add any new test but the old ones still pass.

If you need any help with the tests or you have any question, ask freely.

simlevesque commented 8 years ago

Great, I removed the explicit key in the Joi schema and it works as it should. Thank you for the quick reply !

csrl commented 8 years ago

I'm not sure what the intention of removing the clone of the plugin is for. But doing so breaks expectation that the input parameters do not get modified by the function. ie. the function now has a side affect. If your plugin wants its own copy of the options, then clone the options in your plugin.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.