hapijs / good

hapi process monitoring
Other
525 stars 161 forks source link

trouble using require for reporters in a glue manifest #616

Closed travi closed 5 years ago

travi commented 5 years ago

i'm trying to put together a new hapi app using a glue manifest, but am having trouble using the require form of registering good reporters. i use the require approach over the string version because it works better when using webpack to bundle the app.

this approach results in "console" at position 0 does not match any of the allowed types

      {
        plugin: require('@hapi/good'),
        options: {
          ops: {
            interval: 1000
          },
          reporters: {
            console: [
              {
                module: require('@hapi/good-squeeze'),
                name: 'Squeeze',
                args: [{log: '*', request: '*', response: '*', error: '*'}]
              },
              {module: require('@hapi/good-console')},
              'stdout'
            ]
          }
        }
      }

but this approach works:

      {
        plugin: require('@hapi/good'),
        options: {
          ops: {
            interval: 1000
          },
          reporters: {
            console: [
              {
                module: '@hapi/good-squeeze',
                name: 'Squeeze',
                args: [{log: '*', request: '*', response: '*', error: '*'}]
              },
              {module: require('@hapi/good-console')},
              'stdout'
            ]
          }
        }
      }

the failure appears to be from the joi validation here: https://github.com/hapijs/good/blob/b70d3e0dd0947af919cf707f9adf0524bbea5074/lib/index.js#L21-L25 but it's not immediately clear to me why the require approach works for @hapi/good-console but not for @hapi/good-squeeze. i've been successful with this approach in the past, but it looks like this rule was added fairly recently.

should this approach still work?

travi commented 5 years ago

thanks!

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.