{"name":"serve-favicon","description":"favicon serving middleware with caching","version":"2.5.1","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","keywords":["express","favicon","middleware"],"repository":{"type":"git","url":"git+https://github.com/expressjs/serve-favicon.git"},"dependencies":{"etag":"~1.8.1","fresh":"~0.5.2","ms":"~2.1.3","parseurl":"~1.3.2","safe-buffer":"~5.2.1"},"devDependencies":{"eslint":"4.19.1","eslint-config-standard":"11.0.0","eslint-plugin-import":"2.31.0","eslint-plugin-markdown":"1.0.2","eslint-plugin-node":"6.0.1","eslint-plugin-promise":"3.8.0","eslint-plugin-standard":"3.1.0","mocha":"10.8.2","nyc":"^15.1.0","supertest":"7.1.1","temp-path":"1.0.0"},"engines":{"node":">= 0.8.0"},"scripts":{"lint":"eslint --plugin markdown --ext js,md .","test":"mocha --reporter spec --bail --check-leaks test/","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_id":"serve-favicon@2.5.1","gitHead":"83da8d55d6511c716f31d9ecd9bf96bdda61fc0a","bugs":{"url":"https://github.com/expressjs/serve-favicon/issues"},"homepage":"https://github.com/expressjs/serve-favicon#readme","_nodeVersion":"22.10.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-JndLBslCLA/ebr7rS3d+/EKkzTsTi1jI2T9l+vHfAaGJ7A7NhtDpSZ0lx81HCNWnnE0yHncG+SSnVf9IMxOwXQ==","shasum":"b6482e81801707d5ed40fa547066e7e44fee47cc","tarball":"http://registry-npm.ywwl.com/serve-favicon/download/serve-favicon-2.5.1.tgz","fileCount":5,"unpackedSize":15017,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIDETPM6nDx/7pYN1BDwxfzSTvwuNk2isBIeb4WLdTd69AiAVZaNvhLwbQLLf2IJjGgqP1nD4QVYJSllIuiXq9UJO7g=="}],"size":5900,"noattachment":false,"key":"/serve-favicon/-/serve-favicon-2.5.1.tgz"},"_npmUser":{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"},"directories":{},"maintainers":[{"name":"dougwilson","email":"doug@somethingdoug.com"},{"name":"ulisesgascon","email":"ulisesgascondev@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/serve-favicon_2.5.1_1749549894541_0.32895309827860175"},"_hasShrinkwrap":false,"readme":"# serve-favicon\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Linux Build Status][ci-image]][ci-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n[![OpenSSF Scorecard Badge][ossf-scorecard-badge]][ossf-scorecard-visualizer]\n\nNode.js middleware for serving a favicon.\n\nA favicon is a visual cue that client software, like browsers, use to identify\na site. For an example and more information, please visit\n[the Wikipedia article on favicons](https://en.wikipedia.org/wiki/Favicon).\n\nWhy use this module?\n\n  - User agents request `favicon.ico` frequently and indiscriminately, so you\n    may wish to exclude these requests from your logs by using this middleware\n    before your logger middleware.\n  - This module caches the icon in memory to improve performance by skipping\n    disk access.\n  - This module provides an `ETag` based on the contents of the icon, rather\n    than file system properties.\n  - This module will serve with the most compatible `Content-Type`.\n\n**Note** This module is exclusively for serving the \"default, implicit favicon\",\nwhich is `GET /favicon.ico`. For additional vendor-specific icons that require\nHTML markup, additional middleware is required to serve the relevant files, for\nexample [serve-static](https://npmjs.org/package/serve-static).\n\n## Install\n\nThis is a [Node.js](https://nodejs.org/en/) module available through the\n[npm registry](https://www.npmjs.com/). Installation is done using the\n[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):\n\n```sh\n$ npm install serve-favicon\n```\n\n## API\n\n### favicon(path, options)\n\nCreate new middleware to serve a favicon from the given `path` to a favicon file.\n`path` may also be a `Buffer` of the icon to serve.\n\n#### Options\n\nServe favicon accepts these properties in the options object.\n\n##### maxAge\n\nThe `cache-control` `max-age` directive in `ms`, defaulting to 1 year. This can\nalso be a string accepted by the [ms](https://www.npmjs.org/package/ms#readme)\nmodule.\n\n## Examples\n\nTypically this middleware will come very early in your stack (maybe even first)\nto avoid processing any other middleware if we already know the request is for\n`/favicon.ico`.\n\n### express\n\n```javascript\nvar express = require('express')\nvar favicon = require('serve-favicon')\nvar path = require('path')\n\nvar app = express()\napp.use(favicon(path.join(__dirname, 'public', 'favicon.ico')))\n\n// Add your routes here, etc.\n\napp.listen(3000)\n```\n\n### connect\n\n```javascript\nvar connect = require('connect')\nvar favicon = require('serve-favicon')\nvar path = require('path')\n\nvar app = connect()\napp.use(favicon(path.join(__dirname, 'public', 'favicon.ico')))\n\n// Add your middleware here, etc.\n\napp.listen(3000)\n```\n\n### vanilla http server\n\nThis middleware can be used anywhere, even outside express/connect. It takes\n`req`, `res`, and `callback`.\n\n```javascript\nvar http = require('http')\nvar favicon = require('serve-favicon')\nvar finalhandler = require('finalhandler')\nvar path = require('path')\n\nvar _favicon = favicon(path.join(__dirname, 'public', 'favicon.ico'))\n\nvar server = http.createServer(function onRequest (req, res) {\n  var done = finalhandler(req, res)\n\n  _favicon(req, res, function onNext (err) {\n    if (err) return done(err)\n\n    // continue to process the request here, etc.\n\n    res.statusCode = 404\n    res.end('oops')\n  })\n})\n\nserver.listen(3000)\n```\n\n## License\n\n[MIT](LICENSE)\n\n[ci-image]: https://badgen.net/github/checks/expressjs/serve-favicon/master?label=ci\n[ci-url]: https://github.com/expressjs/serve-favicon/actions/workflows/ci.yml\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-favicon.svg\n[coveralls-url]: https://coveralls.io/r/expressjs/serve-favicon?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/serve-favicon.svg\n[downloads-url]: https://npmjs.org/package/serve-favicon\n[npm-image]: https://img.shields.io/npm/v/serve-favicon.svg\n[npm-url]: https://npmjs.org/package/serve-favicon\n[ossf-scorecard-badge]: https://api.scorecard.dev/projects/github.com/expressjs/serve-favicon/badge\n[ossf-scorecard-visualizer]: https://ossf.github.io/scorecard-visualizer/#/projects/github.com/expressjs/serve-favicon\n","publish_time":1749549894695,"_cnpm_publish_time":1749549894695,"dist-tags":{"latest":"2.5.1"}}