koa-simple-serve

1.0.1 • Public • Published

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.

Package Sidebar

Install

npm i koa-simple-serve

Weekly Downloads

1,621

Version

1.0.1

License

MIT

Last publish

Collaborators

  • ibrahimlawal