{"_id":"@koa/send","name":"@koa/send","dist-tags":{"latest":"6.0.0"},"versions":{"6.0.0":{"name":"@koa/send","version":"6.0.0","description":"Transfer static files","main":"./dist/index.js","module":"./dist/index.mjs","types":"./dist/index.d.ts","exports":{".":{"require":"./dist/index.js","import":"./dist/index.mjs","types":"./dist/index.d.ts"}},"keywords":["koa","file","static","send-file"],"repository":{"type":"git","url":"git://github.com/koajs/send.git"},"contributors":[{"name":"Imed Jaberi","email":"imed_jebari@hotmail.fr"}],"license":"MIT","devDependencies":{"@types/brotli":"^1.3.1","@types/jest":"^29.5.0","@types/koa":"^2.13.6","@types/node":"^20.3.2","@types/resolve-path":"^1.4.0","@types/supertest":"^2.0.12","brotli":"^1.3.3","eslint-config-xo-lass":"^2.0.1","jest":"^29.5.0","koa":"^2.14.1","supertest":"^6.3.3","ts-jest":"^29.0.5","ts-node":"^10.9.1","tsup":"^6.7.0","typescript":"^5.0.3","xo":"^0.54.2"},"dependencies":{"http-errors":"^2.0.0","resolve-path":"^1.4.0"},"scripts":{"build":"tsup","lint":"xo","lint:fix":"xo --fix","test":"jest --detectOpenHandles","test-ci":"npm run test -- --coverage","prepublishOnly":"npm run build"},"engines":{"node":">= 16"},"bugs":{"url":"https://github.com/koajs/send/issues"},"homepage":"https://github.com/koajs/send","_id":"@koa/send@6.0.0","gitHead":"ff480d05d1b7ad52eb10a06de45c432b80a94b0f","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-CGLI1oMefByKvMJV2SjeHBVfgzQz+OQc5Ir00wvqU4LIhMQP+xmeI8+BRH9gDVIaIj2RSm4KsBezh9EmoEjBCw==","shasum":"1421e2ea500f5c04555425268ebf3b7bc1d1b9dd","tarball":"https://registry.npmjs.org/@koa/send/-/send-6.0.0.tgz","fileCount":15,"unpackedSize":795796,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAJsoHGqV+uJUWAHIVDz5t01kXIZ0R3zAhSQa5oAN7vcAiB4Tz6y7wZImDVYj4f1dg1FOABoc8oP+/+T3pkHuAsAtg=="}]},"_npmUser":{"name":"3imed-jaberi","email":"imed_jebari@hotmail.fr"},"directories":{},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"3imed-jaberi","email":"imed_jebari@hotmail.fr"},{"name":"titanism","email":"npm@titanism.com"},{"name":"niftylettuce","email":"niftylettuce@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"aaron","email":"aaron.heckmann+github@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/send_6.0.0_1728777109311_0.8169789321742273"},"_hasShrinkwrap":false}},"time":{"created":"2024-10-12T23:51:49.180Z","6.0.0":"2024-10-12T23:51:49.510Z","modified":"2024-10-12T23:51:49.982Z"},"maintainers":[{"name":"ljharb","email":"ljharb@gmail.com"},{"name":"3imed-jaberi","email":"imed_jebari@hotmail.fr"},{"name":"titanism","email":"npm@titanism.com"},{"name":"niftylettuce","email":"niftylettuce@gmail.com"},{"name":"fengmk2","email":"fengmk2@gmail.com"},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},{"name":"juliangruber","email":"julian@juliangruber.com"},{"name":"aaron","email":"aaron.heckmann+github@gmail.com"}],"description":"Transfer static files","homepage":"https://github.com/koajs/send","keywords":["koa","file","static","send-file"],"repository":{"type":"git","url":"git://github.com/koajs/send.git"},"contributors":[{"name":"Imed Jaberi","email":"imed_jebari@hotmail.fr"}],"bugs":{"url":"https://github.com/koajs/send/issues"},"license":"MIT","readme":"# [**@koa/send**](https://github.com/koajs/send)\n\n\n[![NPM version][npm-image]][npm-url]\n![Build Status][github-action-image]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\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-action-image]: https://github.com/koajs/send/actions/workflows/ci.yml/badge.svg?style=flat-square\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[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\nKoa static file serving middleware.\n\n> Notice: We recommend using `@koa/send` for installation, as both `koa-send` and `@koa/send` refer to the same module. However, in our next major versions bumps, we will deprecate `koa-send` and only maintain the module under `@koa/send`.\n\n## Install\n\n[![NPM](https://nodei.co/npm/@koa/send.png?downloads=true)](https://nodei.co/npm/@koa/send)\n\n```js\n$ npm i @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\nNote that `root` is required, defaults to `''` and will be resolved,\nremoving the leading `/` to make the path relative and this\npath must not contain \"..\", protecting developers from\nconcatenating user input. If you plan on serving files based on\nuser input supply a `root` directory from which to serve from.\n\nFor 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\nTo 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\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](/LICENSE)\n","readmeFilename":"README.md"}