https://github.com/tarrowren/koa-range-static
Static file server middleware, support for multipart ranges request
https://github.com/tarrowren/koa-range-static
koa
Last synced: about 1 month ago
JSON representation
Static file server middleware, support for multipart ranges request
- Host: GitHub
- URL: https://github.com/tarrowren/koa-range-static
- Owner: Tarrowren
- License: mit
- Created: 2022-06-30T11:46:55.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2022-08-11T05:54:20.000Z (almost 4 years ago)
- Last Synced: 2025-09-24T10:14:39.910Z (9 months ago)
- Topics: koa
- Language: TypeScript
- Homepage:
- Size: 594 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# koa-range-static
Static file server middleware, support for multipart ranges request
## Install
```sh
npm i koa-range-static
```
## Example
```js
const Application = require("koa");
const { rangeStatic } = require("koa-range-static");
const app = new Application();
app.use(rangeStatic({ root: ".", directory: true }));
app.listen(3000);
```
## API
```js
// rangeStatic
const { rangeStatic } = require("koa-range-static");
app.use(rangeStatic(rangeStaticOptions));
// send
const { send } = require("koa-range-static");
app.use(async (ctx) => {
await send(ctx, ctx.path, sendOptions);
});
```
- rangeStatic options
- `directory` Show directory, conflict with `format`. Default is `false`
- `renderDirent` Render directory entries.
- For others, see `send options`
- send options
- `delay` Delay sending each chunk. Default is `0`
- `format` If not false, 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/. Default is `false`
- `hidden` Allow transfer of hidden files and show hidden directory. Default is `false`
- `immutable` Tell the browser the resource is immutable and can be cached indefinitely. Default is `false`
- `index` Name of the index file to serve automatically when visiting the root location. Default is `"index.html"`
- `maxage` Browser cache max-age in seconds. Default is `0`
- `multipart` Enable multipart ranges. Default is `true`
- `root` Root directory to restrict file access. Default is `resolve()`
- `getBoundaryParam` Boundary parameter required for multipart ranges requests. Default is a random value of length 12
## License
MIT