{"tsd":{"directory":"test/types"},"bugs":{"url":"https://github.com/fastify/fastify-static/issues"},"dist":{"shasum":"438311dbd7c8a1960ec31fed6d399126afbe9abb","tarball":"https://registry.npmjs.org/fastify-static/-/fastify-static-3.0.0.tgz","fileCount":21,"integrity":"sha512-gimIdKP7wzAEhBTsHwdaeZpd9jJU7ccVdgJFEZz3Tt3Q7PX72r1j9So7em0kQAOs/Wv+JufkoR1z5gS0jAF25A==","signatures":[{"sig":"MEYCIQCHNpI51rK1dtGXw2BIj/lxWWjWbygRvbi1By4dA7G+YQIhAOgijAUHrp+xs9lxjYT6sNrCnH6j1ytCiaEPdaV+oBgp","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":80122,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJer+yjCRA9TVsSAnZWagAAUA8QAI/Y8zLEVgS+QIy0qpCD\n8IC1MqwUuLOu7m9OO9jFtsE+E2G1uMuXTRDX5wxRoSvEbZy8myXUexpcjBrg\nq4wWUwdk70XascDzW/Cq4b2hJ94Icyi3VA+A2oh0lfBNhB1Ci7NR/F1Sc7nA\neBNhVzGA5XwDQqRa78VMcd3OrQ/zGtnp6W6R3t9Vcaxg7ff90YikZ3K18UYy\nAsPrh+BLgYi9hcAZ4cxsm7MYQfXxjjbkma08BERd0In5rE3VAwBuF8KNTsKe\nno0wxWgGfOBbc6KMPIByqTTD12K8B7A8lc3MtuajBGp9r83RIi8/eRYtzwoS\n6S6g6ZdAy7uV+02uzxnSECvemI1doZC+JG0cKtUnBQPvuY85jahbBUza6nwE\nL2g0WXxqg2bQs/1budSjTHzmsnokEsp0mBiOtyq3wRJ8p0L2h7SioFKYv4SM\nZNDloQxDfMqZZS/xDqzd0iToNLK6PbFrmOEiFzz6aapku1f+K4Vb4jT7m+LM\na/h7kj2EIj0NgxVkL+DziEs3nRXn+7P/FCw51kO6Kqw7jAWMh4sPzqoTei1z\nb8jtuaekP4YELj+jN4N5TPMqtp1AolT9wB/vEqDa0EoFyBvDkYxsq/kmRclF\nb8Hu/3P4hTaiPiKxC9c+iMlJmHxEQthRyaZ/BewPdbGqpk3kezDp1yFFAD2R\nb+MN\r\n=w1b/\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#### 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":"11f626d21c48bc5feef2d935a020710731c09e6a","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.4","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.16.1","dependencies":{"glob":"^7.1.4","send":"^0.16.0","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.11.0","snazzy":"^8.0.0","fastify":"^3.0.0-rc.1","standard":"^12.0.0","coveralls":"^3.0.4","pre-commit":"^1.2.2","proxyquire":"^2.1.0","simple-get":"^3.0.3","typescript":"^3.5.2","@types/node":"^13.13.4","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.0.0_1588587683336_0.7382409240096335","host":"s3://npm-registry-packages"},"_id":"fastify-static@3.0.0","version":"3.0.0"}