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 withformat
. Default isfalse
-
renderDirent
Render directory entries. - For others, see
send options
-
-
send options
-
delay
Delay sending each chunk. Default is0
-
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 isfalse
-
hidden
Allow transfer of hidden files and show hidden directory. Default isfalse
-
immutable
Tell the browser the resource is immutable and can be cached indefinitely. Default isfalse
-
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 is0
-
multipart
Enable multipart ranges. Default istrue
-
root
Root directory to restrict file access. Default isresolve()
-
getBoundaryParam
Boundary parameter required for multipart ranges requests. Default is a random value of length 12
-
License
MIT