fastify / fastify/fastify-static

Have the render function for dirlist work for json as well

Open
#221 3 comments 0 reactions 0 assignees View on GitHub
good first issue semver-minor
Dominant language
JavaScript
Stars
500
Forks
129
Avg merge
2m
Merged PRs (30d)
1

Description

## 🚀 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

```typescript

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,
}
}
},
})
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.