{"id":18926814,"url":"https://github.com/ladjs/koa-better-static","last_synced_at":"2025-04-15T13:33:28.924Z","repository":{"id":42367818,"uuid":"164351819","full_name":"ladjs/koa-better-static","owner":"ladjs","description":"Static file serving middleware for Koa.  Forked from an inactive project and maintained for Lad.","archived":false,"fork":false,"pushed_at":"2023-12-06T16:10:11.000Z","size":252,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-23T12:45:14.917Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://lad.js.org","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/ladjs.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":"2019-01-06T22:40:47.000Z","updated_at":"2022-09-16T22:32:29.000Z","dependencies_parsed_at":"2022-08-24T06:21:21.880Z","dependency_job_id":null,"html_url":"https://github.com/ladjs/koa-better-static","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-better-static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-better-static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-better-static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ladjs%2Fkoa-better-static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ladjs","download_url":"https://codeload.github.com/ladjs/koa-better-static/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223672916,"owners_count":17183618,"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-11-08T11:17:14.666Z","updated_at":"2025-04-15T13:33:28.918Z","avatar_url":"https://github.com/ladjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [**@ladjs/koa-better-static**](https://github.com/ladjs/koa-better-static)\n\n[![build status](https://github.com/ladjs/koa-better-static/actions/workflows/ci.yml/badge.svg)](https://github.com/ladjs/koa-better-static/actions/workflows/ci.yml)\n[![code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/sindresorhus/xo)\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n[![made with lass](https://img.shields.io/badge/made_with-lass-95CC28.svg)](https://lass.js.org)\n[![license](https://img.shields.io/github/license/ladjs/koa-better-static.svg)](LICENSE)\n[![npm downloads](https://img.shields.io/npm/dt/@ladjs/koa-better-static.svg)](https://npm.im/@ladjs/koa-better-static)\n\n\u003e Static file serving middleware for Koa.  Forked from an inactive project and maintained for Lad.\n\n\n## Table of Contents\n\n* [Features](#features)\n* [Install](#install)\n* [Usage](#usage)\n* [Options](#options)\n* [Contributors](#contributors)\n* [License](#license)\n\n\n## Features\n\nOur package `@ladjs/koa-better-static` is a high-performance, drop-in replacement for `koa-static` and is a modernized, Koa 2.x+ fork of `koa-better-static` (which is unmaintained and inactive).\n\n* Uses a more optimal version of `koa-send`\n* Supports `If-Modified-Since` header for cache/performance\n* Removal of `gzip` option (which checks for .gz files)\n* Removal of `defer` (if you want this behavior, put the middleware at the end)\n* No default `index` file\n* Faster performance with `findIndex` hidden file lookup\n* Properly sets `Content-Type` header using `mime-types`\n\n\n## Install\n\n[npm][]:\n\n```sh\nnpm install @ladjs/koa-better-static\n```\n\n\n## Usage\n\nThis package exposes a function which accepts two arguments `root` (String - the path to serve assets from) and `opts` (an Object of options, see [Options](#options) below).\n\n```js\nconst serve = require('@ladjs/koa-better-static');\nconst koa = require('koa');\nconst app = koa();\n\n// GET /package.json\napp.use(serve('.'));\n\n// GET /hello.txt\napp.use(serve('test/fixtures'));\n\n// or use absolute paths\napp.use(serve(__dirname + '/test/fixtures'));\n\napp.listen(3000, () =\u003e {\n  console.log('listening on port 3000');\n});\n```\n\n\n## Options\n\n* `maxage` Browser cache max-age in milliseconds. defaults to `0` (`maxAge` camelCase also works as a valid option alternative)\n* `hidden` Allow transfer of hidden files. defaults to false\n* `index` Default file name, defaults to none\n* `ifModifiedSinceSupport`  by sending a 304 (not modified) response. Defaults to true\n* `format`  Allow trailing slashes for directories (e.g.  /directory and /directory. Defaults to true\n\n\n## Contributors\n\n| Name           | Website                    |\n| -------------- | -------------------------- |\n| **Nick Baugh** | \u003chttp://niftylettuce.com/\u003e |\n\n\n## License\n\n[MIT](LICENSE) © [Nick Baugh](http://niftylettuce.com/)\n\n\n##\n\n[npm]: https://www.npmjs.com/\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fkoa-better-static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fladjs%2Fkoa-better-static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fladjs%2Fkoa-better-static/lists"}