{ "manifest": { "name": "serve-index", "description": "Serve directory listings", "version": "1.9.1", "author": { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" }, "license": "MIT", "repository": { "type": "git", "url": "https://github.com/expressjs/serve-index.git" }, "dependencies": { "accepts": "~1.3.4", "batch": "0.6.1", "debug": "2.6.9", "escape-html": "~1.0.3", "http-errors": "~1.6.2", "mime-types": "~2.1.17", "parseurl": "~1.3.2" }, "devDependencies": { "after": "0.8.2", "istanbul": "0.4.5", "mocha": "2.5.3", "supertest": "1.1.0" }, "files": [ "public/", "LICENSE", "HISTORY.md", "index.js" ], "engines": { "node": ">= 0.8.0" }, "scripts": { "test": "mocha --reporter spec --bail --check-leaks test/", "test-ci": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/", "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/" }, "_registry": "npm", "_loc": "/home/josie/.cache/yarn/v6/npm-serve-index-1.9.1-integrity/node_modules/serve-index/package.json", "readmeFilename": "README.md", "readme": "# serve-index\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Linux Build][travis-image]][travis-url]\n[![Windows Build][appveyor-image]][appveyor-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![Gratipay][gratipay-image]][gratipay-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[npm-image]: https://img.shields.io/npm/v/serve-index.svg\n[npm-url]: https://npmjs.org/package/serve-index\n[travis-image]: https://img.shields.io/travis/expressjs/serve-index/master.svg?label=linux\n[travis-url]: https://travis-ci.org/expressjs/serve-index\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[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[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg\n[gratipay-url]: https://www.gratipay.com/dougwilson/\n", "licenseText": "(The MIT License)\n\nCopyright (c) 2010 Sencha Inc.\nCopyright (c) 2011 LearnBoost\nCopyright (c) 2011 TJ Holowaychuk\nCopyright (c) 2014-2015 Douglas Christopher Wilson\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy of this software and associated documentation files (the\n'Software'), to deal in the Software without restriction, including\nwithout limitation the rights to use, copy, modify, merge, publish,\ndistribute, sublicense, and/or sell copies of the Software, and to\npermit persons to whom the Software is furnished to do so, subject to\nthe following conditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\nIN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\nCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\nTORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\nSOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n" }, "artifacts": [], "remote": { "resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", "type": "tarball", "reference": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz", "hash": "", "integrity": "sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=", "registry": "npm", "packageName": "serve-index", "cacheIntegrity": "sha512-pXHfKNP4qujrtteMrSBb0rc8HJ9Ms/GrXwcUtUtD5s4ewDJI8bT3Cz2zTVRMKtri49pLx2e0Ya8ziP5Ya2pZZw== sha1-03aNabHn2C5c4FD/9bRTvqEqkjk=" }, "registry": "npm", "hash": "a571df28d3f8aae8ebb6d78cad205bd2b73c1c9f4cb3f1ab5f0714b54b43e6ce1ec03248f1b4f70b3db34d544c2adae2e3da4bc767b461af3388fe586b6a5967" }