{"tsd":{"directory":"test/types"},"bugs":{"url":"https://github.com/fastify/fastify-static/issues"},"dist":{"shasum":"c8d389ddf56dff9df59bc2952a219a22ae95045e","tarball":"https://registry.npmjs.org/fastify-static/-/fastify-static-3.1.0.tgz","fileCount":26,"integrity":"sha512-od7CZunrw9xUJLObwPTqqoiC5fLDsjBQkWQ1Ebv/tIUiieZZN8NdUaOHjcMwOl3+sUo01k8uUCuhesFBwXrcHw==","signatures":[{"sig":"MEUCIBIELmpzMKIT8fKHfjnD2MAUjiRQuXlvPRspB0EErWPBAiEA+/VRyJ5ESDfr7nHYEwpqqnJZd1LMMQXdmf65x9khuZ8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":195394,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/L1sCRA9TVsSAnZWagAAqH4P/AydDz++0/j6zZI7m6it\nqtOWgCgYOqCC+owlFeBkJBMelhLSXurvYDMqSQssjVTk4CXgE4qbkxFPDZ3w\nQ5XrGwR8HffKFs87XyfVKDekJHPzFQT8k2LX+doxrdpdNMLRah+NNveJURnn\nYpDFpe72M3jrcdSCkGE4//DAHlWxQm1o7RsPgkj6K3XImvMKqQd9k6tLUFMt\ny2nTTlyuHA8sJxq+FN/OPU98RFKxZ2QrbOiurXgFT6MHS2cxy21W65f+63+t\nW2GqoTOPu0chmXU16WEr9VZ+By1A6TbP5C14Sxm59JaDQRxrDvGo5IZL7t1B\n4182sGf7ZDAZBQAGoPi3tQ6hkxV0V6Ouzm8kMPv9mUk5PrgJAmfvfTUgaqLr\nYCLfW2vQHZHd5cqFsYdE1Td+TDPAkp73jWXEwmlrLSrlDShy4YZ7OIGpD/6J\nflUko/CgpUnXsjbSefjC0lUux1oK3GXOLsSXaF6qCvPP2nT3NtPlKzTQPRi3\n+FhEUfpMvWpC0+Y69s/6GDqeRTPaO0MQ6Uq+APFCR/9HplGGz+njZ2N6Oza/\nYW6FNUyINTK4RZUFtmXNx/wSEfhEmblBS/5/EA2v9Qmp2V6WBJ8UJWK7lVQX\netXLRlmPTDFikKHhhviBchqwmpDI33QWdOqMtIznFqnbxoPFj9lncdg1U5cK\nglKX\r\n=EVFe\r\n-----END PGP SIGNATURE-----\r\n"},"main":"index.js","name":"fastify-static","types":"index.d.ts","author":{"name":"Tommaso Allevi - @allevo"},"readme":"# fastify-static\n![CI workflow](https://github.com/fastify/fastify-static/workflows/CI%20workflow/badge.svg) [![Known Vulnerabilities](https://snyk.io/test/github/fastify/fastify-static/badge.svg)](https://snyk.io/test/github/fastify/fastify-static)\n\nPlugin for serving static files as fast as possible. Supports Fastify version `3.x`.\n\nPlease refer to [this branch](https://github.com/fastify/fastify-static/tree/2.x) and related versions for Fastify `^2.0.0` compatibility.\nPlease refer to [this branch](https://github.com/fastify/fastify-static/tree/1.x) and related versions for Fastify `^1.11.0` compatibility.\n\n## Install\n\n`npm install --save fastify-static`\n\n## Usage\n\n```js\nconst fastify = require('fastify')()\nconst path = require('path')\n\nfastify.register(require('fastify-static'), {\n  root: path.join(__dirname, 'public'),\n  prefix: '/public/', // optional: default '/'\n})\n\nfastify.get('/another/path', function (req, reply) {\n  reply.sendFile('myHtml.html') // serving path.join(__dirname, 'public', 'myHtml.html') directly\n})\n\nfastify.get('/path/with/different/root', function (req, reply) {\n  reply.sendFile('myHtml.html', path.join(__dirname, 'build')) // serving a file from a different root location\n})\n\n```\n\n### Multiple prefixed roots\n\n```js\nconst fastify = require('fastify')()\nconst fastifyStatic = require('fastify-static')\nconst path = require('path')\n// first plugin\nfastify.register(fastifyStatic, {\n  root: path.join(__dirname, 'public')\n})\n\n// second plugin\nfastify.register(fastifyStatic, {\n  root: path.join(__dirname, 'node_modules'),\n  prefix: '/node_modules/',\n  decorateReply: false // the reply decorator has been added by the first plugin registration\n})\n\n```\n\n### Options\n\n#### `root` (required)\n\nThe absolute path of the directory that contains the files to serve.\nThe file to serve will be determined by combining `req.url` with the\nprovided root directory.\n\n#### `prefix`\n\nDefault: `'/'`\n\nA URL path prefix used to create a virtual mount path for the static directory.\n\n### `prefixAvoidTrailingSlash`\n\nDefault: `false`\n\nIf set to false prefix will get trailing \"/\" at the end. If set to true, prefix will not append \"/\" to prefix.\n\n#### `schemaHide`\n\nDefault: `true`\n\nA flag that define if the fastify route hide-schema attribute is hidden or not\n\n#### `setHeaders`\n\nDefault: `undefined`\n\nA function to set custom headers on the response. Alterations to the headers\nmust be done synchronously. The function is called as `fn(res, path, stat)`,\nwhere the arguments are:\n\n- `res` The response object.\n- `path` The path of the file that is being sent.\n- `stat` The stat object of the file that is being sent.\n\n#### `send` Options\n\nThe following options are also supported and will be passed directly to the\n[`send`](https://www.npmjs.com/package/send) module:\n\n- [`acceptRanges`](https://www.npmjs.com/package/send#acceptranges)\n- [`cacheControl`](https://www.npmjs.com/package/send#cachecontrol)\n- [`dotfiles`](https://www.npmjs.com/package/send#dotfiles)\n- [`etag`](https://www.npmjs.com/package/send#etag)\n- [`extensions`](https://www.npmjs.com/package/send#extensions)\n- [`immutable`](https://www.npmjs.com/package/send#immutable)\n- [`index`](https://www.npmjs.com/package/send#index)\n- [`lastModified`](https://www.npmjs.com/package/send#lastmodified)\n- [`maxAge`](https://www.npmjs.com/package/send#maxage)\n\n#### `redirect`\n\nDefault: `false`\n\nIf set to `true`, `fastify-static` redirects to the directory with a trailing slash.\n\nThis option cannot be set to `true` with `wildcard` set to `false` on a server\nwith `ignoreTrailingSlash` set to `true`.\n\nIf this option is set to `false`, then requesting directories without trailing \nslash will trigger your app's 404 handler using `reply.callNotFound()`.\n\n#### `wildcard`\n\nDefault: `true`\n\nIf set to `true`, `fastify-static` adds a wildcard route to serve files.\nIf set to `false`, `fastify-static` globs the filesystem for all defined\nfiles in the served folder (`${root}/**/*`), and just creates the routes needed for\nthose.\nIf set to a glob `string` pattern, `fastify-static` will use the provided string when globing the filesystem (`${root}/${wildcard}`).\n\nThe default options of https://www.npmjs.com/package/glob are applied\nfor getting the file list.\n\nThis option cannot be set to `false` with `redirect` set to `true` on a server\nwith `ignoreTrailingSlash` set to `true`.\n\n#### `list`\n\nDefault: `undefined`\n\nIf set, it provide the directory list calling the directory path.\n\nDefault response is json.\n\n**Example:**\n\n```js\nfastify.register(require('fastify-static'), {\n  root: path.join(__dirname, 'public'),\n  prefix: '/public/',\n  list: true\n})\n```\n\nRequest\n\n```bash\nGET .../public\n```\n\nResponse\n\n```json\n{ \"dirs\": [\"dir1\", \"dir2\"], \"files\": [\"file1.png\", \"file2.txt\"] }\n```\n\n#### `list.format`\n\nDefault: `json`\n\nOptions: `html`, `json`\n\nDirectory list can be also in `html` format; in that case, `list.render` function is required.\n\n**Example:**\n\n```js\nfastify.register(require('fastify-static'), {\n  root: path.join(__dirname, 'public'),\n  prefix: '/public/',\n  list: {\n    format: 'html',\n    render: (dirs, files) => {\n      return `\n<html><body>\n<ul>\n  ${dirs.map(dir => `<li><a href=\"${dir.href}\">${dir.name}</a></li>`).join('\\n  ')}\n</ul>\n<ul>\n  ${files.map(file => `<li><a href=\"${file.href}\" target=\"_blank\">${file.name}</a></li>`).join('\\n  ')}\n</ul>\n</body></html>\n`\n      },\n  }\n})\n```\n\nRequest\n\n```bash\nGET .../public\n```\n\nResponse\n\n```html\n<html><body>\n<ul>\n  <li><a href=\"/dir1\">dir1</a></li>\n  <li><a href=\"/dir1\">dir2</a></li>\n</ul>\n<ul>\n  <li><a href=\"/foo.html\" target=\"_blank\">foo.html</a></li>\n  <li><a href=\"/foobar.html\" target=\"_blank\">foobar.html</a></li>\n  <li><a href=\"/index.css\" target=\"_blank\">index.css</a></li>\n  <li><a href=\"/index.html\" target=\"_blank\">index.html</a></li>\n</ul>\n</body></html>\n```\n\n#### `list.names`\n\nDefault: `['']`\n\nDirectory list can respond to different routes, declared in `list.names` options.\n\nNote: if a file with the same name exists, the actual file is sent.\n\n**Example:**\n\n```js\nfastify.register(require('fastify-static'), {\n  root: path.join(__dirname, '/static'),\n  prefix: '/public',\n  prefixAvoidTrailingSlash: true,\n  list: {\n    format: 'json',\n    names: ['index', 'index.json', '/']\n  }\n})\n```\n\nDir list respond with the same content to\n\n```bash\nGET .../public\nGET .../public/\nGET .../public/index\nGET .../public/index.json\n```\n\n#### Disable serving\n\nIf you'd just like to use the reply decorator and not serve whole directories automatically, you can simply pass the option `{ serve: false }`. This will prevent the plugin from serving everything under `root`.\n\n#### Disabling reply decorator\n\nThe reply object is decorated with a `sendFile` function by default.  If you want to\ndisable this, pass the option `{ decorateReply: false }`.  If fastify-static is\nregisters to multiple prefixes in the same route only one can initialize reply\ndecorators.\n\n#### Handling 404s\n\nIf a request matches the URL `prefix` but a file cannot be found for the\nrequest, Fastify's 404 handler will be called. You can set a custom 404\nhandler with [`fastify.setNotFoundHandler()`](https://www.fastify.io/docs/latest/Server/#setnotfoundhandler).\n\n### Handling Errors\n\nIf an error occurs while trying to send a file, the error will be passed\nto Fastify's error handler. You can set a custom error handler with\n[`fastify.setErrorHandler()`](https://www.fastify.io/docs/latest/Server-Methods/#seterrorhandler).\n\n### Payload `stream.filename`\n\nIf you need to access the filename inside the `onSend` hook, you can use `payload.filename`.\n\n```js\nfastify.addHook('onSend', function (req, reply, payload, next) {\n  console.log(payload.filename)\n  next()\n})\n```\n\n## License\n\nLicensed under [MIT](./LICENSE)\n","gitHead":"d1f2edfe58b8aaced3f44251496c138fdc491190","license":"MIT","scripts":{"lint":"standard | snazzy","test":"npm run lint && npm run unit && npm run typescript","unit":"tap test/*.test.js","example":"node example/server.js","coverage":"tap --cov --coverage-report=html test","coveralls":"tap test/*test.js  test/*/*.test.js --cov","typescript":"tsd"},"_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"homepage":"https://github.com/fastify/fastify-static","keywords":["fastify","static"],"repository":{"url":"git+https://github.com/fastify/fastify-static.git","type":"git"},"_npmVersion":"6.14.5","description":"Plugin for serving static files as fast as possible.","directories":{},"maintainers":[{"name":"allevo","email":"tomallevi@gmail.com"},{"name":"cemremengu","email":"cemremengu@gmail.com"},{"name":"delvedor","email":"tommydelved@gmail.com"},{"name":"eomm","email":"behemoth89@gmail.com"},{"name":"ethan_arrowood","email":"ethan.arrowood@gmail.com"},{"name":"jsumners","email":"james.sumners@gmail.com"},{"name":"matteo.collina","email":"hello@matteocollina.com"},{"name":"starptech","email":"deusdustin@gmail.com"}],"_nodeVersion":"12.18.1","dependencies":{"glob":"^7.1.4","send":"^0.17.1","fastify-plugin":"^2.0.0","readable-stream":"^3.4.0"},"eslintConfig":{"rules":{"no-unused-vars":"off","@typescript-eslint/no-unused-vars":"error"}},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"tap":"^14.10.7","tsd":"^0.12.0","snazzy":"^8.0.0","fastify":"^3.0.0-rc.5","standard":"^14.0.0","coveralls":"^3.0.4","handlebars":"^4.7.6","pre-commit":"^1.2.2","proxyquire":"^2.1.0","simple-get":"^4.0.0","typescript":"^3.5.2","@types/node":"^14.0.1","concat-stream":"^2.0.0","fastify-compress":"^3.0.0","eslint-plugin-typescript":"^0.14.0","@typescript-eslint/parser":"^2.29.0","@typescript-eslint/eslint-plugin":"^2.29.0"},"_npmOperationalInternal":{"tmp":"tmp/fastify-static_3.1.0_1593621868370_0.7765142723721379","host":"s3://npm-registry-packages"},"_id":"fastify-static@3.1.0","version":"3.1.0"}