1.3.0 • Published 2 years ago

koa-range-static v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

koa-range-static

Static file server middleware, support for multipart ranges request

Install

npm i koa-range-static

Example

const Application = require("koa");
const { rangeStatic } = require("koa-range-static");

const app = new Application();
app.use(rangeStatic({ root: ".", directory: true }));
app.listen(3000);

API

// 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

1.3.0

2 years ago

1.2.0

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago