{"id":13799154,"url":"https://github.com/pkoretic/koa-static-server","last_synced_at":"2025-10-28T00:02:54.659Z","repository":{"id":32431947,"uuid":"36009814","full_name":"pkoretic/koa-static-server","owner":"pkoretic","description":"Static file serving middleware for koa with directory, rewrite and index support","archived":false,"fork":false,"pushed_at":"2022-07-18T19:33:24.000Z","size":50,"stargazers_count":61,"open_issues_count":2,"forks_count":10,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-16T03:42:51.626Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/pkoretic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-05-21T11:49:37.000Z","updated_at":"2024-03-11T14:48:06.000Z","dependencies_parsed_at":"2022-08-29T03:51:05.053Z","dependency_job_id":null,"html_url":"https://github.com/pkoretic/koa-static-server","commit_stats":null,"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fkoa-static-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fkoa-static-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fkoa-static-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pkoretic%2Fkoa-static-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pkoretic","download_url":"https://codeload.github.com/pkoretic/koa-static-server/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230479865,"owners_count":18232630,"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":[],"created_at":"2024-08-04T00:00:59.391Z","updated_at":"2025-10-28T00:02:49.608Z","avatar_url":"https://github.com/pkoretic.png","language":"JavaScript","readme":"# koa-static-server\n\n[![GitHub license](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/pkoretic/koa-static-server/blob/master/LICENSE)  \n[![NPM](https://nodei.co/npm/koa-static-server.png?downloads=true\u0026downloadRank=true\u0026stars=true)](https://www.npmjs.com/package/koa-static-server)\n\nstatic file serving middleware for koa with directory, rewrite and index support\n\n## Installation\n\n```bash\n$ npm install koa-static-server\n```\n\n## API\n\n```js\nvar koa = require('koa')\nvar app = koa()\napp.use(require('koa-static-server')(options))\n```\n\n\n### Options\n\n - `rootDir` {string} directory that is to be served\n - `rootPath` {string} optional rewrite path, (defaults to `\"/\"`)\n - `notFoundFile` {string} optional default file to serve if requested static is missing\n - `log` {boolean} request access log to console\n - `last` {boolean} don't execute any downstream middleware. (defaults to `true`)\n - `maxage` Browser cache max-age in milliseconds. (defaults to `0`)\n - `hidden` Allow transfer of hidden files. (defaults to `false`)\n - `index` Name of the index file to serve automatically when visiting root location. (defaults to `\"index.html\"`, use `\"\"` to disable)\n - `gzip` Try to serve the gzipped version of a file automatically when `gzip`\nis supported by a client and if the requested file with `.gz` extension exists.\n(defaults to `true`)\n\n## Example\nSee [examples](https://github.com/pkoretic/koa-static-server/tree/master/examples) for code examples\n\n```js\n// example 'web' directory\n// web/index.html\n// web/file.txt\n\nvar serve = require('koa-static-server')\nvar app = require('koa')()\n\n// root index support\n// GET /\n// returns index.html\n// GET /file.txt\n// returns file.txt\napp.use(serve({rootDir: 'web'}))\n\n// folder support\n// GET /web/\n// returns /web/index.html\n// GET /web/file.txt\n// returns /web/file.txt\napp.use(serve({rootDir: 'web', rootPath: '/web'}))\n\n// index support\n// GET /\n// returns /file.txt\napp.use(serve({rootDir: 'web', index: 'file.txt'}))\n\n// rewrite support\n// GET /web/\n// returns 404\n// GET /admin\n// returns /admin/index.html\napp.use(serve({rootDir: 'web', rootPath: '/admin'}))\n\napp.listen(3000)\n\nconsole.log('listening on port 3000')\n```\n\n## Support\n\n * Issues - [open new issue](https://github.com/pkoretic/koa-static-server/issues)\n * mail - petar.koretic@gmail.com\n\n## License\n\n  MIT\n","funding_links":[],"categories":["JavaScript","仓库"],"sub_categories":["中间件"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fkoa-static-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpkoretic%2Fkoa-static-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpkoretic%2Fkoa-static-server/lists"}