Kind: Interface
Source: packages/platform-fastify/interfaces/external/fastify-static-options.interface.ts
Part of: Platform Fastify
ListOptionsJsonFormat configures directory listing output for the Fastify static file integration when JSON responses are required. It fixes the format discriminator to 'json' and requires a render function that generates the listing response.
Properties
| Property | Type |
|---|---|
format | 'json' |
render | ListRender |
Diagram
mermaidgraph LR A[Fastify Static Directory Listing] --> B[ListOptionsJsonFormat] B --> C[format: 'json'] B --> D[render: ListRender] D --> E[JSON Directory Listing Response]
Usage
tsimport type { ListOptionsJsonFormat } from './interfaces/external/fastify-static-options.interface';
const listOptions: ListOptionsJsonFormat = {
format: 'json',
render: (request, reply, files) => {
return reply.send({
files: files.map((file) => ({
name: file.name,
path: file.path,
})),
});
},
};
// Pass listOptions to the Fastify static plugin configuration.
AI Coding Instructions
- Set
formatexactly to'json'; it acts as the discriminator for this listing configuration. - Always provide a
renderimplementation compatible with theListRendertype. - Return or send a JSON-serializable response from
render. - Use this interface only for directory listing behavior in the Fastify static integration.
- Avoid mixing JSON-specific options with other listing format configurations.
Was this page helpful?