{"name":"send","description":"Better streaming static file server with Range and conditional-GET support","version":"0.13.0","author":{"name":"TJ Holowaychuk","email":"tj@vision-media.ca"},"contributors":[{"name":"Douglas Christopher Wilson","email":"doug@somethingdoug.com"}],"license":"MIT","repository":{"type":"git","url":"https://github.com/pillarjs/send"},"keywords":["static","file","server"],"dependencies":{"debug":"~2.2.0","depd":"~1.0.1","destroy":"1.0.3","escape-html":"1.0.2","etag":"~1.7.0","fresh":"0.3.0","http-errors":"~1.3.1","mime":"1.3.4","ms":"0.7.1","on-finished":"~2.3.0","range-parser":"~1.0.2","statuses":"~1.2.1"},"devDependencies":{"after":"0.8.1","istanbul":"0.3.9","mocha":"2.2.5","supertest":"1.0.1"},"files":["HISTORY.md","LICENSE","README.md","index.js"],"engines":{"node":">= 0.8.0"},"scripts":{"test":"mocha --check-leaks --reporter spec --bail","test-ci":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --check-leaks --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --check-leaks --reporter dot"},"readme":"# send\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\nSend is a library for streaming files from the file system as a http response\nsupporting partial responses (Ranges), conditional-GET negotiation, high test\ncoverage, and granular events which may be leveraged to take appropriate actions\nin your application or framework.\n\nLooking to serve up entire folders mapped to URLs? Try [serve-static](https://www.npmjs.org/package/serve-static).\n\n## Installation\n\n```bash\n$ npm install send\n```\n\n## API\n\n```js\nvar send = require('send')\n```\n\n### send(req, path, [options])\n\nCreate a new `SendStream` for the given path to send to a `res`. The `req` is\nthe Node.js HTTP request and the `path` is a urlencoded path to send (urlencoded,\nnot the actual file-system path).\n\n#### Options\n\n##### dotfiles\n\nSet how \"dotfiles\" are treated when encountered. A dotfile is a file\nor directory that begins with a dot (\".\"). Note this check is done on\nthe path itself without checking if the path actually exists on the\ndisk. If `root` is specified, only the dotfiles above the root are\nchecked (i.e. the root itself can be within a dotfile when when set\nto \"deny\").\n\n  - `'allow'` No special treatment for dotfiles.\n  - `'deny'` Send a 403 for any request for a dotfile.\n  - `'ignore'` Pretend like the dotfile does not exist and 404.\n\nThe default value is _similar_ to `'ignore'`, with the exception that\nthis default will not ignore the files within a directory that begins\nwith a dot, for backward-compatibility.\n\n##### etag\n\nEnable or disable etag generation, defaults to true.\n\n##### extensions\n\nIf a given file doesn't exist, try appending one of the given extensions,\nin the given order. By default, this is disabled (set to `false`). An\nexample value that will serve extension-less HTML files: `['html', 'htm']`.\nThis is skipped if the requested file already has an extension.\n\n##### index\n\nBy default send supports \"index.html\" files, to disable this\nset `false` or to supply a new index pass a string or an array\nin preferred order.\n\n##### lastModified\n\nEnable or disable `Last-Modified` header, defaults to true. Uses the file\nsystem's last modified value.\n\n##### maxAge\n\nProvide a max-age in milliseconds for http caching, defaults to 0.\nThis can also be a string accepted by the\n[ms](https://www.npmjs.org/package/ms#readme) module.\n\n##### root\n\nServe files relative to `path`.\n\n### Events\n\nThe `SendStream` is an event emitter and will emit the following events:\n\n  - `error` an error occurred `(err)`\n  - `directory` a directory was requested\n  - `file` a file was requested `(path, stat)`\n  - `headers` the headers are about to be set on a file `(res, path, stat)`\n  - `stream` file streaming has started `(stream)`\n  - `end` streaming has completed\n\n### .pipe\n\nThe `pipe` method is used to pipe the response into the Node.js HTTP response\nobject, typically `send(req, path, options).pipe(res)`.\n\n## Error-handling\n\nBy default when no `error` listeners are present an automatic response will be\nmade, otherwise you have full control over the response, aka you may show a 5xx\npage etc.\n\n## Caching\n\nIt does _not_ perform internal caching, you should use a reverse proxy cache\nsuch as Varnish for this, or those fancy things called CDNs. If your\napplication is small enough that it would benefit from single-node memory\ncaching, it's small enough that it does not need caching at all ;).\n\n## Debugging\n\nTo enable `debug()` instrumentation output export __DEBUG__:\n\n```\n$ DEBUG=send node app\n```\n\n## Running tests\n\n```\n$ npm install\n$ npm test\n```\n\n## Examples\n\n### Small example\n\n```js\nvar http = require('http');\nvar send = require('send');\n\nvar app = http.createServer(function(req, res){\n  send(req, req.url).pipe(res);\n}).listen(3000);\n```\n\nServing from a root directory with custom error-handling:\n\n```js\nvar http = require('http');\nvar send = require('send');\nvar url = require('url');\n\nvar app = http.createServer(function(req, res){\n  // your custom error-handling logic:\n  function error(err) {\n    res.statusCode = err.status || 500;\n    res.end(err.message);\n  }\n\n  // your custom headers\n  function headers(res, path, stat) {\n    // serve all files for download\n    res.setHeader('Content-Disposition', 'attachment');\n  }\n\n  // your custom directory handling logic:\n  function redirect() {\n    res.statusCode = 301;\n    res.setHeader('Location', req.url + '/');\n    res.end('Redirecting to ' + req.url + '/');\n  }\n\n  // transfer arbitrary files from within\n  // /www/example.com/public/*\n  send(req, url.parse(req.url).pathname, {root: '/www/example.com/public'})\n  .on('error', error)\n  .on('directory', redirect)\n  .on('headers', headers)\n  .pipe(res);\n}).listen(3000);\n```\n\n## License \n\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/send.svg\n[npm-url]: https://npmjs.org/package/send\n[travis-image]: https://img.shields.io/travis/pillarjs/send/master.svg?label=linux\n[travis-url]: https://travis-ci.org/pillarjs/send\n[appveyor-image]: https://img.shields.io/appveyor/ci/dougwilson/send/master.svg?label=windows\n[appveyor-url]: https://ci.appveyor.com/project/dougwilson/send\n[coveralls-image]: https://img.shields.io/coveralls/pillarjs/send/master.svg\n[coveralls-url]: https://coveralls.io/r/pillarjs/send?branch=master\n[downloads-image]: https://img.shields.io/npm/dm/send.svg\n[downloads-url]: https://npmjs.org/package/send\n[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg\n[gratipay-url]: https://www.gratipay.com/dougwilson/\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/pillarjs/send/issues"},"homepage":"https://github.com/pillarjs/send","_id":"send@0.13.0","_shasum":"518f921aeb0560aec7dcab2990b14cf6f3cce5de","_from":"https://registry.npmjs.org/send/-/send-0.13.0.tgz","_resolved":"https://registry.npmjs.org/send/-/send-0.13.0.tgz"}