Skip to content

Middleware to set content length value for a stream

Notifications You must be signed in to change notification settings

kierans/koa-stream-length

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

koa-stream-length

Middleware to set content length value for a stream

Usage

$ npm install koa-stream-length
const web = createKoa();
web.use(require("koa-stream-length")());

/*
 * In your route/middleware set the response to a stream
 */
const route = async (ctx) => {
  ctx.body = createSomeStream();
}

Calculating length

If the stream has a calculateLength (async) function then that function is called to return the length of the stream.

If the body stream has a path property, it is treated like a file stream and the file is stat'd for it's size.

See

koa-simple-web for a simple way to run a Koa server.

About

Middleware to set content length value for a stream

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published