@tinyhttp/favicon

npm (scoped) npm

A rewrite of serve-favicon module.

Favicon middleware to serve favicon.ico file.

Install

pnpm i @tinyhttp/favicon

API

import { favicon } from '@tinyhttp/favicon'

Options

favicon accepts these properties in the options object.

path

Path to icon, required. Passed as the first argument.

maxAge

Sets Cache-Control: maxAge= header, optional. Default is one year. Passed with object in the second argument.

Example

import { favicon } from '@tinyhttp/favicon'
import { createServer } from 'http'
import path from 'path'

const server = http.createServer(async (req, res) => {
  return (await favicon(path.join(process.cwd(), 'public', 'favicon.ico')))(req, res)
})

server.listen(3000)

License

MIT © v1rtl

Install

pnpm i @tinyhttp/favicon

Version

0.0.5

Source

packages/favicon