UNPKG

motion

Version:

motion - moving development forward

92 lines (91 loc) 8.27 kB
{ "_args": [ [ "send@https://registry.npmjs.org/send/-/send-0.12.2.tgz", "/Users/nw/flint/packages/flint" ] ], "_from": "send@0.12.2", "_id": "send@0.12.2", "_inCache": true, "_location": "/send", "_phantomChildren": {}, "_requested": { "name": "send", "raw": "send@https://registry.npmjs.org/send/-/send-0.12.2.tgz", "rawSpec": "https://registry.npmjs.org/send/-/send-0.12.2.tgz", "scope": null, "spec": "https://registry.npmjs.org/send/-/send-0.12.2.tgz", "type": "remote" }, "_requiredBy": [ "/express" ], "_resolved": "https://registry.npmjs.org/send/-/send-0.12.2.tgz", "_shasum": "ba6785e47ab41aa0358b9da401ab22ff0f58eab6", "_shrinkwrap": null, "_spec": "send@https://registry.npmjs.org/send/-/send-0.12.2.tgz", "_where": "/Users/nw/flint/packages/flint", "author": { "email": "tj@vision-media.ca", "name": "TJ Holowaychuk" }, "bugs": { "url": "https://github.com/pillarjs/send/issues" }, "contributors": [ { "name": "Douglas Christopher Wilson", "email": "doug@somethingdoug.com" } ], "dependencies": { "debug": "~2.1.3", "depd": "~1.0.0", "destroy": "1.0.3", "escape-html": "1.0.1", "etag": "~1.5.1", "fresh": "0.2.4", "mime": "1.3.4", "ms": "0.7.0", "on-finished": "~2.2.0", "range-parser": "~1.0.2" }, "description": "Better streaming static file server with Range and conditional-GET support", "devDependencies": { "after": "0.8.1", "istanbul": "0.3.7", "mocha": "~2.2.1", "supertest": "~0.15.0" }, "engines": { "node": ">= 0.8.0" }, "files": [ "HISTORY.md", "LICENSE", "README.md", "index.js" ], "homepage": "https://github.com/pillarjs/send#readme", "keywords": [ "file", "server", "static" ], "license": "MIT", "name": "send", "optionalDependencies": {}, "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", "repository": { "type": "git", "url": "git+https://github.com/pillarjs/send.git" }, "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" }, "version": "0.12.2" }