/ never-odd-or-even / back / node_modules / koa-range /

[ICO]NameLast modifiedSizeDescription
[PARENTDIR]Parent Directory  -  
[DIR]test/2 years ago -  
[   ]Makefile8 years ago581  
[TXT]README.md8 years ago1.9K 
[   ]index.js8 years ago2.3K 
[   ]package.json2 years ago1.6K 
README.md

koa-range

range request implementation for koa

NPM version Build status Test coverage License Dependency status

NPM NPM

Installation

$ npm install koa-range

Usage (with koa@2)

var fs = require('fs');
var range = require('koa-range');
var route = require('koa-route');
var Koa = require('koa');
var app = new Koa();

app.use(range);

// via buffer
app.use(route.get('/', async function (ctx) {
  ctx.body = new Buffer(100);
}));

// via object
app.use(route.get('/json', async function (ctx) {
  ctx.body = {
    'foo': 'bar'
  };
}));

// via readable stream
app.use(route.get('/stream', async function (ctx) {
  ctx.body = fs.createReadStream('your path');
}));

Until async/await is supported by default, you will need to do one of the following:

License

MIT

Apache/2.4.38 (Debian) Server at www.karls.computer Port 80