@masx200/koa-range
Version:
range request implementation for koa
94 lines (67 loc) • 2.38 kB
Markdown
forked from
https://github.com/koajs/koa-range
It seems that the original project has not been updated for a long time.
The following problems have been fixed.
https://github.com/koajs/koa-range/issues/17
https://github.com/koajs/koa-range/issues/15
https://github.com/koajs/koa-range/issues/16
https://github.com/koajs/koa-range/issues/19
https://github.com/koajs/koa-range/issues/20
=================
range request implementation for koa
[![NPM version][npm-img]][npm-url]
[![Build status][travis-img]][travis-url]
[![Test coverage][coveralls-img]][coveralls-url]
[![License][license-img]][license-url]
[![Dependency status][david-img]][david-url]
[](https://nodei.co/npm/koa-range/)
[](https://nodei.co/npm/koa-range/)
```sh
$ npm install @masx200/koa-range
```
```js
var fs = require("fs");
var range = require("@masx200/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:
- Transpile your code with somehting like Babel
- Use node v7 with --harmony-async-await flag
MIT
[]: https://img.shields.io/npm/v/koa-range.svg?style=flat-square
[]: https://npmjs.org/package/koa-range
[]: https://img.shields.io/travis/koajs/koa-range.svg?style=flat-square
[]: https://travis-ci.org/koajs/koa-range
[]: https://img.shields.io/coveralls/koajs/koa-range.svg?style=flat-square
[]: https://coveralls.io/r/koajs/koa-range?branch=master
[]: https://img.shields.io/badge/license-MIT-green.svg?style=flat-square
[]: https://opensource.org/licenses/MIT
[]: https://img.shields.io/david/koajs/koa-range.svg?style=flat-square
[]: https://david-dm.org/koajs/koa-range