Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trouble using require for reporters in a glue manifest #616

Closed
travi opened this issue Jun 26, 2019 · 1 comment
Closed

trouble using require for reporters in a glue manifest #616

travi opened this issue Jun 26, 2019 · 1 comment
Assignees
Labels
bug
Milestone

Comments

@travi
Copy link

@travi travi commented Jun 26, 2019

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:

good/lib/index.js

Lines 21 to 25 in b70d3e0

Joi.object({
module: Joi.alternatives().try(Joi.string(), Joi.func()).required(),
name: Joi.string(),
args: Joi.array().default([])
})
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?

@hueniverse hueniverse self-assigned this Sep 21, 2019
@hueniverse hueniverse added the bug label Sep 21, 2019
@hueniverse hueniverse added this to the 8.2.3 milestone Sep 21, 2019
@travi

This comment has been minimized.

Copy link
Author

@travi travi commented Sep 22, 2019

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.