question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom plugin options

See original GitHub issue

🚀 Feature Proposal

I think it could be useful to allow passing custom options to the plugin defined by the app.js. After reading the discussion at https://github.com/fastify/fastify-cli/issues/26 I would like to propose an alternative approach: exposing a pluginOptions property in app.js, the same way the custom options for Fastify are passed using the options property.

Motivation

In some cases, you might need to define custom options for the app.js and you might want to be able to pass them directly through the options object or let fastify-cli inject them.

Example

app.js

module.exports = function (fastify, options, next) {
  ...
  next()
})

module.exports.options = {} // Cusom Fastify options

module.exports.pluginOptions = {} //Custom plugins options injected by fastify-cli

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
dnlupcommented, May 2, 2020

The target is clear, I’m not pro to the module.exports.pluginOptions because it is app.js that loads -using env-schema or other logic- the value of this option and so it is not decoupled: the test must know how app.js implemented the loading logic to change the options. So it should be a different actor that exposes those parameters.

I understand your point, and I agree that it should be a different actor. I thought that exposing the options this way would have been more in line with how fastify options are exposed, and I was wrong. Just to be clear, though, I wasn’t suggesting using pluginOptions in tests, but the opposite. I would have used custom objects without knowing how app.js implemented the loading part. Anyway, I agree with you.

For this reason, I’m pro to a powerful -- because the app.js receives the options without knowing how they are loaded at all.

I like this approach too.

(I say powerful because #208 simply decorate the process.argv and this could be optimized as you suggested, in order to be the input options )

Ok, so we can say that after #208 is merged, there is the groundwork for supporting this and that we would like to support it?

If the answer is yes, should I keep this issue open at this point, or should I open a new one?

Thank you again for the feedback.

1reaction
mcollinacommented, May 1, 2020

I think adding support for passing in args would be nice.

Read more comments on GitHub >

github_iconTop Results From Across the Web

5 Ways to Create a WordPress Plugin Settings Page
Need to create a settings page in a WordPress plugin and wondering what the best approach is? Let's take a look at various...
Read more >
Custom Settings Page | Plugin Developer Handbook
Creating a custom settings page includes the combination of: creating an administration menu, using Settings API and Options API. Alert: Please read these ......
Read more >
Create a Settings Options Page for a WordPress Plugin
Create an Options Page for a Plugin under Settings Menu. To create a sub-menu for your plugin in the dashboard 'Settings' menu, you...
Read more >
How to add setting for custom plugin in the WordPress setting ...
1. Create your custom plugin folder inside the “plugins” folder of your Woo Commerce site. · 2. Create a new PHP file inside...
Read more >
Create WordPress Plugin Settings Page - WPLauncher
Create WordPress Plugin Settings Page · Add your admin menu to the left sidebar in the admin dashboard along with a submenu item...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found