hapijs / glue

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

Glue.compose manifest registration param, the results on each connections returned not as expected #78

Closed sikancil closed 7 years ago

sikancil commented 7 years ago
registrations: [
  { name: 'inert', select: [ 'Connection_A', 'Connection_B' ] },
  { name: 'hapi-auth-jwt2', select: [ 'Connection_A' ] },
  { name: 'yar', select: [ 'Connection_A' ] },
  { name: 'vision', select: [ 'Connection_B' ] }
];

results on each connection by check from here:

server.select( "Connection_A" ).registrations
server.select( "Connection_B" ).registrations
output as below (formatted):
[i] Activated plugins on Connection_A connection:  [ inert, hapi-auth-jwt2, yar, vision ]
[i] Activated plugins on Connection_B connection:  [ inert, hapi-auth-jwt2, yar, vision ]

Why it's applied all plugins into all connections? Have I done something wrong?

Glue v4.0.0. Hapi v15.1.1.

@csrl or anybody.. Please take a look the details I had tried on my gist: https://gist.github.com/sikancil/71f0c07d699cdbe248c243e48913fbbf file: server.js line: 200 ~ 208

mtharrison commented 7 years ago

options here https://gist.github.com/sikancil/71f0c07d699cdbe248c243e48913fbbf#file-server-js-L60-L69 should be a sibling of plugin property, not a child. i.e. it should be:

registrations: [
    {
        plugin: 'inert' ,
        options: {
            select: 'web'
        }
    },
    {
        plugin: 'vision',
        options: {
            select: 'api'
        }
    }
]
sikancil commented 7 years ago

@mtharrison Thanks dude, it help much! gist updated.

var newPluginRegistration = {
    //-- place the module/hapi-plugin name as string,
    //   it will call in background as `required(module_name)`
    plugin: pluginName,

    //-- the options will passing into server.register() options
    options: {
        select: [instance.name]
    }
};

as mentioned by @mtharrison :

registrations:  [
    {  plugin: 'inert',  options: {  select: [ 'Connection_A', 'Connection_B' ]  }  },
    {  plugin: 'hapi-auth-jwt2',  options: {  select: [ 'Connection_A' ]  }  },
    {  plugin: 'yar',  options: {  select: [ 'Connection_A' ]  }  },
    {  plugin: 'vision',  options: {  select: [ 'Connection_B' ]  }  }
]

and when we check into each connections (eg: server.select('Connection_A').registrations)

[i] Activated plugins on "Connection_A" connection:  [ inert, hapi-auth-jwt2, yar ]
[i] Activated plugins on "Connection_B" connection:  [ inert, vision ]
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.