fastify-static icon indicating copy to clipboard operation
fastify-static copied to clipboard

When using serve: false, root should be optional

Open tonttu opened this issue 1 year ago • 2 comments

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] I have searched existing issues to ensure the feature has not already been requested

🚀 Feature Proposal

I just want to use the sendFile decorator without serving any files automatically, so I set serve: false. However, I still need to provide a valid path to root, otherwise checkRootPathForErrors complains. Now I resort to creating a dummy directory in tmpdir() just to keep this plugin happy, which seems a bit silly.

I think if serve: false is defined, checkRootPathForErrors should not be called at all.

Motivation

No response

Example

No response

tonttu avatar Aug 19 '24 08:08 tonttu

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

mcollina avatar Aug 19 '24 13:08 mcollina

Thank's for the quick response. I'm currently short on time and I don't think I'll be able to submit a PR at the moment.

tonttu avatar Aug 19 '24 14:08 tonttu

Hi @mcollina, I’d like to contribute to this open issue #460. Could you confirm if it’s available to work on?

Dipali127 avatar Oct 05 '25 09:10 Dipali127

@Dipali127 Feel free to contribute! We don't assign issues in order to avoid cookie licking.

Fdawgs avatar Oct 05 '25 09:10 Fdawgs

@Fdawgs I’ve pushed the missing index.js changes. The PR is now ready for review.

Dipali127 avatar Oct 08 '25 08:10 Dipali127

@Fdawgs I’ve updated the PR to keep the original styling and added the space before the parentheses as per your suggestion. The functional changes for serve: false behavior remain unchanged.

Dipali127 avatar Oct 09 '25 08:10 Dipali127

@Fdawgs Fixed the linting issues. All tests and lint checks now pass locally. Please let me know if any further changes are needed.

Dipali127 avatar Oct 11 '25 12:10 Dipali127