{"id":13799210,"url":"https://github.com/tunnckoCore/koa-better-serve","last_synced_at":"2025-05-13T06:32:31.772Z","repository":{"id":49957767,"uuid":"70545950","full_name":"tunnckoCore/koa-better-serve","owner":"tunnckoCore","description":"Small, simple and correct serving of files, using `koa-send` - nothing more.","archived":false,"fork":false,"pushed_at":"2023-01-23T20:36:26.000Z","size":1442,"stargazers_count":18,"open_issues_count":20,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-14T09:18:21.515Z","etag":null,"topics":["koa","koa-middleware","serve"],"latest_commit_sha":null,"homepage":"https://i.am.charlike.online","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tunnckoCore.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-10-11T02:01:36.000Z","updated_at":"2023-07-08T10:44:43.000Z","dependencies_parsed_at":"2023-01-24T19:19:05.707Z","dependency_job_id":null,"html_url":"https://github.com/tunnckoCore/koa-better-serve","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-better-serve","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-better-serve/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-better-serve/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tunnckoCore%2Fkoa-better-serve/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tunnckoCore","download_url":"https://codeload.github.com/tunnckoCore/koa-better-serve/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224699781,"owners_count":17355021,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["koa","koa-middleware","serve"],"created_at":"2024-08-04T00:00:59.855Z","updated_at":"2024-11-18T13:32:00.222Z","avatar_url":"https://github.com/tunnckoCore.png","language":"JavaScript","funding_links":[],"categories":["仓库"],"sub_categories":["中间件"],"readme":"# koa-better-serve [![npm version][npmv-img]][npmv-url] [![github release][github-release-img]][github-release-url] [![mit License][license-img]][license-url] [![NPM Downloads Weekly][downloads-weekly-img]][downloads-weekly-url] [![NPM Downloads Total][downloads-total-img]][downloads-total-url] \n\n\u003e Small, simple and correct serving of files, using [koa-send][] - nothing more\n\nYou might also be interested in [koa-better-router](https://github.com/tunnckocore/koa-better-router#readme).\n\n## Quality Assurance :100:\n\n[![Code Climate][codeclimate-img]][codeclimate-url] \n[![Code Style Standard][standard-img]][standard-url] \n[![Linux Build][travis-img]][travis-url] \n[![Code Coverage][codecov-img]][codecov-url] \n[![Dependencies Status][dependencies-img]][dependencies-url] \n[![Renovate App Status][renovate-img]][renovate-url] \n\nIf you have any _how-to_ kind of questions, please read [Code of Conduct](./CODE_OF_CONDUCT.md) and **join the chat** room or [open an issue][open-issue-url].  \nYou may also read the [Contributing Guide](./CONTRIBUTING.md). There, beside _\"How to contribute?\"_, we describe everything **_stated_** by  the badges.\n\n[![tunnckoCore support][gitterchat-img]][gitterchat-url] \n[![Code Format Prettier][prettier-img]][prettier-url] \n[![node security status][nodesecurity-img]][nodesecurity-url] \n[![conventional Commits][ccommits-img]][ccommits-url] \n[![semantic release][semantic-release-img]][semantic-release-url] \n[![Node Version Required][nodeversion-img]][nodeversion-url]\n\n## Table of Contents\n- [Install](#install)\n- [API](#api)\n  * [koaBetterServe](#koabetterserve)\n- [Related](#related)\n- [Contributing](#contributing)\n- [Author](#author)\n- [License](#license)\n\n_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_\n\n## Install\n\nThis project requires [Node.js][nodeversion-url] v7 and above. Use [npm](https://www.npmjs.com) to install it.\n\n```\n$ npm install koa-better-serve\n```\n\n## API\nReview carefully the provided examples and the working [tests](./test.js).\n\n### [koaBetterServe](src/index.js#L33)\n\nServing `dir` of files and folders, when request\nurl (`ctx.url`) match to `pathname`. All behind\nthe scenes is just using [koa-send][].\n**Hint:** use [koa-convert][] to use it for [koa][] v1.\n\n**Params**\n\n* `root` **{String|Buffer}**: folder to serve    \n* `pathname` **{String|RegExp}**: path to match, can be regex    \n* `options` **{Object}**: optional, passed directly to [koa-send][]    \n* `returns` **{Function}**  \n\n**Example**\n\n```jsx\nconst serve = require('koa-better-serve')\nconst Koa = require('koa')\nconst app = new Koa()\n\napp.use(serve('./uploads/images', '/images'))\napp.listen(4290)\n```\n\n## Related\n- [dush](https://www.npmjs.com/package/dush): Microscopic \u0026 functional event emitter in ~350 bytes, extensible through plugins | [homepage](https://github.com/tunnckocore/dush#readme \"Microscopic \u0026 functional event emitter in ~350 bytes, extensible through plugins\")\n- [koa-bel](https://www.npmjs.com/package/koa-bel): View engine for `koa` without any deps, built to be used with… [more](https://github.com/tunnckocore/koa-bel#readme) | [homepage](https://github.com/tunnckocore/koa-bel#readme \"View engine for `koa` without any deps, built to be used with `bel`. Any other engines that can be written in `.js` files would work, too.\")\n- [koa-better-body](https://www.npmjs.com/package/koa-better-body): Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json… [more](https://github.com/tunnckoCore/koa-better-body#readme) | [homepage](https://github.com/tunnckoCore/koa-better-body#readme \"Full-featured [koa][] body parser! Support parsing text, buffer, json, json patch, json api, csp-report, multipart, form and urlencoded bodies. Works for koa@1, koa@2 and will work for koa@3.\")\n- [koa-better-router](https://www.npmjs.com/package/koa-better-router): Stable and lovely router for [koa][], using [path-match][]. Foundation for building powerful… [more](https://github.com/tunnckocore/koa-better-router#readme) | [homepage](https://github.com/tunnckocore/koa-better-router#readme \"Stable and lovely router for [koa][], using [path-match][]. Foundation for building powerful, flexible and RESTful APIs easily.\")\n- [koa-rest-router](https://www.npmjs.com/package/koa-rest-router): Most powerful, flexible and composable router for building enterprise RESTful APIs easily! | [homepage](https://github.com/tunnckocore/koa-rest-router#readme \"Most powerful, flexible and composable router for building enterprise RESTful APIs easily!\")\n- [micro](https://www.npmjs.com/package/micro): Asynchronous HTTP microservices | [homepage](https://github.com/zeit/micro#readme \"Asynchronous HTTP microservices\")\n\n## Contributing\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue][open-issue-url].  \nPlease read the [Contributing Guide](./CONTRIBUTING.md) and [Code of Conduct](./CODE_OF_CONDUCT.md) documents for advices.  \n\n## Author\n- [github/tunnckoCore](https://github.com/tunnckoCore)\n- [twitter/tunnckoCore](https://twitter.com/tunnckoCore)\n- [codementor/tunnckoCore](https://codementor.io/tunnckoCore)\n\n## License\nCopyright © 2016-2017, [Charlike Mike Reagent](https://i.am.charlike.online). Released under the [MIT License](LICENSE).\n\n***\n\n_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on August 15, 2017._  \nProject scaffolded using [charlike-cli][].\n\n[always-done]: https://github.com/hybridables/always-done\n[async-done]: https://github.com/gulpjs/async-done\n[base]: https://github.com/node-base/base\n[browserify]: https://github.com/substack/node-browserify\n[charlike-cli]: https://github.com/tunnckoCore/charlike-cli\n[charlike]: https://github.com/tunnckoCore/charlike\n[commitizen]: https://github.com/commitizen/cz-cli\n[dezalgo]: https://github.com/npm/dezalgo\n[dush-better-use]: https://github.com/tunnckocore/dush-better-use\n[dush-methods]: https://github.com/tunnckocore/dush-methods\n[dush-no-chaining]: https://github.com/tunnckocore/dush-no-chaining\n[dush-options]: https://github.com/tunnckocore/dush-options\n[dush-promise]: https://github.com/tunnckocore/dush-promise\n[dush-router]: https://github.com/tunnckocore/dush-router\n[dush-tap-report]: https://github.com/tunnckocore/dush-tap-report\n[hyperscript]: https://github.com/dominictarr/hyperscript\n[koa-convert]: https://github.com/gyson/koa-convert\n[koa-send]: https://github.com/koajs/send\n[koa]: https://github.com/koajs/koa\n[mitt]: https://github.com/developit/mitt\n[once]: https://github.com/isaacs/once\n[path-match]: https://github.com/pillarjs/path-match\n[rollup]: https://github.com/rollup/rollup\n[standard-version]: https://github.com/conventional-changelog/standard-version\n[verb-generate-readme]: https://github.com/verbose/verb-generate-readme\n[verb]: https://github.com/verbose/verb\n[webpack]: https://github.com/webpack/webpack\n\n\u003c!-- Heading badges --\u003e\n[npmv-url]: https://www.npmjs.com/package/koa-better-serve\n[npmv-img]: https://img.shields.io/npm/v/koa-better-serve.svg\n\n[open-issue-url]: https://github.com/tunnckoCore/koa-better-serve/issues/new\n[github-release-url]: https://github.com/tunnckoCore/koa-better-serve/releases/latest\n[github-release-img]: https://img.shields.io/github/release/tunnckoCore/koa-better-serve.svg\n\n[license-url]: https://github.com/tunnckoCore/koa-better-serve/blob/master/LICENSE\n[license-img]: https://img.shields.io/npm/l/koa-better-serve.svg\n\n[downloads-weekly-url]: https://www.npmjs.com/package/koa-better-serve\n[downloads-weekly-img]: https://img.shields.io/npm/dw/koa-better-serve.svg\n\n[downloads-total-url]: https://www.npmjs.com/package/koa-better-serve\n[downloads-total-img]: https://img.shields.io/npm/dt/koa-better-serve.svg\n\n\u003c!-- Front line badges --\u003e\n[codeclimate-url]: https://codeclimate.com/github/tunnckoCore/koa-better-serve\n[codeclimate-img]: https://img.shields.io/codeclimate/github/tunnckoCore/koa-better-serve.svg\n\n[standard-url]: https://github.com/standard/standard\n[standard-img]: https://img.shields.io/badge/code_style-standard-brightgreen.svg\n\n[travis-url]: https://travis-ci.org/tunnckoCore/koa-better-serve\n[travis-img]: https://img.shields.io/travis/tunnckoCore/koa-better-serve/master.svg?label=linux\n\n[codecov-url]: https://codecov.io/gh/tunnckoCore/koa-better-serve\n[codecov-img]: https://img.shields.io/codecov/c/github/tunnckoCore/koa-better-serve/master.svg\n\n[dependencies-url]: https://david-dm.org/tunnckoCore/koa-better-serve\n[dependencies-img]: https://img.shields.io/david/tunnckoCore/koa-better-serve.svg\n\n[renovate-url]: https://renovateapp.com\n[renovate-img]: https://img.shields.io/badge/renovate-enabled-brightgreen.svg\n\n\u003c!-- Second front of badges --\u003e\n\n[gitterchat-url]: https://gitter.im/tunnckoCore/support\n[gitterchat-img]: https://img.shields.io/gitter/room/tunnckoCore/support.svg\n\n[prettier-url]: https://github.com/prettier/prettier\n[prettier-img]: https://img.shields.io/badge/styled_with-prettier-f952a5.svg\n\n[nodesecurity-url]: https://nodesecurity.io/orgs/tunnckocore-dev/projects/1efca2b5-9131-4e4e-9081-b911c996598e\n[nodesecurity-img]: https://nodesecurity.io/orgs/tunnckocore-dev/projects/1efca2b5-9131-4e4e-9081-b911c996598e/badge\n\u003c!-- the original color of nsp: \n[nodesec-img]: https://img.shields.io/badge/nsp-no_known_vulns-35a9e0.svg --\u003e\n\n[semantic-release-url]: https://github.com/semantic-release/semantic-release\n[semantic-release-img]: https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg\n\n[ccommits-url]: https://conventionalcommits.org/\n[ccommits-img]: https://img.shields.io/badge/conventional_commits-1.0.0-yellow.svg\n\n[nodeversion-url]: https://nodejs.org/en/download\n[nodeversion-img]: https://img.shields.io/node/v/koa-better-serve.svg\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtunnckoCore%2Fkoa-better-serve","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FtunnckoCore%2Fkoa-better-serve","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FtunnckoCore%2Fkoa-better-serve/lists"}