koa-simple-serve

Koa simple middleware for serving static files bound to a specific path


Keywords
koa, serve, static, files, path, directory, folder, css, mime, html, js
License
MIT
Install
npm install koa-simple-serve@1.0.1

Documentation

koa-simple-serve

Koa simple middleware for serving static files saved in a specific folder

var koa = require("koa"),
    serve = require("koa-simple-serve"),
    app = new koa();

// files loaded from ./assets will be cached
app.use(serve("/assets", path.join(__dirname, "assets")));
// files loaded from ../web will not be cached
app.use(serve("/web", path.join(__dirname, "..", "web"), { cache: false }));
app.listen(8000);

Options

cache (defaults to: true): If set to false, the files will be loaded from disk everytime they are requested, else, they will be saved in memory against the next request.

defaultfile (defaults to: index.html): Files that serve as the index for your folders.