{"name":"serve-index","description":"Serve directory listings","version":"1.9.2","author":{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/expressjs/serve-index.git"},"funding":{"type":"opencollective","url":"https://opencollective.com/express"},"dependencies":{"accepts":"~1.3.8","batch":"0.6.1","debug":"2.6.9","escape-html":"~1.0.3","http-errors":"~1.8.0","mime-types":"~2.1.35","parseurl":"~1.3.3"},"devDependencies":{"after":"0.8.2","eslint":"7.23.0","eslint-plugin-markdown":"2.0.0","mocha":"10.4.0","nyc":"15.1.0","supertest":"6.3.4"},"engines":{"node":">= 0.8.0"},"scripts":{"lint":"eslint .","test":"mocha --reporter spec --check-leaks test/","test-ci":"nyc --reporter=lcov --reporter=text npm test","test-cov":"nyc --reporter=html --reporter=text npm test"},"_id":"serve-index@1.9.2","gitHead":"6f86a185446a37a99b2cd9694ce93df996aeba6f","bugs":{"url":"https://github.com/expressjs/serve-index/issues"},"homepage":"https://github.com/expressjs/serve-index#readme","_nodeVersion":"22.10.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-KDj11HScOaLmrPxl70KYNW1PksP4Nb/CLL2yvC+Qd2kHMPEEpfc4Re2e4FOay+bC/+XQl/7zAcWON3JVo5v3KQ==","shasum":"2988e3612106d78a5e4849ddff552ce7bd3d9bcb","tarball":"http://registry-npm.ywwl.com/serve-index/download/serve-index-1.9.2.tgz","fileCount":96,"unpackedSize":87164,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDN0LWzEJKphxlYF5OKM3UGmVZrGmC/wurrJHixQ8ehRAIgd6J9TBU0Qa22HqAEGfY6XOkwfNkurAZhysxfc/rAh0c="}],"size":61038,"noattachment":false,"key":"/serve-index/-/serve-index-1.9.2.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-index_1.9.2_1769093643871_0.7107952596471436"},"_hasShrinkwrap":false,"readme":"# serve-index\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Linux Build Status][ci-image]][ci-url]\n[![Windows Build][appveyor-image]][appveyor-url]\n[![Coverage Status][coveralls-image]][coveralls-url]\n\n  Serves pages that contain directory listings for a given path.\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-index\n```\n\n## API\n\n```js\nvar serveIndex = require('serve-index')\n```\n\n### serveIndex(path, options)\n\nReturns middlware that serves an index of the directory in the given `path`.\n\nThe `path` is based off the `req.url` value, so a `req.url` of `'/some/dir`\nwith a `path` of `'public'` will look at `'public/some/dir'`. If you are using\nsomething like `express`, you can change the URL \"base\" with `app.use` (see\nthe express example).\n\n#### Options\n\nServe index accepts these properties in the options object.\n\n##### filter\n\nApply this filter function to files. Defaults to `false`. The `filter` function\nis called for each file, with the signature `filter(filename, index, files, dir)`\nwhere `filename` is the name of the file, `index` is the array index, `files` is\nthe array of files and `dir` is the absolute path the file is located (and thus,\nthe directory the listing is for).\n\n##### hidden\n\nDisplay hidden (dot) files. Defaults to `false`.\n\n##### icons\n\nDisplay icons. Defaults to `false`.\n\n##### stylesheet\n\nOptional path to a CSS stylesheet. Defaults to a built-in stylesheet.\n\n##### template\n\nOptional path to an HTML template or a function that will render a HTML\nstring. Defaults to a built-in template.\n\nWhen given a string, the string is used as a file path to load and then the\nfollowing tokens are replaced in templates:\n\n  * `{directory}` with the name of the directory.\n  * `{files}` with the HTML of an unordered list of file links.\n  * `{linked-path}` with the HTML of a link to the directory.\n  * `{style}` with the specified stylesheet and embedded images.\n\nWhen given as a function, the function is called as `template(locals, callback)`\nand it needs to invoke `callback(error, htmlString)`. The following are the\nprovided locals:\n\n  * `directory` is the directory being displayed (where `/` is the root).\n  * `displayIcons` is a Boolean for if icons should be rendered or not.\n  * `fileList` is a sorted array of files in the directory. The array contains\n    objects with the following properties:\n    - `name` is the relative name for the file.\n    - `stat` is a `fs.Stats` object for the file.\n  * `path` is the full filesystem path to `directory`.\n  * `style` is the default stylesheet or the contents of the `stylesheet` option.\n  * `viewName` is the view name provided by the `view` option.\n\n##### view\n\nDisplay mode. `tiles` and `details` are available. Defaults to `tiles`.\n\n## Examples\n\n### Serve directory indexes with vanilla node.js http server\n\n```js\nvar finalhandler = require('finalhandler')\nvar http = require('http')\nvar serveIndex = require('serve-index')\nvar serveStatic = require('serve-static')\n\n// Serve directory indexes for public/ftp folder (with icons)\nvar index = serveIndex('public/ftp', {'icons': true})\n\n// Serve up public/ftp folder files\nvar serve = serveStatic('public/ftp')\n\n// Create server\nvar server = http.createServer(function onRequest(req, res){\n  var done = finalhandler(req, res)\n  serve(req, res, function onNext(err) {\n    if (err) return done(err)\n    index(req, res, done)\n  })\n})\n\n// Listen\nserver.listen(3000)\n```\n\n### Serve directory indexes with express\n\n```js\nvar express    = require('express')\nvar serveIndex = require('serve-index')\n\nvar app = express()\n\n// Serve URLs like /ftp/thing as public/ftp/thing\n// The express.static serves the file contents\n// The serveIndex is this module serving the directory\napp.use('/ftp', express.static('public/ftp'), serveIndex('public/ftp', {'icons': true}))\n\n// Listen\napp.listen(3000)\n```\n\n## License\n\n[MIT](LICENSE). The [Silk](http://www.famfamfam.com/lab/icons/silk/) icons\nare created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/).\n\n[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/serve-index/master.svg?label=windows\n[appveyor-url]: https://ci.appveyor.com/project/dougwilson/serve-index\n[ci-image]: https://badgen.net/github/checks/expressjs/serve-index/master?label=ci\n[ci-url]: https://github.com/expressjs/serve-index/actions/workflows/ci.yml\n[coveralls-image]: https://img.shields.io/coveralls/expressjs/serve-index/master.svg\n[coveralls-url]: https://coveralls.io/r/expressjs/serve-index?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/serve-index.svg\n[downloads-url]: https://npmjs.org/package/serve-index\n[npm-image]: https://img.shields.io/npm/v/serve-index.svg\n[npm-url]: https://npmjs.org/package/serve-index","publish_time":1769093644024,"_cnpm_publish_time":1769093644024,"dist-tags":{"latest":"1.9.2"}}