Node.js middleware to serve favicon.ico file.
Go to file
v1rtl a2a4768d4b feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
.github feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
.husky feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
src feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
tests feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
.eslintrc feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
.gitignore feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
.prettierrc Initial commit 2021-07-07 18:35:33 +03:00
LICENSE Initial commit 2021-07-07 18:35:33 +03:00
README.md feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
bun.lockb feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
commitlint.config.cjs Initial commit 2021-07-07 18:35:33 +03:00
package.json feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
tsconfig.eslint.json feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00
tsconfig.json feat: move to bun and tsc, drop ms as dep 2023-10-27 16:03:56 +03:00

README.md

@tinyhttp/favicon

npm GitHub Workflow Status Coverage

A rewrite of serve-favicon module.

Node.js 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 'node:http'
import path from 'node:path'

createServer(favicon(path.join(process.cwd(), 'public', 'favicon.ico')).listen(3000)