hapijs / glue

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

'relativeTo' option usefulness #12

Closed gagle closed 9 years ago

gagle commented 9 years ago

Have you thought about the logging reporters and the way they are loaded? For example:

'plugins': {
  'good': {
    'reporters': [{
      'reporter': 'good-console',
      'args':[{ 'log': '*' }]
    }]
  },
  './my-plugin': {}
}

The relativeTo property is not taken into consideration when requiring the reporter, and you could be using be a reporter that's not available in the npm registry:

https://github.com/hapijs/good/blob/master/lib/monitor.js#L125

Therefore, you need to write:

'plugins': {
  'good': {
    'reporters': [{
      'reporter': './plugins/my-reporter',
      'args':[{ 'log': '*' }]
    }]
  },
  './my-plugin': {}
}

And it makes no sense to have a relativeTo property because you are obligated to hardcode the relative path anyway. So, for me it's better to just ignore the 'relativeTo' property and always hardcode all the paths.

'plugins': {
  'good': {
    'reporters': [{
      'reporter': './plugins/my-reporter',
      'args':[{ 'log': '*' }]
    }]
  },
  './plugins/my-plugin': {}
}

Just sharing my thoughts. I don't find this property very useful, it obscures information if you simply read the json file. You need to know that the custom plugins are prefixed by a path that's hidden in the source code, when in fact this path it's used by a configuration file. I'd simply remove it and bump the version to 3.0.0.

csrl commented 9 years ago

As you found, Good reporters are not loaded by Glue, but by Good itself. Glue's relativeTo option is irrelevant to it. If you want a change to Good's behavior, please open a ticket against Good.

Glue's relativeTo is used to load plugins and the server cache engine.

We won't remove relativeTo at this time. Its use is not required, so no need to use it if it doesn't meet your needs.

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.