Home

Awesome

koa-static

NPM version Build status Test coverage Dependency Status License Downloads

Koa static file serving middleware, wrapper for koa-send.

Installation

$ npm install koa-static

API

const Koa = require('koa');
const app = new Koa();
app.use(require('koa-static')(root, opts));

Options

Example

const serve = require('koa-static');
const Koa = require('koa');
const app = new Koa();

// $ GET /package.json
app.use(serve('.'));

// $ GET /hello.txt
app.use(serve('test/fixtures'));

// or use absolute paths
app.use(serve(__dirname + '/test/fixtures'));

app.listen(3000);

console.log('listening on port 3000');

See also

License

MIT