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

Have the render function for dirlist work for json as well #221

Open
lordnox opened this issue Jul 14, 2021 · 3 comments
Open

Have the render function for dirlist work for json as well #221

lordnox opened this issue Jul 14, 2021 · 3 comments
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor

Comments

@lordnox
Copy link

lordnox commented Jul 14, 2021

🚀 Feature Proposal

With an optional render function for dirlist we could change the results for the json output by either removing files we don't want to show (filter all non-images) or send more data (adding more stats, mimetype or other data)

Motivation

I'd like to have a image server running that connects to a directory and only sends out images, the client should not see other data

Example

  fastify.register(fastifyStatic, {
    root: path.resolve(options.imagePath),
    prefix: options.path,
    dotfiles: 'ignore',
    list: {
      format: 'json',
      names: ['index', 'index.json', '/', ''],
      render: (files, dirs) => {
        return {
          files: files.filter(file => !isImage(file)).map(file => generateImageInfo(file)),
          dirs,
        }
      }
    },
  })
@mcollina mcollina added semver-minor Issue or PR that should land as semver minor good first issue Good for newcomers labels Jul 14, 2021
@mcollina
Copy link
Member

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

@ChakshuGautam
Copy link

I would like to pick this up @mcollina.

@mcollina
Copy link
Member

Go for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers semver-minor Issue or PR that should land as semver minor
Projects
None yet
Development

No branches or pull requests

3 participants