@tinyhttp/static

npm (scoped) npm

tinyhttp static middleware for serving files.

Install

pnpm i @tinyhttp/static

API

import { staticHandler, fileToString } from '@tinyhttp/static'

staticHandler(dir, options)

Returns the middleware to handle static files.

Options

fileToString(path)

Reads file and converts to UTF-8 string.

Example

import { App } from '@tinyhttp/app'
import { staticHandler } from '@tinyhttp/static'

const app = new App()

app.use(
  staticHandler('docs', {
    prefix: '/docs',
    recursive: true,
  })
)

app.listen(3000)

Alternatives

License

MIT © v1rtl

Install

pnpm i @tinyhttp/static

Version

0.2.56

Source

packages/static