A minimal static file handler for chubbyts-undici-server.
- node: 20
 - @chubbyts/chubbyts-http-error: ^3.0.1
 - @chubbyts/chubbyts-undici-server: ^1.0.0
 
Through NPM as @chubbyts/chubbyts-undici-static-file.
npm i @chubbyts/chubbyts-undici-static-file@^1.0.0import { createStaticFileHandler } from '@chubbyts/chubbyts-undici-static-file/dist/handler';
import { createGetRoute } from '@chubbyts/chubbyts-framework/dist/router/route';
const handler = createStaticFileHandler(
  '/path/to/public/directory',
  (await import('../src/mimetypes')).default,
);
// for example as a fallback route matching everything
const route = createGetRoute({
  path: '/*path',
  name: 'static_file',
  handler,
});2025 Dominik Zogg