@masx200/koa-range
TypeScript icon, indicating that this package has built-in type declarations

1.0.5 • Public • Published

koa-range

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 Build status Test coverage License Dependency status

NPM NPM

Installation

$ npm install @masx200/koa-range

Usage (with koa@2)

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

License

MIT

Readme

Keywords

Package Sidebar

Install

npm i @masx200/koa-range

Weekly Downloads

21

Version

1.0.5

License

MIT

Unpacked Size

62.2 kB

Total Files

10

Last publish

Collaborators

  • masx200