Closed dhensby closed 3 months ago
It does seem quite deliberate at the moment that these options
don't make their way to the plugin and seem to not actually be AppOptions
but instead FastifyServerOptions
. However, the TS typings definitely set the expectation that the options would be populated from them when using the --options
flag.
see the TS template for the (potentially misleading) typings: https://github.com/fastify/fastify-cli/blob/v6.1.1/templates/app-ts/src/app.ts
Fixed the linting failure, not sure why the tests failed on macos runner - I've tried adding t.end()
to the end of the new tests incase that was needed, but otherwise can't see an obvious problem 🤔
Fixed the linting regression from adding t.end();
😓
attn: @fastify/typescript
The TS typings and docs strongly imply that the
options
object defined in the app.js file should make their way to the app plugin if the--options
cli argument is present when runningfastify start app.js
. This fix does just that, providing the exported options object back to the app plugin when it is registered.The CLI allows arguments to make their way to the app via additional args (coming after a
--
), eg:fastify start app.js -l info -- --custom test
will populate the pluginoptions
argument with acustom: "test"
property. This change deliberately leaves precedence with the CLI args so that the exportedoptions
object just forms the default values which can then be overridden as required.Potential fix to #593
Checklist
npm run test
~andnpm run benchmark
~