Home

Awesome

koa-static

NPM version Build status Test coverage License Downloads

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

Installation

$ npm install koa-static

API

import Koa from "koa"; // CJS: require('koa');
import serve from "koa-static"; // CJS: require('koa-static')
const app = new Koa();
app.use(serve(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