{"id":13799266,"url":"https://github.com/janpieterz/koajs-static-folder","last_synced_at":"2025-05-08T01:41:47.885Z","repository":{"id":14944191,"uuid":"17668783","full_name":"janpieterz/koajs-static-folder","owner":"janpieterz","description":"Middleware for KoaJS to serve folder as static files.","archived":false,"fork":false,"pushed_at":"2016-02-28T13:38:56.000Z","size":12,"stargazers_count":10,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-31T16:14:19.720Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"google/google-api-php-client","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/janpieterz.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":"2014-03-12T13:59:31.000Z","updated_at":"2021-06-07T02:49:13.000Z","dependencies_parsed_at":"2022-09-24T01:00:23.565Z","dependency_job_id":null,"html_url":"https://github.com/janpieterz/koajs-static-folder","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2Fkoajs-static-folder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2Fkoajs-static-folder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2Fkoajs-static-folder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/janpieterz%2Fkoajs-static-folder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/janpieterz","download_url":"https://codeload.github.com/janpieterz/koajs-static-folder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252983761,"owners_count":21835758,"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:01:00.492Z","updated_at":"2025-05-08T01:41:47.859Z","avatar_url":"https://github.com/janpieterz.png","language":"JavaScript","funding_links":[],"categories":["仓库"],"sub_categories":["中间件"],"readme":"# koajs-static-folder\n\n[![Version](https://img.shields.io/npm/v/koa-static-folder.svg?style=flat-square)](https://www.npmjs.com/package/koa-static-folder)\n[![Downloads](https://img.shields.io/npm/dm/koa-static-folder.svg?style=flat-square)](https://www.npmjs.com/package/koa-static-folder)\n\nMiddleware for KoaJS to serve a folder as static files. Other implementations require every file to be appointed individually (as far as I know). The software initializes at the startup of your application, so changes made in the underlying folders require a restart of your app.\n\n\n## Options\n\n - `maxage` Browser cache max-age in milliseconds. defaults to 0\n - `hidden` Allow transfer of hidden files. defaults to false\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 - `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\n\n## Example\n```js\nvar serve = require('koa-static-folder'),\n    koa = require('koa'),\n    app = koa();\n\napp.use(serve('./public'));\napp.use(serve('./assets', {maxage: 5 * 60 * 1000}));\n\napp.use(function *(next){\n    if('/' == this.path){\n        this.body = 'Try GET one of the following: `/assets/style.css`,`/public/blabla.json`,`/public/style.css`';\n    }\n});\n\napp.listen(8000);\nconsole.log('Koa server listening at port 8000');\n```\n\n## License\n  MIT\n\n## Release log\n0.1.6 - Added the possibility to inform max-age for caching.  \n0.1.5 - Updated documentation slightly.  \n0.1.4 - Updated documentation slightly.  \n0.1.3 - Using procedd.cwd() instead of dirname fixing some bugs with different file locations and systems.  \n0.1.2 - Removed unnecessary dependencies and fixed broken dependency.  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpieterz%2Fkoajs-static-folder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjanpieterz%2Fkoajs-static-folder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjanpieterz%2Fkoajs-static-folder/lists"}