{"_id":"@shellscape/koa-send","_rev":"407829","name":"@shellscape/koa-send","description":"Transfer static files","dist-tags":{"latest":"4.1.3"},"maintainers":[{"name":"shellscape","email":""}],"time":{"modified":"2021-08-04T04:56:04.000Z","created":"2018-02-12T01:33:26.184Z","4.1.3":"2018-04-04T16:21:04.739Z","4.1.2":"2018-02-12T01:33:26.184Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/shellscape/koa-send.git"},"versions":{"4.1.3":{"name":"@shellscape/koa-send","description":"Transfer static files","repository":{"type":"git","url":"git+https://github.com/shellscape/koa-send.git"},"version":"4.1.3","keywords":["koa","file","static","sendfile"],"files":["index.js","legacy/index.js"],"publishConfig":{"access":"public"},"devDependencies":{"@babel/cli":"^7.0.0-beta.39","@babel/core":"^7.0.0-beta.39","@babel/polyfill":"^7.0.0-beta.39","@babel/preset-env":"^7.0.0-beta.39","@babel/register":"^7.0.0-beta.39","eslint":"^3.19.0","eslint-config-standard":"^10.2.1","eslint-plugin-import":"^2.2.0","eslint-plugin-node":"^4.2.2","eslint-plugin-promise":"^3.5.0","eslint-plugin-standard":"^3.0.1","iltorb":"^1.2.1","istanbul":"0","koa":"2","mocha":"3","should":"11","supertest":"3"},"license":"MIT","dependencies":{"debug":"^2.6.3","http-errors":"^1.6.1","mz":"^2.6.0","resolve-path":"^1.3.3"},"scripts":{"lint":"eslint --fix .","prepublishOnly":"babel index.js --out-file legacy/index.js","test":"npm run prepublishOnly && mocha --require should --reporter spec","test-cov":"istanbul cover ./node_modules/.bin/_mocha -- --require should","test-travis":"istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require should"},"engines":{"node":">= 6.11.0"},"gitHead":"0fa636b2639efdb743f953a1b92d71ab8c7c6ab0","bugs":{"url":"https://github.com/shellscape/koa-send/issues"},"homepage":"https://github.com/shellscape/koa-send#readme","_id":"@shellscape/koa-send@4.1.3","_npmVersion":"5.6.0","_nodeVersion":"9.2.0","_npmUser":{"name":"shellscape","email":"andrew@shellscape.org"},"dist":{"shasum":"1a7c8df21f63487e060b7bfd8ed82e1d3c4ae0b0","size":5502,"noattachment":false,"key":"/@shellscape/koa-send/-/@shellscape/koa-send-4.1.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/@shellscape/koa-send/download/@shellscape/koa-send-4.1.3.tgz"},"maintainers":[{"name":"shellscape","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-send_4.1.3_1522858864663_0.5493565191841605"},"_hasShrinkwrap":false,"publish_time":1522858864739,"_cnpm_publish_time":1522858864739},"4.1.2":{"name":"@shellscape/koa-send","description":"Transfer static files","repository":{"type":"git","url":"git+https://github.com/shellscape/koa-send.git"},"version":"4.1.2","keywords":["koa","file","static","sendfile"],"files":["index.js","legacy/index.js"],"publishConfig":{"access":"public"},"devDependencies":{"@babel/cli":"^7.0.0-beta.39","@babel/core":"^7.0.0-beta.39","@babel/polyfill":"^7.0.0-beta.39","@babel/preset-env":"^7.0.0-beta.39","@babel/register":"^7.0.0-beta.39","eslint":"^3.19.0","eslint-config-standard":"^10.2.1","eslint-plugin-import":"^2.2.0","eslint-plugin-node":"^4.2.2","eslint-plugin-promise":"^3.5.0","eslint-plugin-standard":"^3.0.1","iltorb":"^1.2.1","istanbul":"0","koa":"2","mocha":"3","should":"11","supertest":"3"},"license":"MIT","dependencies":{"debug":"^2.6.3","http-errors":"^1.6.1","mz":"^2.6.0","resolve-path":"^1.3.3"},"scripts":{"lint":"eslint --fix .","prepublishOnly":"babel index.js --out-file legacy/index.js","test":"mocha --require should --reporter spec","test-cov":"istanbul cover ./node_modules/.bin/_mocha -- --require should","test-travis":"istanbul cover ./node_modules/.bin/_mocha --report lcovonly -- --require should"},"engines":{"node":">= 7.6.0"},"gitHead":"0f5b1103c2c0b13d6179101c2f66d52821ee0abf","bugs":{"url":"https://github.com/shellscape/koa-send/issues"},"homepage":"https://github.com/shellscape/koa-send#readme","_id":"@shellscape/koa-send@4.1.2","_npmVersion":"5.6.0","_nodeVersion":"9.2.0","_npmUser":{"name":"shellscape","email":"andrew@shellscape.org"},"dist":{"shasum":"d76bb15d621f6f49776a2d53b1af808fa39406e7","size":5490,"noattachment":false,"key":"/@shellscape/koa-send/-/@shellscape/koa-send-4.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/@shellscape/koa-send/download/@shellscape/koa-send-4.1.2.tgz"},"maintainers":[{"name":"shellscape","email":""}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/koa-send_4.1.2_1518399205461_0.20347118558824784"},"_hasShrinkwrap":false,"publish_time":1518399206184,"_cnpm_publish_time":1518399206184}},"readme":"\n# koa-send\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\n Static file serving middleware.\n\n## Installation\n\n```js\n$ npm install koa-send\n```\n\n## Options\n\n - `maxage` Browser cache max-age in milliseconds. (defaults to `0`)\n - `immutable` Tell the browser the resource is immutable and can be cached indefinitely. (defaults to `false`)\n - `hidden` Allow transfer of hidden files. (defaults to `false`)\n - [`root`](#root-path) Root directory to restrict file access.\n - `index` Name of the index file to serve automatically when visiting the root location. (defaults to none)\n - `gzip` Try to serve the gzipped version of a file automatically when `gzip` is supported by a client and if the requested file with `.gz` extension exists. (defaults to `true`).\n - `brotli` Try to serve the brotli version of a file automatically when `brotli` is supported by a client and if the requested file with `.br` extension exists. (defaults to `true`).\n - `format` If not `false` (defaults to `true`), format the path to serve static file servers and not require a trailing slash for directories, so that you can do both `/directory` and `/directory/`.\n - [`setHeaders`](#setheaders) Function to set custom headers on response.\n - `extensions` Try to match extensions from passed array to search for file when no extension is sufficed in URL. First found is served. (defaults to `false`)\n\n### Root path\n\n  Note that `root` is required, defaults to `''` and will be resolved,\n  removing the leading `/` to make the path relative and this\n  path must not contain \"..\", protecting developers from\n  concatenating user input. If you plan on serving files based on\n  user input supply a `root` directory from which to serve from.\n\n  For example to serve files from `./public`:\n\n```js\napp.use(async (ctx) => {\n  await send(ctx, ctx.path, { root: __dirname + '/public' });\n})\n```\n\n  To serve developer specified files:\n\n```js\napp.use(async (ctx) => {\n  await send(ctx, 'path/to/my.js');\n})\n```\n\n### setHeaders\n\nThe function is called as `fn(res, path, stats)`, where the arguments are:\n* `res`: the response object\n* `path`: the resolved file path that is being sent\n* `stats`: the stats object of the file that is being sent.\n\nYou should only use the `setHeaders` option when you wish to edit the `Cache-Control` or `Last-Modified` headers, because doing it before is useless (it's overwritten by `send`), and doing it after is too late because the headers are already sent.\n\nIf you want to edit any other header, simply set them before calling `send`.\n\n## Example\n\n```js\nconst send = require('koa-send');\nconst Koa = require('koa');\nconst app = new Koa();\n\n// $ GET /package.json\n// $ GET /\n\napp.use(async (ctx) => {\n  if ('/' == ctx.path) return ctx.body = 'Try GET /package.json';\n  await send(ctx, ctx.path);\n})\n\napp.listen(3000);\nconsole.log('listening on port 3000');\n```\n\n## License\n\n  MIT\n\n[npm-image]: https://img.shields.io/npm/v/koa-send.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/koa-send\n[github-tag]: http://img.shields.io/github/tag/koajs/send.svg?style=flat-square\n[github-url]: https://github.com/koajs/send/tags\n[travis-image]: https://img.shields.io/travis/koajs/send.svg?style=flat-square\n[travis-url]: https://travis-ci.org/koajs/send\n[coveralls-image]: https://img.shields.io/coveralls/koajs/send.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/koajs/send?branch=master\n[david-image]: http://img.shields.io/david/koajs/send.svg?style=flat-square\n[david-url]: https://david-dm.org/koajs/send\n[license-image]: http://img.shields.io/npm/l/koa-send.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/koa-send.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/koa-send\n[gittip-image]: https://img.shields.io/gittip/jonathanong.svg?style=flat-square\n[gittip-url]: https://www.gittip.com/jonathanong/\n","_attachments":{},"homepage":"https://github.com/shellscape/koa-send#readme","bugs":{"url":"https://github.com/shellscape/koa-send/issues"},"license":"MIT"}